12.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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Getting Startedentering anything (press return twice), at which point all the lines are compiled and theresulting code is listed on the screen. It will look something like this:STATS:GENCODEGenerated code :-;^T<strong>SQL</strong> LOCALVARS=tsqlgen0002;^T<strong>SQL</strong> SIMPLEQUERY=0;^T<strong>SQL</strong> QUERYLOGGING=New %tsqlspcontext,%tsqltableid,%ROWCOUNT,%tsqlScopeIdentitySet %tsqlspcontext=##class(%T<strong>SQL</strong>.SPContext).%New("SPCLASSzSPMETHOD")If $Data(%sqlcontext) {Set %sqlcontext.<strong>SQL</strong>Code=0,%sqlcontext.Message=""}Set (tsqlgen0002)="";;Set tsqlgen0002=$$ESu^%apiT<strong>SQL</strong>2(.<strong>SQL</strong>CODE,.%msg," CREATE TABLE Sample.MyTest (f1 %Library.Integer(MAXVAL=2147483647,MINVAL=-2147483648), f2 %Library.String(MAXLEN=20), ""date"" %Library.TimeStamp DEFAULTOBJECTSCRIPT '##class(%T<strong>SQL</strong>.SysFunc).GETDATE()') ","",0)#execute Do CheckPrepare^%apiT<strong>SQL</strong>2(" CREATE TABLESample.MyTest (f1 %Library.Integer(MAXVAL=2147483647,MINVAL=-2147483648), f2 %Library.String(MAXLEN=20),""date"" %Library.TimeStamp DEFAULT OBJECTSCRIPT'##class(%T<strong>SQL</strong>.SysFunc).GETDATE()')","")%tsqlexit#execute Do SPFinal^%apiT<strong>SQL</strong>()#execute Do SPWriteQuit^%apiT<strong>SQL</strong>(0)6.1.3 Using the GENRAW SettingThe output returned by the above table compile is difficult to follow; you can use theGENRAW/GR setting to trim much of this compilation scaffolding. At the terminal prompt,enter:SAMPLES:T<strong>SQL</strong>>=GR=1Then enter the CREATE TABLE lines again. The compile generates a much shorter output:STATS:GENCODEGenerated code :-Set tsqlgen0002=$$ESu^%apiT<strong>SQL</strong>2(.<strong>SQL</strong>CODE,.%msg," CREATE TABLE Sample.MyTest (f1 %Library.Integer(MAXVAL=2147483647,MINVAL=-2147483648), f2 %Library.String(MAXLEN=20), ""date"" %Library.TimeStamp DEFAULTOBJECTSCRIPT '##class(%T<strong>SQL</strong>.SysFunc).GETDATE()') ","",0)#execute Do CheckPrepare^%apiT<strong>SQL</strong>2(" CREATE TABLESample.MyTest (f1 %Library.Integer(MAXVAL=2147483647,MINVAL=-2147483648), f2 %Library.String(MAXLEN=20),""date"" %Library.TimeStamp DEFAULT OBJECTSCRIPT'##class(%T<strong>SQL</strong>.SysFunc).GETDATE()')","")This setting (GR=1) will persist until you change it. It only affects the shell and the batchloader, not Studio (use the SETTINGS command there). Code compiled using the GR=1setting usually cannot be run. Also, temporary tables and queries now require a stored procedurecontext and can no longer be created on-the-fly in the shell.<strong>Caché</strong> <strong>Transact</strong>-<strong>SQL</strong> (T<strong>SQL</strong>) <strong>Migration</strong> <strong>Guide</strong> 47

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

Saved successfully!

Ooh no, something went wrong!