显示事务状态。
%INTRANSACTION
%INTRANS
无
%INTRANSACTION
语句设置SQLCODE
以指示事务状态:
SQLCODE=0
。SQLCODE=100
。事务正在进行时,%INTRANSACTION
返回SQLCODE=0
。此事务可以是由START TRANSACTION
或SAVEPOINT
发起的SQL事务。它也可以是由TSTART
发起的ObjectScript
事务。
事务嵌套对%INTRANSACTION
没有影响。SET TRANSACTION
对%INTRANSACTION
没有影响。
还可以使用$TLEVEL
确定事务状态。%INTRANSACTION
仅指示事务是否正在进行。$TLEVEL
指示事务是否正在进行以及当前的事务级别数。
以下嵌入式SQL示例显示%INTRANSACTION
如何设置SQLCODE
:
ClassMethod %INTRANSACTION()
{
n SQLCODE
&sql(%INTRANSACTION)
w "Before %INTRANS SQLCODE=",SQLCODE," TL=",$TLEVEL,!
&sql(SET TRANSACTION %COMMITMODE EXPLICIT)
n SQLCODE
&sql(%INTRANSACTION)
w "SetTran %INTRANS SQLCODE=",SQLCODE," TL=",$TLEVEL,!
&sql(START TRANSACTION)
n SQLCODE
&sql(%INTRANSACTION)
w "StartTran %INTRANS SQLCODE=",SQLCODE," TL=",$TLEVEL,!
&sql(SAVEPOINT a)
n SQLCODE
&sql(%INTRANSACTION)
w "Savepoint %INTRANS SQLCODE=",SQLCODE," TL=",$TLEVEL,!
&sql(ROLLBACK TO SAVEPOINT a)
n SQLCODE
&sql(%INTRANSACTION)
w "Rollback to Savepoint %INTRANS SQLCODE=",SQLCODE," TL=",$TLEVEL,!
&sql(COMMIT)
n SQLCODE
&sql(%INTRANSACTION)
w "After Commit %INTRANS SQLCODE=",SQLCODE," TL=",$TLEVEL
}
本文系转载,前往查看
如有侵权,请联系 cloudcommunity@tencent.com 删除。
本文系转载,前往查看
如有侵权,请联系 cloudcommunity@tencent.com 删除。