variables in sql functions - Mailing list pgsql-general

From ceco@noxis.net (ceco)
Subject variables in sql functions
Date
Msg-id 533d2efe.0202220313.79cb0e2d@posting.google.com
Whole thread Raw
List pgsql-general
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 by date:

Previous
From: Marcelo Pereira
Date:
Subject: Re: Select <-> Case Insensitive
Next
From: rorfin@yahoo.com (Roman)
Date:
Subject: funciton returning result of a select statement