Use of variables within a select statement in a function - Mailing list pgsql-general

From Ivan Janssen
Subject Use of variables within a select statement in a function
Date
Msg-id NDBBKGGHEKJELEDPOBGHMEMACFAA.ijanssen@ruralnet.net.au
Whole thread Raw
List 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


pgsql-general by date:

Previous
From: Kevin English
Date:
Subject: Transaction Abort during insert using libpq
Next
From: Florian Steffen
Date:
Subject: Error during creation of indexes