PL/pgsql: function passing argument to IN operator

Поиск
Список
Период
Сортировка
От Daniel Myers
Тема PL/pgsql: function passing argument to IN operator
Дата
Msg-id 455d64770712282240h3c93a2f0y9e357d1d23882b10@mail.gmail.com
обсуждение исходный текст
Ответы Re: PL/pgsql: function passing argument to IN operator
Список pgsql-sql
Hello list,  I'm trying to write a function that uses one of its arguments as
an input to an IN operator in a WHERE clause. I.e., something like:

-- ids are actually integers
CREATE FUNCTION foo(ids SOMETYPE) RETURNS [whatever] AS $$
BEGIN  SELECT id, [other stuff] FROM table WHERE [other conditions] AND
id IN (ids);  RETURN;
END
$$ plpgsql

I had wanted to avoid using the EXECUTE statement and dynamically
creating the query string, because 1) I'd rather not recompile the
query each time and 2) I'm doing a SELECT INTO, which apparently
doesn't work with EXECUTE.

Can anyone help me out?

Thanks,
Daniel

P.S.: Sorry if capitalizing SQL keywords is bad list etiquette...


В списке pgsql-sql по дате отправления:

Предыдущее
От: Marcin Stępnicki
Дата:
Сообщение: Re: Advice for generalizing trigger functions
Следующее
От: "Pavel Stehule"
Дата:
Сообщение: Re: PL/pgsql: function passing argument to IN operator