Re: IN Operator query

Поиск
Список
Период
Сортировка
От Michael Swierczek
Тема Re: IN Operator query
Дата
Msg-id CAHp1f1NjjGKp_pr8wFujJccZdNRxf+b1pcMahsjfFySEAo5YLw@mail.gmail.com
обсуждение исходный текст
Ответ на IN Operator query  (DrYSG <ygutfreund@draper.com>)
Ответы Re: IN Operator query  (Michael Swierczek <mike.swierczek@gmail.com>)
Список pgsql-novice
On Thu, Jul 5, 2012 at 10:31 AM, DrYSG <ygutfreund@draper.com> wrote:
> I made a naive and stupid assumption that I could pass in a TEXT parameter to
> a plpsql Stored Procedure, and use that value in a IN SQL operation.
>
> That is
>
> My naïve hope was that if iFILTER was set to: "CADRG, DTED1, DTED2, SRTF"
>
> (cat.type in (iFilter)) would expand to:
>
> (cat.type in (CADRG, DTED1, DTED2, SRTF))
>
> But that is not working.
>

I believe using the PostgreSQL array type might help,
http://www.postgresql.org/docs/9.1/static/arrays.html

Instead of declaring your iFilter parameter as TEXT, declare it as ARRAY.
Then instead of 'CADRG, DTED1, DTED2, SRTF' you would put the input
parameter as '{"CADRG", "DTED1", "DTED2", "SRTF"}'

And then change cat.type in (iFilter) to cat.type = ANY (iFilter)

Good luck.
-Mike Swierczek

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: IN Operator query
Следующее
От: Michael Swierczek
Дата:
Сообщение: Re: IN Operator query