Re: are there static variables in pgsql?

Поиск
Список
Период
Сортировка
Искать
От
Kenneth Downs
Тема
Re: are there static variables in pgsql?
Дата
Msg-id
448D836F.3040004@secdat.com
Ответ на
Re: are there static variables in pgsql? (ptjm@interlog.com (Patrick TJ McPhee))
Список
Дерево обсуждения
are there static variables in pgsql? "Yavuz Kavus" <yavuzkavus@gmail.com>
Re: are there static variables in pgsql? Terry Lee Tucker <terry@esc1.com>
Re: are there static variables in pgsql? "Jim C. Nasby" <jnasby@pervasive.com>
Patrick TJ McPhee wrote:

>I'm not sure a static variable is the right way to achieve this, but
>you could use a custom_variable_class for this. Add this to your
>postgresql.conf:
> custom_variable_classes='global'
>
>Then you can set and show variables prefixed by global.:
> set global.success = 'true';
>
>  
>
This is very intriguing, but I'd like to make sure it is doing what I 
think it is doing.  Is it tracking variables in a connection across SQL 
commands?  If so, shouldn't this work (Assume the existence of table 
"detail" with a column called "val2").

create or replace function SetVal2() returns void as
$$
begin
    update detail set val2=global.val2;
end;
$$
language plpgsql

set global.val2=5;
select SetVal2();

I'm getting the following error which I don't understand.  Seems I don't 
know how to access the variable once it is set.

ERROR:  missing FROM-clause entry for table "global"
CONTEXT:  SQL statement "update detail set val2=global.val2"
PL/pgSQL function "setval2" line 2 at SQL statement

В списке pgsql-general по дате отправления
От: Alejandro Michelin Salomon \( Adinet \)
Дата:
От: Lincoln Yeoh
Дата:
Сообщение: Re: Disk corruption detection
FAQ