Use of variables within a select statement in a function

From: "Ivan Janssen" <ijanssen(at)ruralnet(dot)net(dot)au>
To: <pgsql-general(at)postgresql(dot)org>
Subject: Use of variables within a select statement in a function
Date: 2000-11-15 05:43:56
Message-ID: NDBBKGGHEKJELEDPOBGHMEMACFAA.ijanssen@ruralnet.net.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I am wondering if you can declare a variable within a function using plpgsql
which can be calculated within that function to be a table which you can
then use in either a select or update statement.

I am wanting to be able to calculate a variable (ie logfilename) as the
table I want to then use in a select of update statement.

CREATE FUNCTION sp_invoicecredit()
RETURNS int4 as '
DECLARE logfilename text;
countrec int4;
BEGIN
logfilename:= ''log1000'';
select into countrec count(*) from logfilename;

RETURN countrec;
END;
' LANGUAGE 'plpgsql'

The following I know does not work, but I am wondering it is possible to do
this.

Regards, Ivan

Browse pgsql-general by date

  From Date Subject
Next Message Ashley Clark 2000-11-15 05:49:00 Re: Can this be done?
Previous Message Tom Lane 2000-11-15 05:42:27 Re: Can this be done?