Using select with Variables, Global Variables, and Constants

Issuing select statements that reference only @variables, @@global variables, and constants in chained mode do not start new transactions.

This enables you to create SQL constructs similar to:
set chained ON
<... Perform some DML or other commands ...>
select @@error, @@trancount, @@transtate

In some circumstances, SAP ASE may rollback the active transaction if an error occurs while executing DML or other statements. Use the select statement to check the state of the transaction while the server is in chained mode, and—without automatically starting a new transaction—collect the date and time the error occurred that triggered the rollback.

Although most functions start new transactions when used in select statements, these diagnostic functions do not:
  • getdate
  • getutcdate
  • current_date
  • current_time
  • current_bigdatetime
  • current_bigtime
  • abs
  • asehostname
  • hostname
  • switchprop