1

I've been trying to find some manual information on this, but my search is fruitless.

I'm trying to see if there is a way to find the unique spid (from sp_who) of a connection into a database from Powerbuilder.

As in, a user logs in, and I can see their sp_who record, but I want to be able to obtain and manipulate this id in the application itself.

(This is probably an easy one. Free rep, pb experts!)

glasnt
  • 2,865
  • 5
  • 35
  • 55

2 Answers2

2

Well, after trying to google this again this morning (and getting this question as the first result :p) I've found that there's actually a @@SPID variable that I can call.

What I've done is create a procedure

create procedure prc_get_spid
as
begin
return @@spid
end

then in my application I just go

long ll_spid
ll_spid = sqlca.prc_get_spid()

which gives me the spid for the sqlca connection.

^_^

glasnt
  • 2,865
  • 5
  • 35
  • 55
0

Another way of accessing the SPID without creating a stored procedure is access it from within a derived table as shown below.

SELECT ses.SPID
INTO :SPID
FROM (SELECT SPID = @@SPID) AS ses
USING SQLCA;
Andy B
  • 1
  • 1