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

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

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

<strong>Caché</strong> T<strong>SQL</strong> Language ElementsThe following <strong>Caché</strong> ObjectScript example changes the empty string definition for the SAMPLES namespace. It first setsthe empty string value to a single blank space. It then sets the empty string value to the non-printing character representedby the ASCII code 0. (This example then immediately resets the empty string value to the <strong>Caché</strong> default):SET ^%SYS("sql","sys","namespace","SAMPLES","empty string")=" "WRITE !,"Empty string set to:"ZZDUMP ^%SYS("sql","sys","namespace","SAMPLES","empty string")SET ^%SYS("sql","sys","namespace","SAMPLES","empty string")=$CHAR(0)WRITE !,"Empty string set to:"ZZDUMP ^%SYS("sql","sys","namespace","SAMPLES","empty string")SET ^%SYS("sql","sys","namespace","SAMPLES","empty string")=""WRITE !,"Empty string reset to:"ZZDUMP ^%SYS("sql","sys","namespace","SAMPLES","empty string")WRITE !,!,"End of sample program"3.1.3 NULLIn T<strong>SQL</strong> a NULL supplied to a boolean operation returns as FALSE, as shown in the following example:DECLARE @var BINARY(1)SELECT @var=NULLIF @var PRINT "true" ELSE PRINT "false"In Sybase dialect, NULL is equal to NULL. A NULL=NULL comparison returns TRUE, and a NULL != NULL comparisonreturns FALSE.In MS<strong>SQL</strong> dialect, a comparison of NULL with any value returns FALSE. Thus NULL=NULL and NULL != NULLcomparisons both return FALSE.DECLARE @var BINARY(1)SELECT @var=NULLIF @var=NULL PRINT "true" ELSE PRINT "false"In Sybase dialect, NULL is not equal to any value. Therefore, Not Equals (!=) comparison involving NULL and any boolean,numeric, or string value (including the empty string ("")) returns TRUE. All Equals (=), Greater Than (>) or Less Than () or LessThan (

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

Saved successfully!

Ooh no, something went wrong!