Is it possible to create a session variable for each user in Postresql ??
Thx 13 13321
On Wed, 2 Jun 2004 16:00:18 +0200
"Nagib Abi Fadel" <na************ *@usj.edu.lb> wrote: Is it possible to create a session variable for each user in Postresql ??
I was just thinking that the term "session variable" is like the word "love" in
that it means something different to everyone.
That being said, I can't think of any definition of "session variable" that
Postgres isn't capable of handling. If you have a more specific meaning you
want to ask about, I suggest providing a scenerio, or otherwise more specific
question.
--
Bill Moran
Potential Technologies http://www.potentialtech.com
---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster
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 pg***@candle.ph a.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
Bruce Momjian wrote: 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.
Would I be right in assuming that's going to be burning through OIDs
though (possibly an issue for a web-app with lots of short sessions).
--
Richard Huxton
Archonet Ltd
---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend
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" <pg***@candle.p ha.pa.us>
To: "Nagib Abi Fadel" <na************ *@usj.edu.lb>
Cc: "generalpos t" <pg***********@ 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 pg***@candle.ph a.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
---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddres sHere" to ma*******@postg resql.org)
On Thu, 3 Jun 2004 09:04:43 +0200, "Nagib Abi Fadel"
<na************ *@usj.edu.lb> wrote: 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.
Sequence values are session-specific which is exactly the property
you're looking for.
CREATE TABLE session (
id SERIAL PRIMARY KEY,
x text
);
CREATE VIEW mysession (x) AS
SELECT x FROM session WHERE id=currval('ses sion_id_seq');
CREATE VIEW t_view AS
SELECT *
FROM SomeTable st INNER JOIN mysession s
ON st.id = s.x;
At the start of a session you just
INSERT INTO session (x) VALUES ('whatever');
From time to time you have to clean up the session table (delete old
entries, VACUUM ANALYSE).
If the value of your session variable X has no special meaning apart
from being unique, you don't need the session table, you just create a
sequence and use nextval/currval directly.
Or you might want to use pg_backend_pid( ). It is documented here: http://www.postgresql.org/docs/7.4/s...ing-stats.html.
Servus
Manfred
---------------------------(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
Manfred Koizar wrote: On Thu, 3 Jun 2004 09:04:43 +0200, "Nagib Abi Fadel" <na************ *@usj.edu.lb> wrote:
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.
Sequence values are session-specific which is exactly the property you're looking for.
CREATE TABLE session ( id SERIAL PRIMARY KEY, x text );
CREATE VIEW mysession (x) AS SELECT x FROM session WHERE id=currval('ses sion_id_seq');
CREATE VIEW t_view AS SELECT * FROM SomeTable st INNER JOIN mysession s ON st.id = s.x;
At the start of a session you just
INSERT INTO session (x) VALUES ('whatever');
Couldn't one also do (this is untested - may include syntax errors):
-- Create a wrapper function for View usage
CREATE FUNCTION getValue() RETURNS text AS '
DECLARE
result text;
BEGIN
SELECT INTO result session_value
FROM session_data;
RETURN result;
END;
LANGUAGE 'plpgsql';
-- Create our View using our function
CREATE VIEW t_view AS
SELECT *
FROM foo
WHERE foo.key = getValue();
-- Now, upon connecting, the app does:
CREATE TEMPORARY TABLE session_data (value text);
INSERT INTO session_data VALUES ('Hello');
In this way, the table needn't exist until the first invocation of
getValue() upon the first access of the view, since the code will be
recompiled during the first access, correct?
Mike Mascari
---------------------------(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
> Would I be right in assuming that's going to be burning through OIDs though (possibly an issue for a web-app with lots of short sessions).
:climbing on soapbox:
If pg had a 64-bit system record ID like Oracle does, that'd
take care of this issue, at least until you managed to write
18 quintilliion (1.8e19) rows. At a million rows a second, that'll
take you about 584,000 years.
Yeah, it costs some disk space, but disk space is cheap compared
to having to confront the OID rollover issue over and over again,
and not just because of bad database design.
:climbing off soapbox:
--
Mike Nolan
---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddres sHere" to ma*******@postg resql.org)
Thx guys Both Solutions works fine for me but which one is better (uses less
resources ?) ?
(Mike i tested your solution)
The use of sequence would require to clean up the table every N hour .
The use of temporary table wouldn't require any cleanup. Plus it won't use
any disk space (i suppose a temporary table wouldn't be written to disk
right ?).
Thx guys for your help.
----- Original Message -----
From: "Mike Mascari" <ma*****@mascar i.com>
To: "Manfred Koizar" <mk*****@aon.at >
Cc: "Nagib Abi Fadel" <na************ *@usj.edu.lb>; "Bruce Momjian"
<pg***@candle.p ha.pa.us>; "generalpos t" <pg***********@ postgresql.org>
Sent: Thursday, June 03, 2004 04:55 PM
Subject: Re: [GENERAL] Creating a session variable in Postgres Manfred Koizar wrote: On Thu, 3 Jun 2004 09:04:43 +0200, "Nagib Abi Fadel" <na************ *@usj.edu.lb> wrote:
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
thevariable X and it will be inserted into the temporary table t_temp.
Sequence values are session-specific which is exactly the property you're looking for.
CREATE TABLE session ( id SERIAL PRIMARY KEY, x text );
CREATE VIEW mysession (x) AS SELECT x FROM session WHERE id=currval('ses sion_id_seq');
CREATE VIEW t_view AS SELECT * FROM SomeTable st INNER JOIN mysession s ON st.id = s.x;
At the start of a session you just
INSERT INTO session (x) VALUES ('whatever');
Couldn't one also do (this is untested - may include syntax errors):
-- Create a wrapper function for View usage
CREATE FUNCTION getValue() RETURNS text AS '
DECLARE
result text;
BEGIN
SELECT INTO result session_value FROM session_data;
RETURN result;
END;
LANGUAGE 'plpgsql';
-- Create our View using our function
CREATE VIEW t_view AS SELECT * FROM foo WHERE foo.key = getValue();
-- Now, upon connecting, the app does:
CREATE TEMPORARY TABLE session_data (value text); INSERT INTO session_data VALUES ('Hello');
In this way, the table needn't exist until the first invocation of getValue() upon the first access of the view, since the code will be recompiled during the first access, correct?
Mike Mascari
---------------------------(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
---------------------------(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
On Fri, 4 Jun 2004 08:25:38 +0200, "Nagib Abi Fadel"
<na************ *@usj.edu.lb> wrote: The use of sequence would require to clean up the table every N hour .
Right.
The use of temporary table wouldn't require any cleanup.
Wrong. You would have to clean up the meta data, at least pg_class and
pg_attribute, maybe pg_index also. For the price of one temp table you
can have several rows in a permanent table.
Servus
Manfred
---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives? http://archives.postgresql.org This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: RooLoo |
last post by:
Hey all
In my GLOBAL.ASA file I'm trying to create a session variable for reference
in the various webpages of my site....
Sub Session_OnStart
Session("LoggedOn")="Y"
End Sub
When referring to Session("LoggedOn") on my various ASP pages, it is coming
|
by: doltharz |
last post by:
Please Help me
i'm doing something i though was to be REALLY EASY but it drives me
crazy
The complete code is at the end of the email
(i mean newsgroup article),
i always use Option Explicit
and Response.Expires=-1,
|
by: Nick Jushchyshyn |
last post by:
Having a really strange issue with IIS 6 where the session variable does not
stay consistant. The first symptom was that database connections (which use a
user entered name/PW stored in the Session) in ASP pages were failing.
Finally got to (what I think is) the root issue by creating two ASP pages,
one that sets Session("test") = "Hello", and the other simply displays "Test
word: .." and the content of Session("test"). After visiting the...
|
by: KathyB |
last post by:
Hi, sorry to be greedy with all my posts lately, but can you tell I'm
doing new things this week?
I've just done my first datalist (a simple one), that give me one
column of records. I would like to put the total count of the rows
into the control's footer. I couldn't find any references for doing
this and ended up trying several things, one of which was assigning a
variable within the sub creating the datalist control, and when that...
|
by: Vidyadhar Joshi |
last post by:
I have the following scenario in a true load balanced environment (without
sticky sessions):
There are 2 ASPX pages. I want to pass an object from the first page to the
second page. On the btnContinue_Click event of Page1.aspx, I create the
object and store it in a session variable. The next statement would be
Response.Redirect("Page2.aspx"). The code appears like this:
private void btnContinue_Click(object sender, EventArgs e)
{...
| |
by: sconeek |
last post by:
hi all,
i am working on a java and HTML based web application. now i am storing
session variables. is there a way for me to pass on these variables to
javascript. what i am getting at is, i need JS to do something based on
the user variable.
can somebody help me out on this one.
thanks.
|
by: MrBiggles |
last post by:
Here's the sitch:
I read in a csv file with 60000 lines (20 fields per record), and store
the data to a local array. The file is read in and stored just fine and
pretty quick.
Now, if I try to assign that array to a session variable it chokes.
e.g. create array and load each element with a row from the file (btw,
each row is an array as well, using fgetcsv()). When local array is
loaded, I assign to session var as so:
$_SESSION =...
|
by: RSH |
last post by:
Hi,
I have a situation where I have created an object that contains
fields,properties and functions. After creating the object I attempted to
assign it to a session variable so i could retrieve the information it
contained on another page. This was significant because I am initially
loading the data from the database, then storing relevent information in the
object, I am allowing users to change the data then preview the
modifications...
|
by: ADN |
last post by:
Hi, I am creating a custom HTTPModule to intercept the request of when
the user is attempting to retrieve a session variable. For instance,
if I set a session variable in my code like so:
session = "Hello World";
When the request for that session variable "myString" is attempted to
be retrieved, I would like to intercept that request like so:
if (Request is for session variable "myString")
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |