Re: Creating a session variable in Postgres - Mailing list pgsql-general

From Nagib Abi Fadel
Subject Re: Creating a session variable in Postgres
Date
Msg-id 001401c44939$0f0c3bc0$8a64a8c0@nagib
Whole thread Raw
In response to Re: Creating a session variable in Postgres  (Bruce Momjian <pgman@candle.pha.pa.us>)
Responses Re: Creating a session variable in Postgres
List pgsql-general
Well i thought about that but i don't feel like it is a clean way.

Actually i need to create a dynamic view depending on the user choice of a
certain variable via a web application.

Let's say for example the variable is called "X". The view is called
"t_view" and the temporary table is called "t_temp".
Each time a user connects to the web, the application will initialize the
variable X and it will be inserted into the temporary table t_temp.

i defined the following view: CREATE VIEW t_view as select * from SomeTable
where id = (select X from t_temp);
This didn't work first cause the temporary table does not exist.
So i created the temporary table then created the view "t_view" and then the
view was created (i kind of fooled the system).

Now every time a user access the web application he will choose a value for
X and the t_temp will be created and X inserted in it.

I solved my problem but it does not seem like a "clean way".

Any ideas ??



I have now a DYNAMIC view
----- Original Message -----
From: "Bruce Momjian" <pgman@candle.pha.pa.us>
To: "Nagib Abi Fadel" <nagib.abi-fadel@usj.edu.lb>
Cc: "generalpost" <pgsql-general@postgresql.org>
Sent: Wednesday, June 02, 2004 04:53 PM
Subject: Re: [GENERAL] Creating a session variable in Postgres


> Nagib Abi Fadel wrote:
> > Is it possible to create a session variable for each user in Postresql
??
>
> No.  The best you can do is create a temp table and put a value in
> there.
>
> --
>   Bruce Momjian                        |  http://candle.pha.pa.us
>   pgman@candle.pha.pa.us               |  (610) 359-1001
>   +  If your life is a hard drive,     |  13 Roberts Road
>   +  Christ can be your backup.        |  Newtown Square, Pennsylvania
19073
>
> ---------------------------(end of broadcast)---------------------------
> TIP 9: the planner will ignore your desire to choose an index scan if your
>       joining column's datatypes do not match


pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: statement-level statistics are disabled error (postgresql.conf)
Next
From: Greg Stark
Date:
Subject: Re: Page access pattern in query plan using index scan