Use of variables within a select statement in a function

Поиск
Список
Период
Сортировка
От Ivan Janssen
Тема Use of variables within a select statement in a function
Дата
Msg-id NDBBKGGHEKJELEDPOBGHMEMACFAA.ijanssen@ruralnet.net.au
обсуждение исходный текст
Список 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 по дате отправления:

Предыдущее
От: Kevin English
Дата:
Сообщение: Transaction Abort during insert using libpq
Следующее
От: Florian Steffen
Дата:
Сообщение: Error during creation of indexes