Re: variables in sql functions

From: otis_usenet(at)yahoo(dot)com (OtisUsenet)
To: pgsql-general(at)postgresql(dot)org
Subject: Re: variables in sql functions
Date: 2002-02-28 17:01:35
Message-ID: 5606b639.0202280901.6065833d@posting.google.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)noxis(dot)net (ceco) wrote in message news:<533d2efe(dot)0202220313(dot)79cb0e2d(at)posting(dot)google(dot)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.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Gavin Scott 2002-02-28 17:16:07 Re: Defunct postmasters
Previous Message OtisUsenet 2002-02-28 16:57:27 Help with SET TRANSACTION in a function