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
  • No tags were found...

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

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

Executing Procedures and MethodsTo examine the table definition, you can use the Management Portal. Select [System] > [Classes], select the correctNamespace, then scroll to the table definition and select the Documentation link.8.2.2 Accessing Table DataTo access data in an existing table, specify commands such as the following:SAMPLES>DO ##class(%T<strong>SQL</strong>.Manager).interactive(,,2)SAMPLES 1>>SELECT Name,DOB FROM Sample.PersonSAMPLES 2>>GOSELECT Name,DOB FROM Sample.PersonSAMPLES 1>>The result set is listed in the T<strong>SQL</strong> Shell log file. The class method's runmode=2 argument causes the DOB (date of birth)values to be returned in Display format rather than the default Logical (internal storage) format.You can display an individual data value to the T<strong>SQL</strong> Shell terminal using local variables, as shown in the followingexample:SAMPLES>DO ##class(%T<strong>SQL</strong>.Manager).interactive(,,,"/nodisplaylog")SAMPLES 1>>DECLARE @a VARCHARSAMPLES 2>>SET @a = (SELECT Name FROM Sample.Person)SAMPLES 3>>PRINT ''SAMPLES 4>>PRINT @aSAMPLES 5>>GOOr simply:SAMPLES>DO ##class(%T<strong>SQL</strong>.Manager).interactive(,,,"/nodisplaylog")SAMPLES 1>>PRINT ''SAMPLES 2>>PRINT (SELECT Name FROM Sample.Person)SAMPLES 3>>GONote that the desired table must be located in the current namespace.8.3 Executing Procedures and MethodsYou can execute a Stored Procedure from the T<strong>SQL</strong> Shell using the EXECUTE command:USER 1>>EXECUTE myproc 10,10,3USER 2>>GOIn this case, three numeric arguments are passed to myproc.The following example dumps (extracts) two result sets from the Sample.Person table.SAMPLES 1>>EXECUTE Sample.PersonT<strong>SQL</strong>Sets 'A%','NY'SAMPLES 2>>GOThe first result set consists of records where Name field values begin with 'A'. The second result set consists of recordswhere 'NY' appears in the Home_State field.<strong>Caché</strong> <strong>Transact</strong>-<strong>SQL</strong> (T<strong>SQL</strong>) <strong>Migration</strong> <strong>Guide</strong> 57

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

Saved successfully!

Ooh no, something went wrong!