variables in sql functions

From: ceco(at)noxis(dot)net (ceco)
To: pgsql-general(at)postgresql(dot)org
Subject: variables in sql functions
Date: 2002-02-22 11:13:41
Message-ID: 533d2efe.0202220313.79cb0e2d@posting.google.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message TPCCUVA 2002-02-22 11:21:00 Size of database
Previous Message tony 2002-02-22 09:05:32 Re: deleting an identical record