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.

OverviewAlternatively, you can invoke $SYSTEM.<strong>SQL</strong>.T<strong>SQL</strong>(), $SYSTEM.<strong>SQL</strong>.Sybase() or$SYSTEM.<strong>SQL</strong>.MS<strong>SQL</strong>Server() method to import the schema. For further details, see the <strong>InterSystems</strong> Class Reference.If the T<strong>SQL</strong> source contains CREATE PROC statements, then a class method containing the CREATE PROC sourceis created. <strong>Caché</strong> places this class method in either an existing class or in a new class whose name is based on theschema and procedure name. If the procedure already exists, then the existing version is replaced by the new version.If a class matching the class name generated from the schema and procedure already exists, then this class name isused — if it was previously generated by the T<strong>SQL</strong> utility. If not, then a unique class name is generated, based on theschema and procedure name. The resulting class is compiled once the procedure has been successfully created. If loggingis requested then the source statements are logged along with the name of the containing class, class method, and theformal arguments generated. Any errors encountered by the process are also reported in the log. If an error is detectedduring CREATE PROC processing, <strong>Caché</strong> deletes any new class that was generated for that procedure.2. Migrate DML and Stored Procedures: These are generally in *.sql files and can be loaded using the following command:DO ##class(%T<strong>SQL</strong>.Manager).Import(...)Set this method's pDialect parameter to either MS<strong>SQL</strong> or Sybase. For further details, see the <strong>InterSystems</strong> Class Reference.The %T<strong>SQL</strong>.Manager.Import method imports (loads) T<strong>SQL</strong> source code of all types: DDL, DML, and stored procedures.This is the method to use when DDL and DML are found in the same file. However, when possible, it is preferable toimport table and view definition files separately using %SYSTEM.<strong>SQL</strong>.DDLImport, as described above.3. Inspect the log file for errors: Search by Error #. A summary count of errors and successful imports will appear at theend of the log. In most cases, errors can be worked around or addressed by using information found in this document.4. Compile: When you import DDL, table and view definition compilation is automatically performed. To compile otherT<strong>SQL</strong> source code, it is best to use the command as follows:DO $SYSTEM.OBJ.CompileAll("-l")The lowercase “L” qualifier flag specifies that locking is not applied for the duration of the compile. For a full list offlag qualifiers, call DO $SYSTEM.OBJ.ShowFlags().1.1.3 Migrating the DataIn the Management Portal select [System] > [<strong>SQL</strong>], then select the Data <strong>Migration</strong> Wizard.1.2 T<strong>SQL</strong> Language ImplementationT<strong>SQL</strong> procedures are converted to <strong>Caché</strong> methods or queries with a Language type equal to T<strong>SQL</strong>. Use the followingcommand:DO ##class(%T<strong>SQL</strong>.Manager).load("sybase",,)When compiling T<strong>SQL</strong> methods, <strong>Caché</strong> ObjectScript code is generated. There is no system-level support for native T<strong>SQL</strong>.It is best to maintain the methods in T<strong>SQL</strong> to retain the familiar look of the original stored procedures.• Using T<strong>SQL</strong> in StudioYou can write and maintain T<strong>SQL</strong> stored procedures (SPs) in <strong>Caché</strong> Studio. A T<strong>SQL</strong> SP can be either a class methodor a query. A class method takes parameters and returns a single scalar result, a query takes parameters and returns4 <strong>Caché</strong> <strong>Transact</strong>-<strong>SQL</strong> (T<strong>SQL</strong>) <strong>Migration</strong> <strong>Guide</strong>

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

Saved successfully!

Ooh no, something went wrong!