Re: Any form of connection-level "session variable" ?

Поиск
Список
Период
Сортировка
От David Fetter
Тема Re: Any form of connection-level "session variable" ?
Дата
Msg-id 20070105152700.GH1562@fetter.org
обсуждение исходный текст
Ответ на Re: Any form of connection-level "session variable" ?  (Scott Ribe <scott_ribe@killerbytes.com>)
Ответы Re: Any form of connection-level "session variable" ?  (Scott Ribe <scott_ribe@killerbytes.com>)
Список pgsql-general
On Thu, Jan 04, 2007 at 06:53:09PM -0700, Scott Ribe wrote:
> What about:
>
>  create function set_emp_id() returns void as $$
>  begin
>     drop table if exists emp_1_id;
>     select emp_id into temp emp_1_id from secureview.tbl_employee where
> username = current_user;
>  end;
>  $$ language plpgsql;
>
>  create function get_emp_id() returns int as $$
>     return select emp_id from emp_1_id;
>  $$ language plpgsql stable;
>
> Call set_emp_id once on connection, then use get_emp_id thereafter.
> Would that be any faster? (This is what Erik meant by "a temp table
> is pretty much a session variable" in his earlier message.)

You can use PL/Perl's %_SHARED hash
<http://www.postgresql.org/docs/current/static/plperl-global.html> to
store session-long variables, and you don't need to worry about
cleanup :)  Similar things exist in PL/Python and possibly others.

Cheers,
D
--
David Fetter <david@fetter.org> http://fetter.org/
phone: +1 415 235 3778        AIM: dfetter666
                              Skype: davidfetter

Remember to vote!

В списке pgsql-general по дате отправления:

Предыдущее
От: David Fetter
Дата:
Сообщение: Re: [JDBC] PgSQL Monitoring( Please let me know the table details )
Следующее
От: Scott Ribe
Дата:
Сообщение: Re: Any form of connection-level "session variable" ?