Re: Creating a session variable in Postgres

From: "Nagib Abi Fadel" <nagib(dot)abi-fadel(at)usj(dot)edu(dot)lb>
To: "Bruce Momjian" <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: "generalpost" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Creating a session variable in Postgres
Date: 2004-06-03 07:04:43
Message-ID: 001401c44939$0f0c3bc0$8a64a8c0@nagib
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)candle(dot)pha(dot)pa(dot)us>
To: "Nagib Abi Fadel" <nagib(dot)abi-fadel(at)usj(dot)edu(dot)lb>
Cc: "generalpost" <pgsql-general(at)postgresql(dot)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(at)candle(dot)pha(dot)pa(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Lee Fesperman 2004-06-03 08:06:55 Re: JDBC: what exactly does nullsAreSortedHigh() return?
Previous Message Roshani Shah 2004-06-03 06:43:46 Request