13.07.2015 Views

Caché Transact-SQL (TSQL) Migration Guide - InterSystems ...

Caché Transact-SQL (TSQL) Migration Guide - InterSystems ...

Caché Transact-SQL (TSQL) Migration Guide - InterSystems ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

@@ Special VariablesCOS LOCK command<strong>SQL</strong> SET OPTION LOCK_TIMEOUT7.2.5 @@NESTLEVELContains an integer specifying the nesting level of the current process. The maximum is 16.SET myquery = "PRINT @@NESTLEVEL"SET tStatement = ##class(%<strong>SQL</strong>.Statement).%New(,,"MS<strong>SQL</strong>")SET qStatus = tStatement.%Prepare(myquery)IF qStatus'=1 { WRITE "%Prepare failed",$System.Status.DisplayError(qStatus) QUIT}SET rset = tStatement.%Execute()DO rset.%Display()COS $STACK7.2.6 @@ROWCOUNTContains the number of rows affected by the most recent SELECT, INSERT, UPDATE, or DELETE command. A singlerowSELECT always returns a @@ROWCOUNT value of either 0 (no row selected) or 1.When invoking an AFTER statement level trigger, the @@ROWCOUNT value upon entering the trigger is the@@ROWCOUNT immediately prior to the trigger. Rows affected within the scope of the trigger code are reflected in the@@ROWCOUNT value. Upon completion of the trigger code, @@ROWCOUNT reverts to the value immediately priorto the trigger invocation.COS %ROWCOUNT<strong>SQL</strong> :%ROWCOUNT7.2.7 @@SERVERNAMEContains the <strong>Caché</strong> instance name.SET myquery = "SELECT @@SERVERNAME AS CacheInstance"SET tStatement = ##class(%<strong>SQL</strong>.Statement).%New(,,"MS<strong>SQL</strong>")SET qStatus = tStatement.%Prepare(myquery)IF qStatus'=1 { WRITE "%Prepare failed",$System.Status.DisplayError(qStatus) QUIT}SET rset = tStatement.%Execute()DO rset.%Display()COS $PIECE($system,":",2)7.2.8 @@SPIDContains the server process ID of the current process.SET myquery = "SELECT @@SPID AS ProcessID"SET tStatement = ##class(%<strong>SQL</strong>.Statement).%New(,,"MS<strong>SQL</strong>")SET qStatus = tStatement.%Prepare(myquery)IF qStatus'=1 { WRITE "%Prepare failed",$System.Status.DisplayError(qStatus) QUIT}SET rset = tStatement.%Execute()DO rset.%Display()COS $JOB<strong>SQL</strong> $T<strong>SQL</strong>_SPID()<strong>Caché</strong> <strong>Transact</strong>-<strong>SQL</strong> (T<strong>SQL</strong>) <strong>Migration</strong> <strong>Guide</strong> 55

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!