Global Variables

SAP ASE version 16.0 add global variables.

Global VariableDescription
@@trigger_name
Returns the name of the trigger currently executing.
@@tranrollback
Returns the type of rollback encountered, if any. If the return value is:
  • < 0 – a server induced implicit rollback of a multistatement transaction. @@tranrollback stores the negation of the error number that resulted in the implicit transaction rollback.
  • 0 – this session of the currently active transaction encountered no implicit rollbacks.
  • > 0 < 10 – the most-recent occurrence of a transaction rollback was a user-issued rollback from one of these SQL commands:
    • rollback tran in a SQL batch, procedure or trigger
    • rollback trigger outside a trigger’s scope.
    The return value for @@transtate describes which rollback command the user issued:
    • 1 – user issued an explicit rollback tran command
    • 2 – user issued a rollback tran to savepoint. The transaction is still active.
  • > 100 – The most recent occurrence of a transaction rollback was invoked on a single-statement transaction. @@transtate stores the error number that caused the statement to rollback.
SAP ASE does not change a negative value for @@tranrollback until the next rollback tran or commit tran is issued, indicating that the session has encountered an implicit transaction rollback. SAP ASE resets the value for @@tranrollback to 0 once it successfully applies the next rollback tran or commit tran. The value for @@tranrollback is 0 at the end of this example:
set chained on
go
<... Execute a DML statement ...> 
if (@@error != 0) and (@@tranrollback < 0) 
begin 
     rollback tran 
end 
go