12.07.2015 Views

Solution Guide for Migrating Oracle on UNIX to SQL Server - Willy .Net

Solution Guide for Migrating Oracle on UNIX to SQL Server - Willy .Net

Solution Guide for Migrating Oracle on UNIX to SQL Server - Willy .Net

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

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

126 Developing: Databases — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> Schemas To create a view using T-<strong>SQL</strong>, use the following syntax:Table 6.23 offers a comparis<strong>on</strong> of the CREATE VIEW statements in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and<strong>SQL</strong> <strong>Server</strong>.Table 6.23: <strong>SQL</strong> Statement <str<strong>on</strong>g>for</str<strong>on</strong>g> Creating Views in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong><str<strong>on</strong>g>Oracle</str<strong>on</strong>g>CREATE [OR REPLACE] [FORCE |NO FORCE] VIEW [schema.]view_name<strong>SQL</strong> <strong>Server</strong>CREATE VIEW [owner.]view_namename [,…] ) ][ ( column_[ ( column_alias [ inline_c<strong>on</strong>straint ] [,…] [, AS select_statemen<strong>to</strong>ut_of_line_c<strong>on</strong>straint ] ) ]AS select_statement[ WITH READ ONLY ][ [ WITH CHECK OPTION ] [CONSTRAINT c<strong>on</strong>straint_name ] ][ WITH CHECK OPTION ]In O racle, views can be created without permissi<strong>on</strong>s <strong>on</strong> the base objects, or even withoutthe base objects existing, by using the FORCE keyword. This is not allowed in<strong>SQL</strong> <strong>Server</strong>. <strong>SQL</strong> <strong>Server</strong> also does not allow ORDER BY and GROUP BY clauses in theview definiti<strong>on</strong>.Note When a view is created in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> using an asterisk (*) in the SELECT clause, theasterisk is expanded <strong>to</strong> the actual column names in the definiti<strong>on</strong> of the view.SQ L <strong>Server</strong> retains the exact definiti<strong>on</strong> used in the DDL. <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> does the same thingwhen an asterisk (*) is not used. While c<strong>on</strong>verting from <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong>, the viewdefiniti<strong>on</strong> may be changed back <strong>to</strong> an asterisk instead of specifying every column.S<strong>to</strong>red ProgramsOra cle and <strong>SQL</strong> <strong>Server</strong> have the capability <strong>to</strong> s<strong>to</strong>re complex business logic (bey<strong>on</strong>dc<strong>on</strong>straints) inside the database. The code <strong>to</strong> support such requirements cannot beprovided by <strong>SQL</strong> because it cannot execute commands based <strong>on</strong> logical c<strong>on</strong>diti<strong>on</strong>s. Italso fails <strong>to</strong> support looping operati<strong>on</strong>s. In spite of recent extensi<strong>on</strong>s <strong>to</strong> <strong>SQL</strong>, such asinco rporati<strong>on</strong> of a CASE expressi<strong>on</strong>, it is still difficult <strong>to</strong> per<str<strong>on</strong>g>for</str<strong>on</strong>g>m more than <strong>on</strong>e operati<strong>on</strong>based <strong>on</strong> a logical c<strong>on</strong>diti<strong>on</strong> using these methods. The need <strong>to</strong> implement c<strong>on</strong>trolstructures and programming c<strong>on</strong>structs cannot be met with <strong>SQL</strong> al<strong>on</strong>e. Hence <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>and <strong>SQL</strong> <strong>Server</strong> both offer procedural extensi<strong>on</strong>s <strong>to</strong> <strong>SQL</strong>, PL/<strong>SQL</strong>, and Transact-<strong>SQL</strong> ( T-<strong>SQL</strong>), respectively, that offer a more complete envir<strong>on</strong>ment <str<strong>on</strong>g>for</str<strong>on</strong>g> defining s<strong>to</strong>red programs(or subprograms).S<strong>to</strong>red programs provide modularity (<strong>to</strong>p-down design), encapsulati<strong>on</strong> (logic is hidden),abstracti<strong>on</strong> (black box approach), security (<strong>on</strong>ly execute <strong>on</strong> subprogram), andextensibility (user-defined functi<strong>on</strong>ality). Additi<strong>on</strong>ally, existence inside the databasepromotes accessibility (available <strong>to</strong> all users), reuse (available <strong>to</strong> all database users),speed of executi<strong>on</strong> (s<strong>to</strong>red programs are in compiled <str<strong>on</strong>g>for</str<strong>on</strong>g>m), per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance (handling oflarge amounts of data close <strong>to</strong> its source), and reduced resource requirements (reducesnetwork bandwidth, memory, and so <strong>on</strong> because <strong>on</strong>ly the results are transported).In <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>, Java can be used <strong>to</strong> write native s<strong>to</strong>red procedures and user-defined functi<strong>on</strong>s.A PL/<strong>SQL</strong> procedure can also call external procedures or functi<strong>on</strong>s written in the Cprogramming language and s<strong>to</strong>red in a shared library.In <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>, there are four types of s<strong>to</strong>red programs: functi<strong>on</strong>s, procedures, packages, andtriggers. These objects are very similar in c<strong>on</strong>structi<strong>on</strong>, functi<strong>on</strong>ality,and usage <strong>to</strong> those

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

Saved successfully!

Ooh no, something went wrong!