SessionID, pretty please

Started by Tom Dalmost 20 years ago4 messagesgeneral
Jump to latest
#1Tom D
tom.darci@gmail.com

Hello All-

I am in the process of replacing the backend for a large MS Access
project with PG.

I really could use a Session ID. I would like to create a view like
this:

CREATE VIEW mysettings
AS
SELECT * FROM mysettingstable
WHERE sessionidcolumn = CURRENTSESSIONID()

It is essential that we be able to reference a session id without
passing it in, as this has to work within the "linked table" paradigm
of Access and a lot of Access forms that have already been developed.

The TEMPORARY TABLE feature of PG seemed ideal for these purposes.
However, after burning many many days on 2 different attempts at
solving this using temp tables (first attempt used temp tables, second
attempt tried to use the name of the current temp schema as a unique
session id), I'm at my wits end, as I can't get this to work reliably
with Access and its linked tables...

I see that the log_line_prefix can be set to a Session ID (using
'%c'). Is there any way to get the current value of this from a
function in PG? (current_setting() simply returns the configuration
string, not its actual value.)

My troubles would be solved if I could reference a SessionID from
within PG. Any hope?

THANKS,
-Tom

#2Tom D
tom.darci@gmail.com
In reply to: Tom D (#1)
Re: SessionID, pretty please

OK... so I see now that Access seems to be having a field day with
opening and closing sessions, in a way that seems out of my control.

This explains why my temporary table solutions (and then my plperl
global variable solution) were not working.

I will have to go with plan B.

I'd still be curious as to getting a sessionID, though.

-Tom

#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: Tom D (#1)
Re: SessionID, pretty please

tom.darci@gmail.com writes:

My troubles would be solved if I could reference a SessionID from
within PG. Any hope?

Create a sequence. At session start, nextval() it to assign a session
ID for your session. Then currval() returns your session ID whenever
you need it.

regards, tom lane

#4Tom D
tom.darci@gmail.com
In reply to: Tom Lane (#3)
Re: SessionID, pretty please

thanks.

Tom Lane wrote:

Show quoted text

tom.darci@gmail.com writes:

My troubles would be solved if I could reference a SessionID from
within PG. Any hope?

Create a sequence. At session start, nextval() it to assign a session
ID for your session. Then currval() returns your session ID whenever
you need it.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly