Re: obtaining session id
Posted in 1998
Nicole Guffey wrote:
>
> Does anyone know of a way for a stored procedure to obtain it's own session
> id
> (sysmaster.syssessions.sid)? In other words, is there some way for a stored
>
> procedure to be able to look at sysmaster.syssessions and know which row
> describes itself? All connections to the database through our app use the
> same
> user name, so 'username' or 'uid' will not work.
>
> Basically, we write an application that needs to:
> 1. Connect to the database.
> 2. Record the session id for that connection.
> 3. Validate through a later connection wether or not the earlier
> connection is still active.
>
> MS SQL Server and Oracle both provide means by which a connection can obtain
> it's
> own session id, a global system variable and a system view respectively. I
> have
> called Informix tech support and at first look they do not know how this
> could be done.
>
Nicole,
There is a way to do this in Informix. To achieve your objective you
may need an additional table to register live process (instances of
your executable), something like a process-control table where you can
store the process-id (executable identifier) and session id ( from
informix ), any other session trying to run the same process will be
able to see whether the other session is still active or not.
You can get the current session-id and Unix-PID by :
select sid,pid from sysmaster:syssessions
where sid = dbinfo('sessionid')
Basically this is all what you need for building your status-check
logic. I find it surprising to see Informix customer support people
not explaining you about this dbinfo(), function. Otherwise you may be
using an old version of the product which do not support dbinfo()
function.
--
Have a nice day
Felix K. Mathews
mailto:fmathews@systems.dhl.com