Re: Pass where clause to a function

Поиск
Список
Период
Сортировка
От John R Pierce
Тема Re: Pass where clause to a function
Дата
Msg-id 53EC471F.9030400@hogranch.com
обсуждение исходный текст
Ответ на Pass where clause to a function  (Andrew Bartley <ambartley@gmail.com>)
Ответы Re: Pass where clause to a function
Список pgsql-general
On 8/13/2014 10:08 PM, Andrew Bartley wrote:
>
> Is it possible to create a view or foreign table that will do
> something like this
>
> select * from table_x
> where x_id = 10;
>
> passing the where "x_id = 10" to a function
>
> sorta like this
>
> select * from api_function('x = 10')
>
> or
>
>  select * from api_function(10)
>
> passing the result set back to the original select....
>

your first version of api_function would have to use that x=10 to
construct the query and EXECUTE it, then return the recordset,

your second version of the view would just pass 10 in as an argument,
which could be used for the query select * from table_x where x_id=$1

either way, your view would be select * from api_function(whichever).

but I think you're rather confused here, as I don't see much utility in
either of these constructs in the form you specified.



--
john r pierce                                      37N 122W
somewhere on the middle of the left coast



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

Предыдущее
От: Andrew Bartley
Дата:
Сообщение: Pass where clause to a function
Следующее
От: Andrew Bartley
Дата:
Сообщение: Re: Pass where clause to a function