how to kow if in transaction? and lock mode ?
Posted in 2003
Topics: Stored Procedures & SPL
in a SPL stored procedure a must know if a transaction is started for the session and what is the actual lock mode (wait,no wait...) does anybody know how to do ?..., infos in system tables..? thanks ...
----- Original Message -----
From: "Coquel Nath...." <Nathanael.Coquel@services.fujitsu.com>
To: <ids@iiug.org>
Sent: July 04, 2003 04:25
Subject: how to kow if in transaction? and lock mode ? [1495]
>
>
> in a SPL stored procedure a must know if a transaction is started for the
> session and
> what is the actual lock mode (wait,no wait...)
>
> does anybody know how to do ?..., infos in system tables..?
I don't think it is possible to know inside a stored procedure
whether a transaction is started or what is the lock mode. Forget
about stored procedure, I don't think it is possible in 'C' program
also to know.
However u can find it in a different way.
create procedure is_tran() returning smallint
-- will return 0 if transaction has not started.
-- will return 1 if the database does not support transaction
-- will return 2 if transaction has already starteddefine esql,isam integer;
BEGIN
on exception set esql,isam
end exception with resume
BEGIN work ;
END
if (esql = -256) then
return 1
end if ;
if (esql = -535) then
return 2
end if ;
-- it means that transaction has not started.
COMMIT WORK ; -- needed to close the BEGIN WORK;
return 0 ;
end procedure ;
I just wrote the program without checking it. Just run it and
check for syntax.
However this method is a very expensive way of knowing whether a
transaction has already started or not. Use it with caution.
ravi