Re: variables in sql functions

Поиск
Список
Период
Сортировка
От otis_usenet@yahoo.com (OtisUsenet)
Тема Re: variables in sql functions
Дата
Msg-id 5606b639.0202280901.6065833d@posting.google.com
обсуждение исходный текст
Ответ на variables in sql functions  (ceco@noxis.net (ceco))
Список pgsql-general
I think you can use SELECT INTO <variable here>.
I read that in the online version of the Practical PostgreSQL book.

Otis

ceco@noxis.net (ceco) wrote in message news:<533d2efe.0202220313.79cb0e2d@posting.google.com>...
> Is there a way for something like that to be made with sql function
> not plpgsql
>
> CREATE FUNCTION resource_limit($int4, date) RETURNS BOOLEAN
> AS '
> SELECT SUM(amount) as $user_amount FROM user_resource WHERE id = $1;
> SELECT SUM(amount) > ($user_amount) FROM resource WHERE enddate > $2
> '
> LANGUAGE 'sql'
> WITH     (isstrict);
>
>
> It is a reduced version, but it gives the idea of what I need - I need
> to select a constant for the duration of the function data as a
> variable and use it for the later query.

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

Предыдущее
От: "Patrick Loh"
Дата:
Сообщение: Benefit of postgresql and benchmark
Следующее
От: john@localhost.localdomain (John)
Дата:
Сообщение: Newbie question re SQL