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

From: Joe Conway <mail(at)joeconway(dot)com>
To: Scott Ribe <scott_ribe(at)killerbytes(dot)com>
Cc: John McCawley <nospam(at)hardgeus(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Any form of connection-level "session variable" ?
Date: 2007-01-05 02:22:29
Message-ID: 459DB665.2030009@joeconway.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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.)

Or, in similar fashion, use this:
http://www.joeconway.com/sessfunc.tar.gz
http://www.onlamp.com/pub/a/onlamp/2004/06/28/postgresql_extensions.html

HTH,

Joe

In response to

Browse pgsql-general by date

  From Date Subject
Next Message sbaskar 2007-01-05 04:25:05 PgSQL Monitoring( Please let me know the table details )
Previous Message Scott Ribe 2007-01-05 01:53:09 Re: Any form of connection-level "session variable" ?