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

Create successful ePaper yourself

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

Commonly Used ConstructsFor example:SELECT A,B FROM CSELECT X,Y FROM Zwill have columns A, B, X, Y.While the first query is active, X and Y will be returned as NULL. Once the second querybecomes active, A and B will be returned as NULL.Care is needed with columns that appear in more than one SELECT. Accessing them bynumber (GetData) is fine, but accessing them by name (Data) will always fetch the valuebound to the version of the column which appears latest in the list, which will be NULL exceptwhen its own query is active.You can get around duplicate columns using aliases. For example, instead of this:SELECT Category,Description FROM Cinema.FilmSELECT Category,Description FROM Cinema.Filmuse this:SELECT Category,Description FROM Cinema.FilmSELECT Category AS C2,Description AS D2 FROM Cinema.Film2.2.8 EXEC StatementThe EXEC (EXECUTE) statement can be used to invoke a stored procedure which is aquery. You can pass parameters as normal when calling a query stored procedure, but youcannot assign the result of a call to a query stored procedure to a variable.If the caller is itself a query the called query is incorporated into the calling query, both atcompile time and at execution time:• The called query's metadata is incorporated into the calling query.• The called query returns rows one at a time and the calling query returns those rows oneat a time to its own caller.For example, if the caller looks like this:SELECT Description FROM Cinema.FilmEXEC CalledQuery()SELECT Title FROM Cinema.Filmand the called query looks like this:SELECT Name,Age FROM Person<strong>Caché</strong> <strong>Transact</strong>-<strong>SQL</strong> (T<strong>SQL</strong>) <strong>Migration</strong> <strong>Guide</strong> 9

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

Saved successfully!

Ooh no, something went wrong!