Re: obtaining session id
Posted in 1998
Nicole,
If you are using Informix version 7.3 then you can use the dbinfo
function, as in:
dbinfo('sessionid')
Otherwise, if the client is running on the server machine, e.g. a
typical Informix-4gl application, then you can use:
select sid from sysmaster:syssessions where pid = xpid
You will have to find out your unix process id (xpid) beforehand, either
through a c function or environment variable, and send it to your stored
procedure.
As a side note, you may want to consider letting your users connect with
their own user name and using Informix roles to enforce security. While
the users themselves have no direct access to data, the application can
gain full access with the SET ROLE statement. The name of the role can
be secret, like a password. This makes for easier adminstration, like
knowing who's connected.
Hope this helps,
----------------------------------------------------------------------
John H. Frantz Power-4gl: Extending Informix-4gl
john@rl.is http://www.rl.is/~john/pow4gl.html
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.
>
> Thank you,
> Nicole Guffey
> DBA
> J. Driscoll & Associates
> nguffey@jdriscoll.com