12.07.2015 Views

Oracle to Sybase ASE Migration Guide

Oracle to Sybase ASE Migration Guide

Oracle to Sybase ASE Migration Guide

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

ORACLE TO SYB<strong>ASE</strong> <strong>ASE</strong> MIGRATION GUIDERev.1.3<strong>Oracle</strong>Declarations without DECLARE keyword in declarationsection of s<strong>to</strong>red procedures/functionsCREATE PROCEDURE pASV1 NUMBER(10,0);V2 CHAR(20);CURSOR mycursor ISSELECT * FROM mytable;BEGIN…statements…END;Variable assignmentmyvar := expression;Transferring table data in<strong>to</strong> a variableSELECT my_col INTO my_variableFROM my_table WHERE id = 123;Constants%TYPE denotes the datatype of a column in an existingtable<strong>Sybase</strong> <strong>ASE</strong> ("simple conversion")DECLARE keyword is required in <strong>Sybase</strong> <strong>ASE</strong>.Cursors must be declared separately withDECLARE…CURSORCREATE PROCEDURE pASBEGINDECLARE@v1 int,@v2 char(20)DECLARE mycurs CURSOR ASSELECT * FROM mytable…statements…ENDgoSET @myvar = expressionSELECT @myvar = expressionDirectly select in<strong>to</strong> the variableSELECT @my_variable = my_col FROMmy_table WHERE id = 123Redefine as variables and check scope of usage (localor global).Explicitly declare the variable with the column's actualdatatypeDECLARE count my_table.id%TYPEDynamic SQLEXECUTE IMMEDIATE '…sql…';Optional clauses:EXECUTE IMMEDIATE '…sql…' USING …;EXECUTE IMMEDIATE '…sql…' INTO …;EXECUTE IMMEDIATE '…sql…' BULK COLLECTINTO …;Use <strong>Sybase</strong> <strong>ASE</strong> execute-immediateSET @cmd = '…sql…'EXECUTE (@cmd)or:EXECUTE ('…sql…')With the clauses USING (specifies parameters <strong>to</strong> thedynamic SQL), INTO (puts results in<strong>to</strong> variables forsingle-row results), BULK COLLECT INTO (s<strong>to</strong>resresults in<strong>to</strong> <strong>Oracle</strong> collections), the query should berewritten <strong>to</strong> achieve the same effect in <strong>ASE</strong>.<strong>Oracle</strong>-<strong>to</strong>-<strong>Sybase</strong> <strong>Migration</strong> Cross-Reference 48

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

Saved successfully!

Ooh no, something went wrong!