12.11.2014 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

Create successful ePaper yourself

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

<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g><br />

<strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows<br />

Published April 2005


The in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> in this document and any document referenced herein is provided <str<strong>on</strong>g>for</str<strong>on</strong>g> in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong>al purposes <strong>on</strong>ly, is provided AS IS AND WITH ALL<br />

FAULTS and cannot be unders<strong>to</strong>od as substituting <str<strong>on</strong>g>for</str<strong>on</strong>g> cus<strong>to</strong>mized service and in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> that might be developed by Microsoft Corporati<strong>on</strong> <str<strong>on</strong>g>for</str<strong>on</strong>g> a<br />

particular user based up<strong>on</strong> that user’s particular envir<strong>on</strong>ment. RELIANCE UPON THIS DOCUMENT AND ANY DOCUMENT REFERENCED HEREIN<br />

IS AT THE USER’S OWN RISK.<br />

MICROSOFT CORPORATION PROVIDES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION CONTAINED IN<br />

THIS DOCUMENT AND ANY DOCUMENT REFERENCED HEREIN. Microsoft Corporati<strong>on</strong> provides no warranty and makes no representati<strong>on</strong> that<br />

the in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> provided in this document or any document referenced herein is suitable or appropriate <str<strong>on</strong>g>for</str<strong>on</strong>g> any situati<strong>on</strong>, and Microsoft Corporati<strong>on</strong><br />

cannot be held liable <str<strong>on</strong>g>for</str<strong>on</strong>g> any claim or damage of any kind that users of this document or any document referenced herein may suffer. Your retenti<strong>on</strong> of<br />

and/or use of this document and/or any document referenced herein c<strong>on</strong>stitutes your acceptance of these terms and c<strong>on</strong>diti<strong>on</strong>s. If you do not accept<br />

these terms and c<strong>on</strong>diti<strong>on</strong>s, Microsoft Corporati<strong>on</strong> does not provide you with any right <strong>to</strong> use any part of this document or any document referenced<br />

herein.<br />

Complying with the applicable copyright laws is the resp<strong>on</strong>sibility of the user. Without limiting the rights under copyright, no part of this document may<br />

be reproduced, s<strong>to</strong>red in or introduced in<strong>to</strong> a retrieval system, or transmitted in any <str<strong>on</strong>g>for</str<strong>on</strong>g>m or by any means (electr<strong>on</strong>ic, mechanical, pho<strong>to</strong>copying,<br />

recording or otherwise), or <str<strong>on</strong>g>for</str<strong>on</strong>g> any purpose, without the express written permissi<strong>on</strong> of Microsoft Corporati<strong>on</strong>.<br />

Microsoft may have patents, patent applicati<strong>on</strong>s, trademarks, copyrights or other intellectual property rights covering subject matter within this<br />

document. Except as provided in any separate written license agreement from Microsoft, the furnishing of this document does not give you, the user,<br />

any license <strong>to</strong> these patents, trademarks, copyrights or other intellectual property.<br />

In<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> in this document, including URL and other Internet Web site references, is subject <strong>to</strong> change without notice. Unless otherwise noted, the<br />

example companies, organizati<strong>on</strong>s, products, domain names, e-mail addresses, logos, people, places and events depicted herein are fictitious, and<br />

no associati<strong>on</strong> with any real company, organizati<strong>on</strong>, product, domain name, e-mail address, logo, pers<strong>on</strong>, place or event is intended or should be<br />

inferred.<br />

Microsoft, Visual Basic, Visual Studio, Windows, Windows <strong>Server</strong>, and Win32 are either registered trademarks or trademarks of Microsoft Corporati<strong>on</strong><br />

in the United States and/or other countries.<br />

©2005 Microsoft Corporati<strong>on</strong>. All rights reserved.<br />

The names of actual companies and products menti<strong>on</strong>ed herein may be the trademarks of their respective owners.


C<strong>on</strong>tents<br />

iii<br />

C<strong>on</strong>tents<br />

Preface........................................................................................................................................... ix<br />

Overview..................................................................................................................................................ix<br />

Technical Subjects Covered in This <str<strong>on</strong>g>Guide</str<strong>on</strong>g> ........................................................................................x<br />

Technical Subjects That Are Not Covered in This <str<strong>on</strong>g>Guide</str<strong>on</strong>g>...................................................................x<br />

Intended Audiences .................................................................................................................................xi<br />

Knowledge Prerequisites ................................................................................................................ xiii<br />

How <strong>to</strong> Use This <str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> ............................................................................................................ xiii<br />

Organizati<strong>on</strong> by Chapter..................................................................................................................xv<br />

Document C<strong>on</strong>venti<strong>on</strong>s ................................................................................................................. xvii<br />

Job Aids ................................................................................................................................................ xvii<br />

C<strong>on</strong>tribu<strong>to</strong>rs ........................................................................................................................................... xix<br />

Program Manager........................................................................................................................... xix<br />

Author ............................................................................................................................................. xix<br />

Edi<strong>to</strong>rs ............................................................................................................................................ xix<br />

Architects........................................................................................................................................ xix<br />

Test................................................................................................................................................. xix<br />

Feedback ............................................................................................................................................... xix<br />

Introducti<strong>on</strong> <strong>to</strong> the Microsoft <str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g>s Framework.................................................................. 1<br />

Introducti<strong>on</strong> and Goals............................................................................................................................. 1<br />

Overview of MSF ..................................................................................................................................... 1<br />

MSF Foundati<strong>on</strong>al Principles............................................................................................................ 2<br />

The MSF Team Model — Overview.................................................................................................. 2<br />

The MSF Process Model — Overview.............................................................................................. 3<br />

The MSF Disciplines — Overview .................................................................................................... 5<br />

Overview of MSF Phases ................................................................................................................11<br />

Envisi<strong>on</strong>ing Phase....................................................................................................................... 13<br />

Introducti<strong>on</strong> and Goals............................................................................................................................13<br />

Understand the Goals of the Migrati<strong>on</strong> Project .......................................................................................14<br />

Define the Business Goals ..............................................................................................................15<br />

Identify the Design Goals.................................................................................................................16<br />

Create the Problem Statement ...............................................................................................................18<br />

Create the Visi<strong>on</strong> Statement ...................................................................................................................18<br />

Define the User Profiles..........................................................................................................................19<br />

Assess the Current Situati<strong>on</strong> (High Level) ..............................................................................................19<br />

Capture High Level Requirements..........................................................................................................22<br />

Define the Project Scope ........................................................................................................................22<br />

Define the <str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> C<strong>on</strong>cept ...................................................................................................................23<br />

Applicati<strong>on</strong> and Database Migrati<strong>on</strong> <str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> Design Strategy........................................................23<br />

Optimal Strategy..............................................................................................................................30<br />

Set Up a Team........................................................................................................................................30<br />

Special C<strong>on</strong>siderati<strong>on</strong>s <str<strong>on</strong>g>for</str<strong>on</strong>g> Setting Up Your Migrati<strong>on</strong> Team...........................................................33<br />

Define the Project Structure....................................................................................................................34<br />

Define Project Communicati<strong>on</strong>s ......................................................................................................34<br />

Define Change C<strong>on</strong>trol ....................................................................................................................35<br />

Assess Risk ............................................................................................................................................36<br />

Manage Risks .........................................................................................................................................37<br />

Planning Phase............................................................................................................................ 39<br />

Introducti<strong>on</strong> and Goals............................................................................................................................39<br />

Complete a Detailed Assessment of the Existing Envir<strong>on</strong>ment ..............................................................40<br />

Applicati<strong>on</strong> .......................................................................................................................................41<br />

Database .........................................................................................................................................42<br />

Applicati<strong>on</strong> Infrastructure .................................................................................................................42<br />

Develop the <str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> Design and Architecture........................................................................................43<br />

Build the C<strong>on</strong>ceptual Design ...........................................................................................................44<br />

Build the Logical Design ..................................................................................................................45


iv<br />

C<strong>on</strong>tents<br />

Build the Physical Design ................................................................................................................48<br />

Incorporate Design C<strong>on</strong>siderati<strong>on</strong>s.........................................................................................................50<br />

Hardware Design C<strong>on</strong>siderati<strong>on</strong>s ....................................................................................................50<br />

Validate the Technology .........................................................................................................................50<br />

<strong>SQL</strong> <strong>Server</strong> Editi<strong>on</strong>s and Features ..................................................................................................51<br />

Windows <strong>Server</strong> 2003......................................................................................................................52<br />

Technical Proof of C<strong>on</strong>cept .............................................................................................................52<br />

Develop the Project Plans.......................................................................................................................53<br />

Development Plan ...........................................................................................................................53<br />

Stabilizing Phase Plans ...................................................................................................................55<br />

Test Plan .........................................................................................................................................55<br />

Pilot Plan .........................................................................................................................................59<br />

Deployment Plan .............................................................................................................................60<br />

Create the Project Schedules .................................................................................................................63<br />

Estimating the Ef<str<strong>on</strong>g>for</str<strong>on</strong>g>t ........................................................................................................................63<br />

Set Up the Development and Test Envir<strong>on</strong>ments ...................................................................................65<br />

Developing: Databases — Introducti<strong>on</strong> .................................................................................... 67<br />

Introducti<strong>on</strong> and Goals............................................................................................................................67<br />

<str<strong>on</strong>g>Migrating</str<strong>on</strong>g> the Database...........................................................................................................................68<br />

Developing: Databases — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> the Database Architecture ........................................... 71<br />

Introducti<strong>on</strong> and Goals............................................................................................................................71<br />

Build the <strong>SQL</strong> <strong>Server</strong> Instance................................................................................................................71<br />

Pre-Installati<strong>on</strong> Planning..................................................................................................................72<br />

Installati<strong>on</strong> .......................................................................................................................................72<br />

C<strong>on</strong>figure the <strong>Server</strong>...............................................................................................................................73<br />

C<strong>on</strong>figure Memory ...........................................................................................................................74<br />

Set the CPU Affinity.........................................................................................................................76<br />

C<strong>on</strong>figure the Listener .....................................................................................................................77<br />

Migrate the S<strong>to</strong>rage Architecture ............................................................................................................77<br />

Blocks ..............................................................................................................................................77<br />

Extents and Segments.....................................................................................................................78<br />

Tablespaces and Datafiles ..............................................................................................................79<br />

S<strong>to</strong>rage Definiti<strong>on</strong> <str<strong>on</strong>g>for</str<strong>on</strong>g> Tables and Indexes.......................................................................................81<br />

Migrate System S<strong>to</strong>rage Structures.................................................................................................82<br />

Developing: Databases — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> Schemas ........................................................................ 83<br />

Introducti<strong>on</strong> and Goals............................................................................................................................83<br />

Scripting Migrated Schema Objects........................................................................................................84<br />

Script Everything..............................................................................................................................84<br />

Provide Support Documentati<strong>on</strong>......................................................................................................84<br />

Protect the Scripts ...........................................................................................................................84<br />

Migrate the Schema................................................................................................................................85<br />

Map the S<strong>to</strong>rage Architecture ..........................................................................................................85<br />

Create Databases <str<strong>on</strong>g>for</str<strong>on</strong>g> the Schema...................................................................................................87<br />

Create Filegroups <str<strong>on</strong>g>for</str<strong>on</strong>g> the Tablespaces............................................................................................90<br />

Add Datafiles <strong>to</strong> Filegroups..............................................................................................................90<br />

Add Transacti<strong>on</strong> Logs......................................................................................................................91<br />

Sample Schema Migrati<strong>on</strong>...............................................................................................................91<br />

Migrate the Schema Objects...................................................................................................................98<br />

Create the Schema Owner ..............................................................................................................98<br />

Create the Schema Objects...........................................................................................................102<br />

Comments .....................................................................................................................................111<br />

C<strong>on</strong>straints ....................................................................................................................................111<br />

Triggers .........................................................................................................................................119<br />

Indexes ..........................................................................................................................................121<br />

Views .............................................................................................................................................123<br />

S<strong>to</strong>red Programs............................................................................................................................126<br />

<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g>s <str<strong>on</strong>g>for</str<strong>on</strong>g> Objects not Found in <strong>SQL</strong> <strong>Server</strong> .............................................................................129<br />

Sample Schema Object Migrati<strong>on</strong> .................................................................................................132


C<strong>on</strong>tents<br />

v<br />

Developing: Databases — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> the Database Users .................................................... 143<br />

Introducti<strong>on</strong> and Goals..........................................................................................................................143<br />

Create User Accounts...........................................................................................................................143<br />

Create Roles and Grant Privileges .......................................................................................................145<br />

Sample User Migrati<strong>on</strong> .........................................................................................................................147<br />

Developing: Databases — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> the Data........................................................................ 153<br />

Introducti<strong>on</strong> and Goals..........................................................................................................................153<br />

Planning the Data Migrati<strong>on</strong>..................................................................................................................153<br />

Opti<strong>on</strong>s <str<strong>on</strong>g>for</str<strong>on</strong>g> Migrati<strong>on</strong> .....................................................................................................................153<br />

Fac<strong>to</strong>rs in Migrati<strong>on</strong> .......................................................................................................................155<br />

Migrati<strong>on</strong> Strategy..........................................................................................................................156<br />

Executing the Data Migrati<strong>on</strong>................................................................................................................157<br />

Pre-Implementati<strong>on</strong> Tasks.............................................................................................................158<br />

Implementati<strong>on</strong> Tasks....................................................................................................................160<br />

Post-Implementati<strong>on</strong> Tasks ...........................................................................................................165<br />

Validating the Data Migrati<strong>on</strong>.........................................................................................................165<br />

Developing: Databases — Unit Testing the Migrati<strong>on</strong>........................................................... 167<br />

Introducti<strong>on</strong> and Goals..........................................................................................................................167<br />

Objectives of Testing ............................................................................................................................167<br />

The Testing Process.............................................................................................................................168<br />

Test Database Integrity..................................................................................................................169<br />

Test Security..................................................................................................................................169<br />

Validate Data .................................................................................................................................170<br />

Validate the Migrati<strong>on</strong> ....................................................................................................................170<br />

Developing: Applicati<strong>on</strong>s — Introducti<strong>on</strong>............................................................................... 173<br />

Introducti<strong>on</strong> and Goals..........................................................................................................................173<br />

Applicati<strong>on</strong> Migrati<strong>on</strong> Strategies ...........................................................................................................174<br />

Interoperati<strong>on</strong> ................................................................................................................................174<br />

Port or Rewrite <strong>to</strong> .NET Framework...............................................................................................175<br />

Port or Rewrite <strong>to</strong> Win32................................................................................................................175<br />

Quick Port Using Windows Services <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>UNIX</strong>...............................................................................176<br />

Scenarios and Cases............................................................................................................................176<br />

Developing: Applicati<strong>on</strong>s —<str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>SQL</strong> and PL/<strong>SQL</strong>............................................ 177<br />

Introducti<strong>on</strong> ...........................................................................................................................................177<br />

<str<strong>on</strong>g>Migrating</str<strong>on</strong>g> Data Access..........................................................................................................................177<br />

Sample Tables...............................................................................................................................179<br />

Migrati<strong>on</strong> Process Overview ..........................................................................................................181<br />

Step 1: Extracti<strong>on</strong> of Data Access .................................................................................................182<br />

Step 2: Transacti<strong>on</strong> Management..................................................................................................202<br />

Step 3: Fetch Strategy ...................................................................................................................203<br />

Step 4: Subprograms C<strong>on</strong>versi<strong>on</strong>..................................................................................................206<br />

Step 5: Job Scheduling..................................................................................................................213<br />

Step 6: Interface File C<strong>on</strong>versi<strong>on</strong>...................................................................................................217<br />

Step 7: Workflow Au<strong>to</strong>mati<strong>on</strong> ........................................................................................................217<br />

Step 8: Per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance Tuning..........................................................................................................218<br />

Developing: Applicati<strong>on</strong>s — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> Perl............................................................................ 223<br />

Introducti<strong>on</strong> and Goals..........................................................................................................................223<br />

Introducti<strong>on</strong> <strong>to</strong> the Perl DBI Architecture...............................................................................................224<br />

Scenario 1: Interoperati<strong>on</strong> of Perl <strong>on</strong> <strong>UNIX</strong> with <strong>SQL</strong> <strong>Server</strong>................................................................225<br />

Case 1: Interoperating an ODBC DBD Applicati<strong>on</strong>........................................................................226<br />

Case 2: Interoperating an <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> DBD Applicati<strong>on</strong>........................................................................228<br />

Scenario 2: Porting the Perl Applicati<strong>on</strong> <strong>to</strong> Windows ............................................................................232<br />

Case 1: Porting a Perl Applicati<strong>on</strong> using ODBC DBD....................................................................232<br />

Case 2: Porting a Perl Applicati<strong>on</strong> Using <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> DBD...................................................................234<br />

Developing: Applicati<strong>on</strong>s — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> PHP ........................................................................... 237<br />

Introducti<strong>on</strong> and Goals..........................................................................................................................237<br />

PHP Modules........................................................................................................................................238<br />

Scenario 1: Interoperating PHP <strong>on</strong> <strong>UNIX</strong> with <strong>SQL</strong> <strong>Server</strong>...................................................................240<br />

Case 1: Interoperating a PHP Applicati<strong>on</strong> Using ORA Functi<strong>on</strong>s ..................................................240


vi<br />

C<strong>on</strong>tents<br />

Case 2: Interoperating a PHP Applicati<strong>on</strong> Using OCI8 Functi<strong>on</strong>s.........................................................244<br />

Case 3: Interoperating a PHP Applicati<strong>on</strong> Using ODBC Functi<strong>on</strong>s.......................................................246<br />

Comm<strong>on</strong> Functi<strong>on</strong> Translati<strong>on</strong> Issues ..................................................................................................249<br />

Handling Transacti<strong>on</strong>s ...................................................................................................................249<br />

<str<strong>on</strong>g>Migrating</str<strong>on</strong>g> Cursors ..........................................................................................................................250<br />

C<strong>on</strong>necti<strong>on</strong> Pooling........................................................................................................................251<br />

S<strong>to</strong>red Procedures.........................................................................................................................251<br />

Scenario 2: Porting the Applicati<strong>on</strong> <strong>to</strong> Win32........................................................................................252<br />

Case 1: Porting a PHP Applicati<strong>on</strong> using ORA Functi<strong>on</strong>s .............................................................252<br />

Case 2: Porting a PHP Applicati<strong>on</strong> Using OCI8 Functi<strong>on</strong>s ............................................................252<br />

Case 3: Porting a PHP Applicati<strong>on</strong> Using ODBC Functi<strong>on</strong>s ..........................................................253<br />

Developing: Applicati<strong>on</strong>s — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> Java .......................................................................... 255<br />

Introducti<strong>on</strong> and Goals..........................................................................................................................255<br />

Scenario 1: Interoperating Java <strong>on</strong> <strong>UNIX</strong> with <strong>SQL</strong> <strong>Server</strong>...................................................................256<br />

Case 1: Interoperating a Java Applicati<strong>on</strong> Using the JDBC Driver ................................................256<br />

Scenario 2 — Porting the Applicati<strong>on</strong> <strong>to</strong> Win32 ....................................................................................259<br />

Developing: Applicati<strong>on</strong>s — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> Pyth<strong>on</strong> ...................................................................... 261<br />

Introducti<strong>on</strong> and Goals..........................................................................................................................261<br />

Scenario 1: Interoperating Pyth<strong>on</strong> <strong>on</strong> <strong>UNIX</strong> with <strong>SQL</strong> <strong>Server</strong> ...............................................................263<br />

Case 1: Interoperating Using the mxODBC Module ......................................................................263<br />

Scenario 2: Port the Pyth<strong>on</strong> Applicati<strong>on</strong> <strong>to</strong> Win32 ................................................................................266<br />

Case 1: Porting a Pyth<strong>on</strong> Applicati<strong>on</strong> using mxODBC...................................................................266<br />

Developing: Applicati<strong>on</strong>s — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Pro*C ............................................................ 269<br />

Introducti<strong>on</strong> and Goals..........................................................................................................................269<br />

Understanding the Technology .............................................................................................................270<br />

Understanding Pro*C.....................................................................................................................270<br />

Understanding .NET and ADO.NET ..............................................................................................270<br />

Scenario 1: Rewriting Pro*C <strong>to</strong> the .NET Plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m................................................................................271<br />

Case 1: Rewrite the Applicati<strong>on</strong> using Visual Basic.NET...............................................................271<br />

Developing: Applicati<strong>on</strong>s — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms ........................................................... 279<br />

Introducti<strong>on</strong> and Goals..........................................................................................................................279<br />

Migrati<strong>on</strong> Approach...............................................................................................................................279<br />

Examining <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms ......................................................................................................................281<br />

Object Library ................................................................................................................................284<br />

PL/<strong>SQL</strong> Library ..............................................................................................................................284<br />

Form Module .................................................................................................................................285<br />

Menu Module.................................................................................................................................288<br />

Windows and Canvases ................................................................................................................288<br />

Understanding Visual Basic .NET.........................................................................................................290<br />

Scenario 1: Rewriting <strong>to</strong> Visual Basic .NET ..........................................................................................291<br />

Case 1: Using <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Designer .....................................................................................................291<br />

Case 2: Manually Redesigning the Applicati<strong>on</strong>..............................................................................291<br />

Testing the Visual Basic .NET Applicati<strong>on</strong> ............................................................................................295<br />

Stabilizing Phase ....................................................................................................................... 297<br />

Introducti<strong>on</strong> and Goals..........................................................................................................................297<br />

Testing the <str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> ..............................................................................................................................298<br />

Best Practices................................................................................................................................299<br />

Preparing <str<strong>on</strong>g>for</str<strong>on</strong>g> Testing .....................................................................................................................299<br />

Types of Testing ............................................................................................................................301<br />

Bug Tracking and Reporting ..........................................................................................................305<br />

User Acceptance Testing and Signoff............................................................................................308<br />

Piloting the <str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> ..............................................................................................................................308<br />

Preparing <str<strong>on</strong>g>for</str<strong>on</strong>g> the Pilot ....................................................................................................................309<br />

C<strong>on</strong>ducting the Pilot.......................................................................................................................309<br />

Evaluating the Pilot ........................................................................................................................310<br />

Finalizing the Release...........................................................................................................................310<br />

Deploying Phase........................................................................................................................ 313


C<strong>on</strong>tents<br />

vii<br />

Introducti<strong>on</strong> and Goals..........................................................................................................................313<br />

Deploying the <str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g>..........................................................................................................................313<br />

Deploying the Database <strong>Server</strong>.....................................................................................................314<br />

Deploying the <strong>Server</strong> Side Applicati<strong>on</strong>s.........................................................................................317<br />

Deploying the Client Applicati<strong>on</strong> ....................................................................................................318<br />

Change Management ....................................................................................................................320<br />

Stabilizing the Deployment ...................................................................................................................320<br />

Deployment Checklist ....................................................................................................................320<br />

Quiet Period...................................................................................................................................323<br />

Transferring Ownership <strong>to</strong> Operati<strong>on</strong>s..................................................................................................324<br />

Project Team Tasks.......................................................................................................................324<br />

Operati<strong>on</strong>s Team Tasks ................................................................................................................325<br />

C<strong>on</strong>ducting Project Review and Closure...............................................................................................325<br />

Operati<strong>on</strong>s.................................................................................................................................. 327<br />

Introducti<strong>on</strong> and Goals..........................................................................................................................327<br />

Operati<strong>on</strong>al Framework ........................................................................................................................327<br />

Windows Envir<strong>on</strong>ment Operati<strong>on</strong>s........................................................................................................328<br />

System Administrati<strong>on</strong> ...................................................................................................................328<br />

Security Administrati<strong>on</strong> ..................................................................................................................328<br />

M<strong>on</strong>i<strong>to</strong>ring......................................................................................................................................329<br />

Additi<strong>on</strong>al Links .............................................................................................................................329<br />

<strong>SQL</strong> <strong>Server</strong> Envir<strong>on</strong>ment Operati<strong>on</strong>s ...................................................................................................329<br />

Administrati<strong>on</strong>................................................................................................................................329<br />

Security..........................................................................................................................................330<br />

M<strong>on</strong>i<strong>to</strong>ring......................................................................................................................................330<br />

Additi<strong>on</strong>al Links .............................................................................................................................330<br />

APPENDICES ............................................................................................................................. 331<br />

Appendix A: <strong>SQL</strong> <strong>Server</strong> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Professi<strong>on</strong>als................................................................................331<br />

Architecture ...................................................................................................................................331<br />

Administrati<strong>on</strong>................................................................................................................................343<br />

Appendix B: Getting the Best Out of <strong>SQL</strong> <strong>Server</strong> 2000 and Windows ..................................................348<br />

Per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance ..................................................................................................................................348<br />

Scalability ......................................................................................................................................349<br />

High Availability .............................................................................................................................349<br />

Features and Tools........................................................................................................................351<br />

Appendix C: Baselining.........................................................................................................................353<br />

Creating Baselines.........................................................................................................................353<br />

Capturing Statistics........................................................................................................................357<br />

Comparing and Reporting Results.................................................................................................357<br />

Appendix D: Installing Comm<strong>on</strong> Drivers and Applicati<strong>on</strong>s ....................................................................358<br />

Installing FreeTDS ................................................................................................................................358<br />

C<strong>on</strong>figuring FreeTDS.....................................................................................................................358<br />

Testing the FreeTDS C<strong>on</strong>figurati<strong>on</strong> ...............................................................................................358<br />

Installing unixODBC..............................................................................................................................359<br />

Installing ActiveState Perl .....................................................................................................................360<br />

Appendix E: Reference Resources.......................................................................................................362


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows<br />

ix<br />

Preface<br />

Overview<br />

The <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows Migrati<strong>on</strong> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> provides practical<br />

guidance <strong>on</strong> the processes and procedures <strong>to</strong> be followed while migrating from <str<strong>on</strong>g>Oracle</str<strong>on</strong>g><br />

databases (versi<strong>on</strong>s 8i and later) <strong>on</strong> <strong>UNIX</strong> plat<str<strong>on</strong>g>for</str<strong>on</strong>g>ms <strong>to</strong><br />

Microsoft® Windows® <strong>Server</strong> 2003 and Microsoft <strong>SQL</strong> <strong>Server</strong> 2000. This guide also<br />

presents strategies and procedural guidance <strong>to</strong> c<strong>on</strong>vert existing applicati<strong>on</strong>s <str<strong>on</strong>g>for</str<strong>on</strong>g> use<br />

within the <strong>SQL</strong> <strong>Server</strong> 2000 and Microsoft Windows <strong>Server</strong> envir<strong>on</strong>ment. This guide<br />

provides additi<strong>on</strong>al in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> and references <strong>to</strong> <strong>on</strong>line resources about migrating other<br />

comp<strong>on</strong>ents of your applicati<strong>on</strong> ecosystem, including the server and network<br />

infrastructure, development and test envir<strong>on</strong>ment, and user accounts.<br />

The guide is based <strong>on</strong> the experience of c<strong>on</strong>sultants working in the field and<br />

organizati<strong>on</strong>s that have successfully migrated from an <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> a <strong>SQL</strong> <strong>Server</strong><br />

<strong>on</strong> Windows envir<strong>on</strong>ment, and it comprises the best lab-tested, cus<strong>to</strong>mer-proven, crossproduct<br />

technical guidance from Microsoft <strong>on</strong> planning, building, deploying, and operating<br />

the migrati<strong>on</strong> soluti<strong>on</strong>. All processes and procedures c<strong>on</strong>tained in this guide have been<br />

validated through the Microsoft Technology Adopti<strong>on</strong> Program (TAP), which is a beta<br />

program that c<strong>on</strong>sists of cus<strong>to</strong>mers and partners who have evaluated and validated the<br />

various technologies and practices described in this guide.<br />

An important assumpti<strong>on</strong> made in this guide is that your organizati<strong>on</strong> has decided <strong>to</strong><br />

migrate all or parts of the <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> database and applicati<strong>on</strong> envir<strong>on</strong>ment from <strong>UNIX</strong> <strong>to</strong><br />

<strong>SQL</strong> <strong>Server</strong> 2000 in a Windows envir<strong>on</strong>ment. Because of this assumpti<strong>on</strong>, this guide<br />

does not present a competitive analysis of <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> versus <strong>SQL</strong> <strong>Server</strong> 2000, or <strong>UNIX</strong><br />

versus Windows. This guide does help you decide which migrati<strong>on</strong> strategy is best <str<strong>on</strong>g>for</str<strong>on</strong>g><br />

your organizati<strong>on</strong> given your specific business and technical requirements, and it<br />

explains how <strong>to</strong> plan <str<strong>on</strong>g>for</str<strong>on</strong>g> and execute that strategy.<br />

This process-driven approach <strong>to</strong> migrati<strong>on</strong> is applied <strong>to</strong> the <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> database, the <strong>UNIX</strong><br />

applicati<strong>on</strong>s that rely <strong>on</strong> the database, and the applicati<strong>on</strong> programming interfaces (APIs)<br />

that c<strong>on</strong>nect the applicati<strong>on</strong>s <strong>to</strong> the database. The strategies and methods <str<strong>on</strong>g>for</str<strong>on</strong>g> migrating<br />

these comp<strong>on</strong>ents vary according <strong>to</strong> the size and complexity of the database, applicati<strong>on</strong>,<br />

and infrastructure of the <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> source system. The strategies and methods also vary<br />

according <strong>to</strong> any new business or technical requirements your organizati<strong>on</strong> develops as a<br />

result of migrating <strong>to</strong> the Microsoft Windows plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m.<br />

Because there is so much variance in the possible approaches <strong>to</strong> migrati<strong>on</strong>, this guide<br />

provides numerous examples and best practices <strong>to</strong> help you better understand both the<br />

c<strong>on</strong>cepts and detailed processes involved in migrati<strong>on</strong>. A series of job aids (templates,<br />

spreadsheets, and questi<strong>on</strong>naires) are included as part of this soluti<strong>on</strong> guide <strong>to</strong> help you<br />

better analyze, plan, structure, and per<str<strong>on</strong>g>for</str<strong>on</strong>g>m the migrati<strong>on</strong>.<br />

The in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> under the following two headings outlines the technical scope of the<br />

migrati<strong>on</strong> strategies and methods provided in this guide.


x<br />

Preface<br />

Technical Subjects Covered in This <str<strong>on</strong>g>Guide</str<strong>on</strong>g><br />

The following technical <strong>to</strong>pics and subject areas are included in this guide:<br />

●<br />

●<br />

●<br />

●<br />

Migrati<strong>on</strong> of a typical <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> database, including objects (such as tables, indexes,<br />

views, triggers, and s<strong>to</strong>red procedures) and the c<strong>on</strong>tents of the objects <strong>to</strong> <strong>SQL</strong><br />

<strong>Server</strong>.<br />

Methods and procedures that focus <strong>on</strong> taking advantage of existing applicati<strong>on</strong>s <strong>on</strong><br />

<strong>UNIX</strong> plat<str<strong>on</strong>g>for</str<strong>on</strong>g>ms by communicating with <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows.<br />

Migrati<strong>on</strong> of applicati<strong>on</strong>s and APIs <strong>to</strong> work under Microsoft Win32®, Microsoft<br />

Windows Services <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>UNIX</strong>, and Microsoft .NET.<br />

Applicati<strong>on</strong> and API interoperability with <strong>SQL</strong> <strong>Server</strong>, including:<br />

●<br />

●<br />

●<br />

●<br />

●<br />

●<br />

●<br />

Java 2 Enterprise Editi<strong>on</strong> (J2EE) and Java Database C<strong>on</strong>nectivity (JDBC)<br />

Open Database C<strong>on</strong>nectivity (ODBC)<br />

Perl, including the DBI and DBD modules<br />

PHP<br />

Pyth<strong>on</strong><br />

Pro*C<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms<br />

●<br />

Microsoft offers the <strong>SQL</strong> <strong>Server</strong> Migrati<strong>on</strong> Assistant <strong>to</strong>olset <str<strong>on</strong>g>for</str<strong>on</strong>g> the migrati<strong>on</strong> of<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> databases <strong>to</strong> <strong>SQL</strong> <strong>Server</strong>, including:<br />

●<br />

●<br />

●<br />

●<br />

Migrati<strong>on</strong> Analyzer—analyzes the source <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> databases and produces vital<br />

statistics <strong>on</strong> the size and complexity of the migrati<strong>on</strong>.<br />

Schema and Data Migra<strong>to</strong>r—migrates the <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> schemas and moves the<br />

data in<strong>to</strong> the new <strong>SQL</strong> <strong>Server</strong> objects.<br />

<strong>SQL</strong> C<strong>on</strong>verter—c<strong>on</strong>verts code found in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> objects <strong>to</strong> their T-<strong>SQL</strong><br />

equivalents.<br />

Migrati<strong>on</strong> Tester—au<strong>to</strong>matically tests the c<strong>on</strong>verted code.<br />

These <strong>to</strong>ols can be downloaded from http://www.microsoft.com/sql/migrati<strong>on</strong>/. The <strong>to</strong>ols<br />

are in beta as of the date of publicati<strong>on</strong> <str<strong>on</strong>g>for</str<strong>on</strong>g> this soluti<strong>on</strong>. Versi<strong>on</strong> 1 of the <strong>to</strong>ols is slated <str<strong>on</strong>g>for</str<strong>on</strong>g><br />

release in June 2005 and will be available <str<strong>on</strong>g>for</str<strong>on</strong>g> download at the same locati<strong>on</strong>.<br />

Technical Subjects That Are Not Covered in This <str<strong>on</strong>g>Guide</str<strong>on</strong>g><br />

The following technical <strong>to</strong>pics and subject areas are not included in this guide:<br />

●<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> versi<strong>on</strong>s earlier than 8i and <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> 10g<br />

● <strong>SQL</strong> <strong>Server</strong> versi<strong>on</strong>s earlier than <strong>SQL</strong> <strong>Server</strong> 2000<br />

●<br />

●<br />

●<br />

●<br />

●<br />

●<br />

Design of hardware architecture<br />

Modeling and design of databases<br />

Procedures <str<strong>on</strong>g>for</str<strong>on</strong>g> database administrati<strong>on</strong> functi<strong>on</strong>s, such as capacity planning,<br />

backup and recovery, per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance tuning, and m<strong>on</strong>i<strong>to</strong>ring<br />

Aspects of the database that could be rendered inapplicable in the new<br />

envir<strong>on</strong>ment, such as archived data and backups<br />

Features available in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> that do not have corresp<strong>on</strong>ding features in <strong>SQL</strong><br />

<strong>Server</strong>, such as spatial data, XML DB, flashback query, <strong>SQL</strong>J, and X<strong>SQL</strong><br />

Installati<strong>on</strong> of applicati<strong>on</strong> clients, or client c<strong>on</strong>nectivity <strong>to</strong> the applicati<strong>on</strong> server or<br />

database


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows<br />

xi<br />

● Migrati<strong>on</strong> of the operating system <strong>to</strong> Microsoft Windows <strong>Server</strong> 2003<br />

●<br />

●<br />

Support <str<strong>on</strong>g>for</str<strong>on</strong>g> Open Management Group (OMG), an open-source, java-based<br />

standard <str<strong>on</strong>g>for</str<strong>on</strong>g> metadata<br />

Data extracti<strong>on</strong> from enterprise resource planning (ERP) systems<br />

While these technical subjects are not explicitly discussed in this guide, in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> about<br />

many of them is available from Microsoft. Where appropriate throughout this guide, links<br />

<strong>to</strong> more in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> are provided.<br />

Intended Audiences<br />

Generally, the intended audience <str<strong>on</strong>g>for</str<strong>on</strong>g> this soluti<strong>on</strong> guide includes medium and large-sized<br />

IT organizati<strong>on</strong>s that want <strong>to</strong> migrate their database and applicati<strong>on</strong>s from <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong><br />

<strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> 2000 <strong>on</strong> Windows. More specifically, this guide is written <str<strong>on</strong>g>for</str<strong>on</strong>g> all of<br />

the members of the migrati<strong>on</strong> team, from business decisi<strong>on</strong> makers <strong>to</strong> development <strong>to</strong><br />

operati<strong>on</strong>s. As a result, not all chapters in this guide are relevant <strong>to</strong> all team members,<br />

and the knowledge prerequisites <str<strong>on</strong>g>for</str<strong>on</strong>g> using this guide are expressed as an aggregate of<br />

the knowledge required of the team. The rest of this secti<strong>on</strong> provides brief descripti<strong>on</strong>s of<br />

the typical audiences <str<strong>on</strong>g>for</str<strong>on</strong>g> this guide, followed by a brief statement of the aggregate<br />

knowledge prerequisites <str<strong>on</strong>g>for</str<strong>on</strong>g> developing the soluti<strong>on</strong> described in this guide. The intended<br />

audience <str<strong>on</strong>g>for</str<strong>on</strong>g> individual chapters is identified in the "How <strong>to</strong> Use This <str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g>"<br />

secti<strong>on</strong> later in this Preface.<br />

The following list organizes comm<strong>on</strong> job titles and organizati<strong>on</strong>al resp<strong>on</strong>sibilities under<br />

the Microsoft <str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g>s Framework (MSF) role most comm<strong>on</strong>ly associated with that title<br />

or resp<strong>on</strong>sibility. The relati<strong>on</strong>ship between this soluti<strong>on</strong> guide and MSF is discussed in<br />

more detail in the "How <strong>to</strong> Use This <str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g>" secti<strong>on</strong>. In some organizati<strong>on</strong>s, a<br />

role may be filled by a single team member or many.<br />

● Stakeholders and High Level Decisi<strong>on</strong> Makers. These team members can be<br />

subdivided in<strong>to</strong> two groups:<br />

● Business Decisi<strong>on</strong> Makers (BDMs). This group often includes the CIO and IT<br />

direc<strong>to</strong>r of an organizati<strong>on</strong>. These pers<strong>on</strong>nel decide the business priorities <str<strong>on</strong>g>for</str<strong>on</strong>g><br />

purchasing and implementing soluti<strong>on</strong>s within the organizati<strong>on</strong>s. IT BDMs<br />

require a high-level understanding of the technical soluti<strong>on</strong>s being explored so<br />

that they can assess the value that the soluti<strong>on</strong> can provide <strong>to</strong> the<br />

organizati<strong>on</strong>.<br />

● Technical Decisi<strong>on</strong> Makers (TDMs). The focus of TDMs is <strong>to</strong> determine the<br />

technology used <strong>to</strong> solve business problems. IT TDMs must understand the<br />

business drivers the organizati<strong>on</strong>s face al<strong>on</strong>g with the functi<strong>on</strong>ality delivered by<br />

multiple technology scenarios.<br />

●<br />

●<br />

Product Management Role. This role usually includes team members with the<br />

following job title and resp<strong>on</strong>sibilities:<br />

● Product Manager. This team member acts as a link between the team<br />

members of the project and the cus<strong>to</strong>mers of the soluti<strong>on</strong> by handling highlevel<br />

communicati<strong>on</strong> and managing the cus<strong>to</strong>mer's expectati<strong>on</strong>s. The Product<br />

Manager ensures that the team addresses the cus<strong>to</strong>mer's needs, c<strong>on</strong>cerns,<br />

questi<strong>on</strong>s, and feedback throughout the project. Product managers must<br />

understand the business needs of the soluti<strong>on</strong>, including operati<strong>on</strong>s, business<br />

processes, and policies.<br />

User Experience Role. This role usually includes team members with the<br />

following job titles and resp<strong>on</strong>sibilities:


xii<br />

Preface<br />

●<br />

Usability Expert or Technical Writer/Edi<strong>to</strong>r. Ensures that the new soluti<strong>on</strong> is<br />

easy <str<strong>on</strong>g>for</str<strong>on</strong>g> cus<strong>to</strong>mers <strong>to</strong> use. The Usability Experts ensure that documentati<strong>on</strong><br />

and training is provided <strong>to</strong> end users <strong>to</strong> use the new soluti<strong>on</strong> effectively.<br />

●<br />

●<br />

●<br />

●<br />

Program Management Role. This role usually includes team members with the<br />

following job title and resp<strong>on</strong>sibilities:<br />

●<br />

Project Managers. These pers<strong>on</strong>nel are resp<strong>on</strong>sible <str<strong>on</strong>g>for</str<strong>on</strong>g> managing the<br />

resources and schedule <str<strong>on</strong>g>for</str<strong>on</strong>g> the migrati<strong>on</strong> project from start <strong>to</strong> end.<br />

Development Role. This role usually includes team members with the following<br />

job titles and resp<strong>on</strong>sibilities:<br />

●<br />

●<br />

●<br />

●<br />

●<br />

●<br />

●<br />

●<br />

IT Architect. The primary role of the IT architect is <strong>to</strong> carry out decisi<strong>on</strong>s made<br />

by the TDMs. Team members with this resp<strong>on</strong>sibility are most involved during<br />

the Planning, Developing, and Stabilizing Phases of the migrati<strong>on</strong> project.<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Database Administra<strong>to</strong>rs. These pers<strong>on</strong>nel are knowledgeable about<br />

the physical characteristics, logical characteristics, per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance, and service<br />

requirements of the source database. These pers<strong>on</strong>nel also have knowledge<br />

of any scripts and <strong>to</strong>ols that are used in database administrati<strong>on</strong>.<br />

<strong>SQL</strong> <strong>Server</strong> Database Administra<strong>to</strong>rs. These pers<strong>on</strong>nel are expert in<br />

architecting and implementing <strong>SQL</strong> <strong>Server</strong> databases. These team members<br />

will design the target <strong>SQL</strong> <strong>Server</strong> database envir<strong>on</strong>ment and per<str<strong>on</strong>g>for</str<strong>on</strong>g>m key tasks<br />

during the actual migrati<strong>on</strong>.<br />

<strong>UNIX</strong> System Administra<strong>to</strong>rs. These pers<strong>on</strong>nel have complete knowledge of<br />

the <strong>UNIX</strong> servers and the operating system installati<strong>on</strong>s, such as versi<strong>on</strong>s,<br />

packages, c<strong>on</strong>figurati<strong>on</strong>, and security.<br />

Windows System Administra<strong>to</strong>rs. These pers<strong>on</strong>nel have complete<br />

knowledge of the Windows operating system and the Microsoft applicati<strong>on</strong><br />

product line. These team members should have some experience in defining<br />

and implementing server technologies in Windows.<br />

<strong>UNIX</strong> Applicati<strong>on</strong> Developers. These pers<strong>on</strong>nel have knowledge of the<br />

applicati<strong>on</strong>s that are running in the current <strong>UNIX</strong> envir<strong>on</strong>ment and their<br />

implementati<strong>on</strong> details.<br />

Windows Applicati<strong>on</strong> Developers. These pers<strong>on</strong>nel have per<str<strong>on</strong>g>for</str<strong>on</strong>g>med<br />

development in the Windows envir<strong>on</strong>ment <str<strong>on</strong>g>for</str<strong>on</strong>g> the technologies involved in the<br />

soluti<strong>on</strong>.<br />

Security Specialists. These pers<strong>on</strong>nel have a wide base of knowledge about<br />

security issues, including how security relates <strong>to</strong> networks, servers, databases,<br />

and applicati<strong>on</strong>s.<br />

Test Role. This role usually includes team members with the following job titles<br />

and resp<strong>on</strong>sibilities:<br />

● Test Engineering Managers. These pers<strong>on</strong>nel have knowledge about testing<br />

applicati<strong>on</strong> and database soluti<strong>on</strong>s and also have managerial experience.<br />

● <strong>UNIX</strong> Database and Applicati<strong>on</strong>s Testers. These pers<strong>on</strong>nel have knowledge<br />

about all databases and applicati<strong>on</strong>s that are running in the current <strong>UNIX</strong><br />

envir<strong>on</strong>ment and provide input when test plans are created <str<strong>on</strong>g>for</str<strong>on</strong>g> the migrated<br />

envir<strong>on</strong>ment.<br />

● Windows Database and Applicati<strong>on</strong>s Testers. These team members have<br />

knowledge of databases and applicati<strong>on</strong>s in both <strong>UNIX</strong> and Windows. These<br />

pers<strong>on</strong>nel are experienced at creating and executing test plans.<br />

Release Management Role. This role usually includes team members with the<br />

following job titles and resp<strong>on</strong>sibilities:


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows<br />

xiii<br />

●<br />

●<br />

Deployment Manager. These pers<strong>on</strong>nel have knowledge of managing the<br />

deployment of the new database and applicati<strong>on</strong>s in the producti<strong>on</strong><br />

envir<strong>on</strong>ment.<br />

Technology Specialist. These pers<strong>on</strong>nel have knowledge of the technology<br />

and processes in a data center operati<strong>on</strong>. They have intimate knowledge of the<br />

soluti<strong>on</strong> being developed and will aid in transiti<strong>on</strong>ing them in<strong>to</strong> the producti<strong>on</strong><br />

envir<strong>on</strong>ment.<br />

Knowledge Prerequisites<br />

It is assumed that the technically-oriented audience <str<strong>on</strong>g>for</str<strong>on</strong>g> this guide has, in aggregate, the<br />

following specific technology competencies and proficiencies:<br />

● Expert level of <strong>UNIX</strong> development and administrati<strong>on</strong><br />

● Expert level of Windows development and administrati<strong>on</strong><br />

● Expert level of <strong>SQL</strong> <strong>Server</strong> and <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> administrati<strong>on</strong><br />

● Knowledgeable staff <strong>to</strong> maintain the new envir<strong>on</strong>ment and the technologies<br />

involved<br />

● Knowledgeable staff that understand any interacti<strong>on</strong> between the <strong>UNIX</strong> and<br />

Windows envir<strong>on</strong>ment when interoperability is created and maintained<br />

How <strong>to</strong> Use This <str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g><br />

The organizati<strong>on</strong> of this guide is based <strong>on</strong> the industry-proven need <strong>to</strong> manage IT<br />

projects according <strong>to</strong> a disciplined process that improves the likelihood of the project's<br />

success. It is designed <strong>to</strong> be used with a compani<strong>on</strong> guide, the <strong>UNIX</strong> Migrati<strong>on</strong> Project<br />

<str<strong>on</strong>g>Guide</str<strong>on</strong>g> (UMPG). While this guide c<strong>on</strong>tains the technical and soluti<strong>on</strong>-specific in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong><br />

needed <str<strong>on</strong>g>for</str<strong>on</strong>g> the project, the UMPG provides the disciplined process steps <str<strong>on</strong>g>for</str<strong>on</strong>g> using this<br />

in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> in the c<strong>on</strong>text of a migrati<strong>on</strong> project and a team organizati<strong>on</strong> model ("people<br />

and process" guidance).<br />

To facilitate their side-by-side use, both guides use project phases as an organizati<strong>on</strong>al<br />

device. Specifically, they follow the structure of the Microsoft <str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g>s Framework<br />

(MSF), which defines five distinct phases <str<strong>on</strong>g>for</str<strong>on</strong>g> IT projects: Envisi<strong>on</strong>ing, Planning,<br />

Developing (or <str<strong>on</strong>g>Migrating</str<strong>on</strong>g>), Stabilizing, and Deploying. Each guide presents the<br />

in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> (process or technical) needed <str<strong>on</strong>g>for</str<strong>on</strong>g> a phase within chapters named <str<strong>on</strong>g>for</str<strong>on</strong>g> that<br />

phase. For example, in the soluti<strong>on</strong> guide, business and technical in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> needed <str<strong>on</strong>g>for</str<strong>on</strong>g><br />

the initial decisi<strong>on</strong>-making is in the Envisi<strong>on</strong>ing chapter and detailed procedures and<br />

scripts are in the <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> chapters.<br />

The UMPG is essentially "MSF applied <strong>to</strong> <strong>UNIX</strong> migrati<strong>on</strong> projects." It begins with an<br />

overview of MSF and then describes the processes that bel<strong>on</strong>g <strong>to</strong> each phase and the<br />

team roles resp<strong>on</strong>sible <str<strong>on</strong>g>for</str<strong>on</strong>g> them — it is not, however, meant <strong>to</strong> serve as a comprehensive<br />

introducti<strong>on</strong> <strong>to</strong> MSF. In-depth in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> about MSF is available <strong>to</strong> interested readers <strong>on</strong><br />

the Microsoft <str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g>s Frameworks Web site at http://www.microsoft.com/msf.<br />

The reas<strong>on</strong> <str<strong>on</strong>g>for</str<strong>on</strong>g> separating the process guidance from technical and project-specific<br />

guidance is <strong>to</strong> keep this guide as lean as possible. It is recognized that some readers<br />

need <strong>to</strong> focus narrowly <strong>on</strong> project tasks, while pers<strong>on</strong>s with project management and<br />

team lead resp<strong>on</strong>sibilities need <strong>to</strong> digest the UMPG guidance and apply it <strong>to</strong> the project.<br />

Because organizati<strong>on</strong>al pers<strong>on</strong>nel and project team members tend <strong>to</strong> have different<br />

levels of involvement during different phases, the divisi<strong>on</strong> of c<strong>on</strong>tent according <strong>to</strong> project<br />

phase also supports the ability <strong>to</strong> focus <strong>on</strong> the material that is most relevant <strong>to</strong> a<br />

particular resp<strong>on</strong>sibility.


xiv<br />

Preface<br />

It is important <str<strong>on</strong>g>for</str<strong>on</strong>g> you <strong>to</strong> note the c<strong>on</strong>tent scope of this guidance. The applicati<strong>on</strong><br />

migrati<strong>on</strong> and interoperati<strong>on</strong>-related in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> in this soluti<strong>on</strong> <strong>on</strong>ly discusses issues<br />

pertaining <strong>to</strong> the database c<strong>on</strong>nectivity logic. It does not discuss general applicati<strong>on</strong><br />

porting issues between <strong>UNIX</strong> and Windows such as mapping <strong>UNIX</strong> system calls <strong>to</strong><br />

Windows APIs and migrating the graphical user interface (GUI). For detailed in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong><br />

about <strong>UNIX</strong> <strong>to</strong> Windows applicati<strong>on</strong> migrati<strong>on</strong>, refer <strong>to</strong> the <strong>UNIX</strong> Applicati<strong>on</strong> Migrati<strong>on</strong><br />

<str<strong>on</strong>g>Guide</str<strong>on</strong>g> (UAMG) available at http://msdn.microsoft.com/library/default.asp?url=/library/enus/dnucmg/html/ucmglp.asp.<br />

Note Although the two guides are designed <strong>to</strong> be used <strong>to</strong>gether, it is not necessary <strong>to</strong><br />

follow the MSF processes and team guidance described in the UMPG if the<br />

organizati<strong>on</strong> has an alternative project methodology in place. In that case, the UMPG<br />

would be used merely <strong>to</strong> map the MSF phases and team structure <strong>to</strong> the elements of<br />

the organizati<strong>on</strong>'s methodology. Readers who will use this guide <strong>to</strong> implement a project<br />

should read at least the overview of MSF in the UMPG <strong>to</strong> familiarize themselves with<br />

the MSF Process Model, the MSF Team Model, and MSF terminology.<br />

Figure 0.1 represents the chapters of interest <strong>to</strong> readers with different areas of<br />

resp<strong>on</strong>sibility.<br />

Figure 0.1<br />

Chapters of interest by team role


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows<br />

xv<br />

Organizati<strong>on</strong> by Chapter<br />

The following chapter list provides an overview of the c<strong>on</strong>tent and structure of this guide.<br />

●<br />

●<br />

●<br />

●<br />

●<br />

●<br />

●<br />

●<br />

●<br />

●<br />

●<br />

●<br />

●<br />

●<br />

●<br />

Preface.<br />

Chapter 1: Introducti<strong>on</strong> <strong>to</strong> the Microsoft <str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g>s Framework. This chapter<br />

provides a brief introducti<strong>on</strong> <strong>to</strong> the Microsoft <str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g>s Framework (MSF) and how<br />

it is applied <strong>to</strong> migrati<strong>on</strong> projects.<br />

Chapter 2: Envisi<strong>on</strong>ing Phase. This chapter provides guidance <strong>to</strong> carry out the<br />

various activities of the Envisi<strong>on</strong>ing Phase in an <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong><br />

Windows migrati<strong>on</strong> project. These activities include understanding your business<br />

and technical goals, assessing your current situati<strong>on</strong> at a high level, building a<br />

high-level soluti<strong>on</strong> c<strong>on</strong>cept, setting up the project team, and assessing project<br />

risks.<br />

Chapter 3: Planning Phase. This chapter provides guidance <strong>to</strong> carry out the<br />

various activities of the Planning Phase in an <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong><br />

Windows migrati<strong>on</strong> project. These activities include creating a detailed assessment<br />

of the current envir<strong>on</strong>ment, developing the soluti<strong>on</strong> design and architecture, and<br />

producing detailed project plans and project schedule.<br />

Chapter 4: Developing: Databases — Introducti<strong>on</strong>. This chapter introduces the<br />

different tasks in migrating the <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> database <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> 2000.<br />

Chapter 5: Developing: Databases — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> the Database Architecture.<br />

This chapter describes the steps <str<strong>on</strong>g>for</str<strong>on</strong>g> creating an instance of <strong>SQL</strong> <strong>Server</strong> which is<br />

equivalent in architecture <strong>to</strong> the original <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> database.<br />

Chapter 6: Developing: Databases — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> Schemas. This chapter shows<br />

how <strong>to</strong> migrate a schema owner and its objects <strong>to</strong> a <strong>SQL</strong> <strong>Server</strong> database.<br />

Chapter 7: Developing: Databases — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> the Database Users. This<br />

chapter c<strong>on</strong>tains detailed steps <str<strong>on</strong>g>for</str<strong>on</strong>g> creating users in the <strong>SQL</strong> <strong>Server</strong> databases<br />

and granting them the same kind of privileges they had in the original <str<strong>on</strong>g>Oracle</str<strong>on</strong>g><br />

database.<br />

Chapter 8: Developing: Databases — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> the Data. This chapter explores<br />

the different opti<strong>on</strong>s <str<strong>on</strong>g>for</str<strong>on</strong>g> migrating the applicati<strong>on</strong> data from <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong>.<br />

It provides details in the usage of each of the opti<strong>on</strong>s.<br />

Chapter 9: Developing: Databases — Unit Testing the Migrati<strong>on</strong>. This chapter<br />

c<strong>on</strong>tains the processes <str<strong>on</strong>g>for</str<strong>on</strong>g> testing the migrated database, its objects, and data.<br />

Chapter 10: Developing: Applicati<strong>on</strong>s — Introducti<strong>on</strong>. This chapter introduces<br />

the procedures <strong>to</strong> migrate the applicati<strong>on</strong> and the API (the c<strong>on</strong>nectivity tier<br />

between the database and the applicati<strong>on</strong>) from the existing soluti<strong>on</strong> <strong>to</strong> the<br />

proposed soluti<strong>on</strong>.<br />

Chapter 11: Developing: Applicati<strong>on</strong>s — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>SQL</strong> and PL/<strong>SQL</strong>.<br />

This chapter provides specific steps and procedures <str<strong>on</strong>g>for</str<strong>on</strong>g> c<strong>on</strong>verting <strong>SQL</strong><br />

statements and PL/<strong>SQL</strong> code <str<strong>on</strong>g>for</str<strong>on</strong>g> use with <strong>SQL</strong> <strong>Server</strong>.<br />

Chapter 12: Developing: Applicati<strong>on</strong>s — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> Perl. This chapter provides<br />

specific steps and procedures <str<strong>on</strong>g>for</str<strong>on</strong>g> migrating Perl applicati<strong>on</strong>s <strong>to</strong> the <strong>SQL</strong> <strong>Server</strong> <strong>on</strong><br />

Windows envir<strong>on</strong>ment.<br />

Chapter 13: Developing: Applicati<strong>on</strong>s — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> PHP. This chapter provides<br />

specific steps and procedures <str<strong>on</strong>g>for</str<strong>on</strong>g> migrating PHP applicati<strong>on</strong>s <strong>to</strong> the <strong>SQL</strong> <strong>Server</strong> <strong>on</strong><br />

Windows envir<strong>on</strong>ment.<br />

Chapter 14: Developing: Applicati<strong>on</strong>s — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> Java. This chapter provides<br />

specific steps and procedures <str<strong>on</strong>g>for</str<strong>on</strong>g> migrating Java applicati<strong>on</strong>s <strong>to</strong> the <strong>SQL</strong> <strong>Server</strong> <strong>on</strong><br />

Windows envir<strong>on</strong>ment.


xvi<br />

Preface<br />

●<br />

●<br />

●<br />

●<br />

●<br />

●<br />

●<br />

●<br />

●<br />

●<br />

Chapter 15: Developing: Applicati<strong>on</strong>s — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> Pyth<strong>on</strong>. This chapter<br />

provides specific steps and procedures <str<strong>on</strong>g>for</str<strong>on</strong>g> migrating Pyth<strong>on</strong> applicati<strong>on</strong>s <strong>to</strong> the<br />

<strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows envir<strong>on</strong>ment.<br />

Chapter 16: Developing: Applicati<strong>on</strong>s — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Pro*C. This chapter<br />

provides specific steps and procedures <str<strong>on</strong>g>for</str<strong>on</strong>g> migrating Pro*C applicati<strong>on</strong>s <strong>to</strong> the <strong>SQL</strong><br />

<strong>Server</strong> <strong>on</strong> Windows envir<strong>on</strong>ment.<br />

Chapter 17: Developing: Applicati<strong>on</strong>s — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms. This chapter<br />

discusses the opti<strong>on</strong>s available <str<strong>on</strong>g>for</str<strong>on</strong>g> migrating an <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms-based applicati<strong>on</strong>.<br />

Chapter 18: Stabilizing Phase. In this chapter, the soluti<strong>on</strong> is tested in an<br />

envir<strong>on</strong>ment similar <strong>to</strong> the producti<strong>on</strong> envir<strong>on</strong>ment. This chapter describes the<br />

various testing opti<strong>on</strong>s and processes that can be implemented <strong>to</strong> ensure the<br />

quality of the soluti<strong>on</strong>.<br />

Chapter 19: Deploying Phase. This chapter describes the procedure <str<strong>on</strong>g>for</str<strong>on</strong>g> moving<br />

the soluti<strong>on</strong> in<strong>to</strong> the producti<strong>on</strong> envir<strong>on</strong>ment and transferring ownership of the<br />

soluti<strong>on</strong> <strong>to</strong> operati<strong>on</strong>s. The chapter also identifies the tests that need <strong>to</strong> be<br />

per<str<strong>on</strong>g>for</str<strong>on</strong>g>med <strong>on</strong> the soluti<strong>on</strong> during deployment.<br />

Chapter 20: Operati<strong>on</strong>s. This chapter provides references <strong>to</strong> existing operati<strong>on</strong>al<br />

guides <strong>to</strong> administer a Windows-based server infrastructure and <strong>SQL</strong> <strong>Server</strong> 200<br />

based databases.<br />

Appendix A: <strong>SQL</strong> <strong>Server</strong> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Professi<strong>on</strong>als. This appendix provides<br />

in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <strong>to</strong> help <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> DBAs who do not have <strong>SQL</strong> <strong>Server</strong> experience learn<br />

about its administrati<strong>on</strong>.<br />

Appendix B: Getting the Best Out of <strong>SQL</strong> <strong>Server</strong> 2000 and Windows. This<br />

appendix provides reference <strong>to</strong> material <strong>to</strong> optimize and take advantage of <strong>SQL</strong><br />

<strong>Server</strong> and Windows.<br />

Appendix C: Baselining. This appendix provides detailed in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> about<br />

collecting statistics in <strong>SQL</strong> <strong>Server</strong>.<br />

Appendix D: Installing Comm<strong>on</strong> Applicati<strong>on</strong>s and Drivers. This appendix<br />

provides installati<strong>on</strong> instructi<strong>on</strong>s <str<strong>on</strong>g>for</str<strong>on</strong>g> applicati<strong>on</strong>s and drivers that may be used<br />

while migrating the applicati<strong>on</strong>.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows<br />

xvii<br />

Document C<strong>on</strong>venti<strong>on</strong>s<br />

This guide uses the style c<strong>on</strong>venti<strong>on</strong>s shown in Table 0.1.<br />

Table 0.1: Document C<strong>on</strong>venti<strong>on</strong>s<br />

Text Element<br />

Meaning<br />

Bold text<br />

Bold text is used in the c<strong>on</strong>text of<br />

paragraphs <str<strong>on</strong>g>for</str<strong>on</strong>g> commands; literal<br />

arguments <strong>to</strong> commands (including paths<br />

when they <str<strong>on</strong>g>for</str<strong>on</strong>g>m part of the command);<br />

switches; and programming elements,<br />

such as methods, functi<strong>on</strong>s, data types,<br />

and data structures. User interface<br />

elements are also identified with bold f<strong>on</strong>t.<br />

Italic text<br />

Italic text is used in the c<strong>on</strong>text of<br />

paragraphs <str<strong>on</strong>g>for</str<strong>on</strong>g> variables <strong>to</strong> be replaced by<br />

the user. It is also used <strong>to</strong> emphasize<br />

important in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong>.<br />

M<strong>on</strong>ospace f<strong>on</strong>t<br />

Used <str<strong>on</strong>g>for</str<strong>on</strong>g> excerpts from c<strong>on</strong>figurati<strong>on</strong> files,<br />

code examples, and terminal sessi<strong>on</strong>s.<br />

M<strong>on</strong>ospace bold f<strong>on</strong>t<br />

Used <strong>to</strong> represent commands or other text<br />

that the user types.<br />

M<strong>on</strong>ospace italic f<strong>on</strong>t<br />

Used <strong>to</strong> represent variables the reader<br />

supplies in command line examples and<br />

terminal sessi<strong>on</strong>s.<br />

UPPERCASE<br />

Transact-<strong>SQL</strong> keywords and <strong>SQL</strong><br />

elements.<br />

%SystemRoot% The folder in which Windows <strong>Server</strong> 2003<br />

is installed.<br />

Job Aids<br />

The job aids included with this guide can be used <strong>to</strong> support the various tasks per<str<strong>on</strong>g>for</str<strong>on</strong>g>med<br />

during the different phases of the migrati<strong>on</strong>. The aids are in the <str<strong>on</strong>g>for</str<strong>on</strong>g>m of questi<strong>on</strong>naires,<br />

<strong>to</strong>ols, and templates used <str<strong>on</strong>g>for</str<strong>on</strong>g> designing, planning, and managing the migrati<strong>on</strong> project.<br />

The job aids are either in Microsoft Excel spreadsheet or Microsoft Word document<br />

<str<strong>on</strong>g>for</str<strong>on</strong>g>mat. They are available in the Tools and Templates folder in the zip file download of<br />

this guidance at http://go.microsoft.com/fwlink/?LinkId=45289.<br />

The purpose of providing job aids is <strong>to</strong> help you speed up the development of your<br />

project documents. New or additi<strong>on</strong>al guidance is not provided in the job aids. Instead,<br />

the job aids are generic templates that you should cus<strong>to</strong>mize <strong>to</strong> fit your requirements.


xviii<br />

Preface<br />

Table 1.2: Job Aids Descripti<strong>on</strong>s<br />

Job Aid<br />

Visi<strong>on</strong>/Scope<br />

Project Structure<br />

Migrati<strong>on</strong> Risk Exposure Rating Form<br />

Assessing the Current Envir<strong>on</strong>ment<br />

Template<br />

Development Plan<br />

Test Plan<br />

Pilot Plan<br />

Deployment Plan<br />

Descripti<strong>on</strong><br />

Use this template <strong>to</strong> describe the goals of<br />

the project and the approaches that the<br />

team will use <strong>to</strong> achieve those goals.<br />

Use this template <strong>to</strong> define how the project<br />

is structured and managed and how the<br />

soluti<strong>on</strong> will be created. This template will<br />

help you c<strong>on</strong>trol and coordinate the entire<br />

project.<br />

This spreadsheet will help you identify the<br />

possible migrati<strong>on</strong> risks and their<br />

c<strong>on</strong>sequences. In additi<strong>on</strong>, this document<br />

also helps you <strong>to</strong> prioritize the risks and<br />

prepare a mitigati<strong>on</strong> plan <str<strong>on</strong>g>for</str<strong>on</strong>g> each risk.<br />

This template provides separate<br />

spreadsheets <strong>to</strong> assist in assessing the<br />

applicati<strong>on</strong>, database, and server<br />

envir<strong>on</strong>ments.<br />

This template helps you <strong>to</strong> describe the<br />

soluti<strong>on</strong> development process used <str<strong>on</strong>g>for</str<strong>on</strong>g> the<br />

project. This plan provides the technical<br />

details of what will be built, and it provides<br />

c<strong>on</strong>sistent guidelines and processes <strong>to</strong> the<br />

teams creating the soluti<strong>on</strong>.<br />

This template helps you <strong>to</strong> describe the<br />

strategy and approach used <strong>to</strong> plan,<br />

organize, and manage the project’s testing<br />

activities. It identifies testing objectives,<br />

methodologies and <strong>to</strong>ols, expected results,<br />

resp<strong>on</strong>sibilities, and resource<br />

requirements.<br />

This template c<strong>on</strong>tains in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <strong>to</strong> help<br />

prepare and execute a successful pilot. It<br />

includes pilot scope, user interacti<strong>on</strong>s and<br />

pilot evaluati<strong>on</strong><br />

This template helps you <strong>to</strong> describe the<br />

acti<strong>on</strong>s necessary <str<strong>on</strong>g>for</str<strong>on</strong>g> a smooth<br />

deployment and transiti<strong>on</strong> <strong>to</strong> <strong>on</strong>going<br />

operati<strong>on</strong>s. It covers the processes of<br />

preparing, installing, testing, training, and<br />

transferring the soluti<strong>on</strong> <strong>to</strong> operati<strong>on</strong>s.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows<br />

xix<br />

C<strong>on</strong>tribu<strong>to</strong>rs<br />

The following organizati<strong>on</strong>s and individuals c<strong>on</strong>tributed <strong>to</strong> this project.<br />

Program Manager<br />

Dhilip Gopalakrishnan (Microsoft)<br />

Author<br />

Scalability Experts<br />

Edi<strong>to</strong>rs<br />

Thomas Olsen (Volt Technical Services)<br />

Gaile Simm<strong>on</strong>s (Microsoft)<br />

Architects<br />

Peter Skjøtt Larsen (Microsoft)<br />

Jas<strong>on</strong> Zi<strong>on</strong>s (Microsoft)<br />

Test<br />

Sandor Kiss (Microsoft)<br />

Infosys Technologies<br />

Feedback<br />

Please direct questi<strong>on</strong>s and comments about this guide <strong>to</strong> cisfdbk@microsoft.com.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 1<br />

1<br />

Introducti<strong>on</strong> <strong>to</strong> the Microsoft<br />

<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g>s Framework<br />

Introducti<strong>on</strong> and Goals<br />

For large-scale projects, such as database migrati<strong>on</strong>s, it is vital <strong>to</strong> have a cohesive and<br />

structured project framework in place. This foundati<strong>on</strong> ensures that projects are carefully<br />

planned, roles and tasks are clearly identified and defined, and that the thousands of<br />

crucial details are addressed <str<strong>on</strong>g>for</str<strong>on</strong>g> a successful migrati<strong>on</strong>.<br />

In this chapter, you will learn about Microsoft <str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g>s Framework (MSF), which has<br />

been used successfully <strong>on</strong> numerous IT projects. This adaptable and robust project<br />

framework provides a comprehensive structure that assists in guiding the project from the<br />

initial planning stages until after the project has been completed. If you are familiar with<br />

MSF, skip this chapter and c<strong>on</strong>tinue with Chapter 2, "Envisi<strong>on</strong>ing Phase."<br />

Overview of MSF<br />

Every successful project follows a methodology <strong>to</strong> achieve its objectives. The<br />

methodology employed in this migrati<strong>on</strong> guide is the Microsoft <str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g>s Framework. A<br />

vast amount of in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> about MSF is available from Microsoft, and the <strong>UNIX</strong><br />

Migrati<strong>on</strong> Project <str<strong>on</strong>g>Guide</str<strong>on</strong>g> provides a thorough explanati<strong>on</strong> of MSF <str<strong>on</strong>g>for</str<strong>on</strong>g> specific audiences of<br />

this migrati<strong>on</strong> guide, such as the team members that fulfill the Program Management<br />

role. Yet not every team member <strong>on</strong> your migrati<strong>on</strong> project needs in-depth knowledge of<br />

MSF <strong>to</strong> successfully per<str<strong>on</strong>g>for</str<strong>on</strong>g>m their team functi<strong>on</strong>. Because this is the case, the following<br />

brief overview is intended <strong>to</strong> provide all team members with a high-level overview of MSF<br />

that will familiarize them with basic c<strong>on</strong>cepts and terminology and help them <strong>to</strong> better<br />

understand the specific secti<strong>on</strong>s of this migrati<strong>on</strong> guide that they will need <strong>to</strong> read,<br />

understand, and execute.<br />

MSF was created <strong>to</strong> maximize the success of IT projects throughout the entire IT life<br />

cycle. This in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> is derived from the experience gained within Microsoft <strong>on</strong> largescale<br />

software development and service operati<strong>on</strong> projects, the experience of Microsoft’s<br />

c<strong>on</strong>sultants, and comm<strong>on</strong> best practices from the worldwide IT industry.<br />

As opposed <strong>to</strong> a prescriptive methodology, MSF provides a flexible and scalable<br />

framework <strong>to</strong> meet the needs of any sized organizati<strong>on</strong> or project team. MSF guidance<br />

c<strong>on</strong>sists of principles, models, and disciplines <str<strong>on</strong>g>for</str<strong>on</strong>g> managing the people, process, and


2<br />

Introducti<strong>on</strong> <strong>to</strong> the Microsoft <str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g>s Framework<br />

technology elements that most projects encounter. A detailed introducti<strong>on</strong> <strong>to</strong> the MSF<br />

models and disciplines is available at http://www.microsoft.com/msf.<br />

MSF Foundati<strong>on</strong>al Principles<br />

At the core of MSF are eight foundati<strong>on</strong>al principles. For detailed in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <strong>on</strong> the eight<br />

foundati<strong>on</strong>al principles, download the MSF Versi<strong>on</strong> 3 Overview from<br />

http://msdn.microsoft.com/vstudio/enterprise/msf/.<br />

The eight foundati<strong>on</strong>al principles of MSF are:<br />

● Foster open communicati<strong>on</strong>s. The MSF Process Model enables an open and<br />

free flow of in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> am<strong>on</strong>g the team members and key stakeholders <strong>to</strong> prevent<br />

misunderstandings and reduce the probability that work will have <strong>to</strong> be red<strong>on</strong>e.<br />

Documenting the progress of the project and making it available <strong>to</strong> the team<br />

members, stakeholders, and cus<strong>to</strong>mers can best achieve this.<br />

● Work <strong>to</strong>ward a shared visi<strong>on</strong>. The MSF Process Model provides a phase (the<br />

Envisi<strong>on</strong>ing Phase) and a separate milest<strong>on</strong>e (Visi<strong>on</strong>/Scope Approved) <str<strong>on</strong>g>for</str<strong>on</strong>g> creating<br />

a shared visi<strong>on</strong>. A visi<strong>on</strong> includes detailed understanding of the goals and<br />

objectives that the soluti<strong>on</strong> needs <strong>to</strong> achieve. A shared visi<strong>on</strong> highlights the<br />

assumpti<strong>on</strong>s that the team members and cus<strong>to</strong>mers have <str<strong>on</strong>g>for</str<strong>on</strong>g> the soluti<strong>on</strong>.<br />

● Empower team members. Empowering the team members implies that the<br />

members accept resp<strong>on</strong>sibility and ownership of work assigned <strong>to</strong> them. Team<br />

empowerment can be achieved by preparing schedules where the team members<br />

commit <strong>to</strong> complete their work <strong>on</strong> a fixed date. This makes the team members feel<br />

accountable and also provides a method <str<strong>on</strong>g>for</str<strong>on</strong>g> identifying any potential delays early<br />

in the project.<br />

● Establish clear accountability and shared resp<strong>on</strong>sibility. The MSF Team<br />

Model is based <strong>on</strong> the principle that each role is accountable <str<strong>on</strong>g>for</str<strong>on</strong>g> the quality of the<br />

soluti<strong>on</strong>. All the team members share the overall resp<strong>on</strong>sibility of the project<br />

because the project can fail due <strong>to</strong> a mistake made by a single member.<br />

● Focus <strong>on</strong> delivering business value. The soluti<strong>on</strong> must deliver value <strong>to</strong> the<br />

organizati<strong>on</strong> in the <str<strong>on</strong>g>for</str<strong>on</strong>g>m of business value. This business value is achieved <strong>on</strong>ly<br />

after the soluti<strong>on</strong> is completely deployed in<strong>to</strong> the producti<strong>on</strong> envir<strong>on</strong>ment.<br />

● Stay agile, expect change. MSF assumes that the soluti<strong>on</strong> will encounter<br />

c<strong>on</strong>tinuous changes be<str<strong>on</strong>g>for</str<strong>on</strong>g>e being deployed <strong>to</strong> the producti<strong>on</strong> envir<strong>on</strong>ment. The<br />

team should be aware and prepared <strong>to</strong> manage such changes.<br />

● Invest in quality. In MSF, each team member is resp<strong>on</strong>sible <str<strong>on</strong>g>for</str<strong>on</strong>g> the quality of the<br />

soluti<strong>on</strong>. To c<strong>on</strong>firm the quality throughout the project's durati<strong>on</strong>, a test team is<br />

<str<strong>on</strong>g>for</str<strong>on</strong>g>med. This ensures that the soluti<strong>on</strong> meets the quality level of the stakeholders.<br />

● Learn from all experiences. MSF states that the experiences derived from <strong>on</strong>e<br />

project should be used and shared with teams in other projects. These<br />

experiences can also help <strong>to</strong> identify the best practices that should be followed in<br />

your organizati<strong>on</strong>.<br />

The MSF Team Model — Overview<br />

The MSF Team Model was developed over a period of several years <strong>to</strong> compensate <str<strong>on</strong>g>for</str<strong>on</strong>g><br />

some of the disadvantages imposed by the <strong>to</strong>p-down, hierarchical structure of traditi<strong>on</strong>al<br />

project teams. Teams organized under the MSF Team Model are small and<br />

multidisciplinary teams of peers, although the model is scalable <str<strong>on</strong>g>for</str<strong>on</strong>g> both small and large<br />

projects. Team members share resp<strong>on</strong>sibilities and balance each other’s competencies<br />

<strong>to</strong> keenly focus <strong>on</strong> the project at hand. They are expected <strong>to</strong> share a comm<strong>on</strong> project


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 3<br />

visi<strong>on</strong>, a focus <strong>on</strong> deploying the project, high standards <str<strong>on</strong>g>for</str<strong>on</strong>g> quality and communicati<strong>on</strong>,<br />

and a willingness <strong>to</strong> learn. Figure 1.1 shows the role clusters of the MSF Team Model.<br />

Figure 1.1<br />

The MSF Team Model<br />

The MSF Team Model emphasizes the importance of aligning role clusters (comm<strong>on</strong>ly<br />

referred <strong>to</strong> simply as "roles") <strong>to</strong> business needs. It does this by organizing each role<br />

around a quality goal that the project must meet <strong>to</strong> be successful. Each role aggregates a<br />

"cluster" of related functi<strong>on</strong>al areas and resp<strong>on</strong>sibilities. The functi<strong>on</strong>al areas each<br />

require a different discipline and focus, but are related in that they c<strong>on</strong>tribute <strong>to</strong>ward<br />

meeting the quality goal.<br />

The result is a well-balanced team whose skills and perspective represent all of the<br />

fundamental project goals. For team members, possessing a clearly defined role and<br />

owning a clearly defined goal is motivati<strong>on</strong>al. It increases the understanding of<br />

resp<strong>on</strong>sibilities, and ultimately leads <strong>to</strong> a better soluti<strong>on</strong>. Because each goal is critical <strong>to</strong><br />

the success of a project, the roles that represent these goals are c<strong>on</strong>sidered <strong>to</strong> be equally<br />

important. Pers<strong>on</strong>s filling the roles are given equal say in critical decisi<strong>on</strong>s and are<br />

thought of as peers. MSF teams are known as "teams of peers." Table 1.1 associates<br />

each role cluster with a quality goal.<br />

Table 1.1: Role Clusters and Quality Goals<br />

Role Cluster<br />

Program Management<br />

Development<br />

Test<br />

User Experience<br />

Release Management<br />

Product Management<br />

Goal<br />

Deliver the soluti<strong>on</strong> within project c<strong>on</strong>straints<br />

Build <strong>to</strong> specificati<strong>on</strong><br />

Approve <str<strong>on</strong>g>for</str<strong>on</strong>g> release <strong>on</strong>ly after all product quality<br />

issues are identified and addressed<br />

Enhance user effectiveness<br />

Achieve smooth deployment and <strong>on</strong>going operati<strong>on</strong>s<br />

Satisfy cus<strong>to</strong>mers<br />

The MSF Process Model — Overview<br />

The MSF Process Model describes a high-level sequence of activities <str<strong>on</strong>g>for</str<strong>on</strong>g> building and<br />

deploying IT soluti<strong>on</strong>s. Rather than prescribing a specific series of procedures, it is<br />

flexible enough <strong>to</strong> accommodate a broad range of IT projects. MSF combines two<br />

industry standard models: the waterfall model, which emphasizes the achievement of<br />

milest<strong>on</strong>es, and the spiral model, which focuses <strong>on</strong> the c<strong>on</strong>tinual need <strong>to</strong> refine the


4<br />

Introducti<strong>on</strong> <strong>to</strong> the Microsoft <str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g>s Framework<br />

requirements and estimates <str<strong>on</strong>g>for</str<strong>on</strong>g> a project. An innovative aspect of the MSF process<br />

model is that it covers the life cycle of a soluti<strong>on</strong> from project incepti<strong>on</strong> <strong>to</strong> live deployment.<br />

This helps project teams focus <strong>on</strong> cus<strong>to</strong>mer business value, because no value is realized<br />

until the soluti<strong>on</strong> is deployed and in operati<strong>on</strong>.<br />

Figure 1.2<br />

The MSF Process Model showing phases and major milest<strong>on</strong>es<br />

MSF is a milest<strong>on</strong>e-driven process. Milest<strong>on</strong>es fall at the end of each phase and c<strong>on</strong>tain<br />

criteria <str<strong>on</strong>g>for</str<strong>on</strong>g> completing the phase. Important deliverables must have been completed and<br />

critical questi<strong>on</strong>s, such as: Does the team agree <strong>on</strong> the project scope? Have we planned<br />

enough <strong>to</strong> proceed? Have we built what we said we would build? Is the soluti<strong>on</strong> working<br />

properly <str<strong>on</strong>g>for</str<strong>on</strong>g> the cus<strong>to</strong>mer? must be satisfac<strong>to</strong>rily answered. The project team and key<br />

stakeholders review the deliverables and reach agreement that the project can proceed<br />

<strong>to</strong> the next phase in a milest<strong>on</strong>e meeting.<br />

MSF is also an iterative process. The process model is designed <strong>to</strong> accommodate<br />

changing project requirements by iterating through short development cycles and<br />

incremental versi<strong>on</strong>s of the soluti<strong>on</strong>.<br />

The iterative aspect of the MSF process applies well <strong>to</strong> migrati<strong>on</strong> projects, which are<br />

frequently driven by an iterative process. In some cases, the migrati<strong>on</strong> task itself is<br />

approached iteratively. The first cycle migrates limited, basic functi<strong>on</strong>ality <strong>to</strong> the new<br />

plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m; and subsequent cycles add additi<strong>on</strong>al capabilities <strong>to</strong> the new envir<strong>on</strong>ment until<br />

it is equivalent <strong>to</strong> the original, unmigrated technology. In some other migrati<strong>on</strong> projects,<br />

the first cycle completely migrates some technology <strong>to</strong> a new envir<strong>on</strong>ment, while<br />

subsequent cycles extend the technology bey<strong>on</strong>d its original capabilities. Iterative<br />

approaches <strong>to</strong> migrati<strong>on</strong> projects provide a means <strong>to</strong> c<strong>on</strong>trol project risk and create<br />

greater flexibility <strong>to</strong> accommodate changing requirements.<br />

The MSF Process Model originated with the process used by Microsoft <strong>to</strong> develop<br />

applicati<strong>on</strong>s. This model may be applied <strong>to</strong> traditi<strong>on</strong>al applicati<strong>on</strong> development<br />

envir<strong>on</strong>ments, but is equally appropriate <str<strong>on</strong>g>for</str<strong>on</strong>g> the development and deployment of<br />

enterprise infrastructure soluti<strong>on</strong>s, Web development, e-commerce, and distributed<br />

applicati<strong>on</strong>s.<br />

Although the Program Management Role orchestrates the overall process within each<br />

phase, the successful achievement of each milest<strong>on</strong>e requires special leadership and<br />

accountability from each of the other team roles. As a project moves sequentially through<br />

each phase, the level of ef<str<strong>on</strong>g>for</str<strong>on</strong>g>t <str<strong>on</strong>g>for</str<strong>on</strong>g> each of the roles varies. The use of milest<strong>on</strong>es helps <strong>to</strong><br />

manage this ebb and flow of involvement in the project.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 5<br />

Table 1.2: Major Milest<strong>on</strong>es and Primary Drivers<br />

Milest<strong>on</strong>e<br />

Visi<strong>on</strong>/Scope Approved<br />

Project Plans Approved<br />

Scope Complete<br />

Release Readiness Approved<br />

Deployment Complete<br />

Primary Driver(s)<br />

Product Management<br />

Program Management<br />

Development and User Experience<br />

Test and Release Management<br />

Release Management<br />

Each phase also has interim milest<strong>on</strong>es that lead <strong>to</strong> the achievement of the final phase<br />

milest<strong>on</strong>e. Recommended interim milest<strong>on</strong>es are shown in Figure 1.3, but they may need<br />

<strong>to</strong> be modified <str<strong>on</strong>g>for</str<strong>on</strong>g> a particular project.<br />

Figure 1.3<br />

MSF Process Model with interim milest<strong>on</strong>es<br />

The MSF Disciplines — Overview<br />

MSF makes use of three classic disciplines, Risk Management, Readiness Management,<br />

and Project Management, which it has adapted <strong>to</strong> fit the framework. They are reflected in<br />

both the Process Model and the role resp<strong>on</strong>sibilities defined in the Team Model. This<br />

secti<strong>on</strong> describes each discipline briefly. For a thorough discussi<strong>on</strong> of each discipline and<br />

its applicati<strong>on</strong> within MSF, see the respective white papers available at<br />

http://msdn.microsoft.com/vstudio/enterprise/msf/.<br />

Risk Management<br />

The MSF Risk Management Discipline advocates proactive risk management, c<strong>on</strong>tinuous<br />

risk assessment, and integrati<strong>on</strong> in<strong>to</strong> decisi<strong>on</strong>-making throughout the project and<br />

operati<strong>on</strong>al life cycle. Risks are c<strong>on</strong>tinuously assessed, m<strong>on</strong>i<strong>to</strong>red, and actively managed<br />

until they are either resolved or the possible negative event happens and the risks have


6<br />

Introducti<strong>on</strong> <strong>to</strong> the Microsoft <str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g>s Framework<br />

become real problems <strong>to</strong> be handled as such. The MSF risk management process<br />

defines six logical steps the team uses <strong>to</strong> manage current risks, plan and execute risk<br />

management strategies, and capture knowledge <str<strong>on</strong>g>for</str<strong>on</strong>g> the enterprise. Figure 1.4 illustrates<br />

the relati<strong>on</strong>ship between the six steps.<br />

Figure 1.4<br />

The MSF risk management process<br />

The following list provides detailed in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> about each of the six risk management<br />

steps.<br />

● Identify. The process of risk identificati<strong>on</strong> calls <str<strong>on</strong>g>for</str<strong>on</strong>g> all team members <strong>to</strong> participate<br />

in surfacing risks <strong>to</strong> make the team aware of potential problems. As the input <strong>to</strong> the<br />

risk management process, risk identificati<strong>on</strong> should be undertaken as early as<br />

possible and repeated frequently throughout the project life cycle.<br />

● Analyze and Prioritize. Risk analysis trans<str<strong>on</strong>g>for</str<strong>on</strong>g>ms the estimates or data about<br />

specific project risks that surface during risk identificati<strong>on</strong> in<strong>to</strong> a <str<strong>on</strong>g>for</str<strong>on</strong>g>m that the team<br />

can use <strong>to</strong> make decisi<strong>on</strong>s regarding prioritizati<strong>on</strong>. Risk prioritizati<strong>on</strong> enables the<br />

team <strong>to</strong> commit project resources <strong>to</strong> manage the most important risks.<br />

● Plan and Schedule. Risk planning takes the in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> obtained from risk<br />

analysis and prioritizati<strong>on</strong> and uses it <strong>to</strong> <str<strong>on</strong>g>for</str<strong>on</strong>g>mulate strategies, plans, and acti<strong>on</strong>s.<br />

Risk scheduling ensures that these plans are approved and then incorporated in<strong>to</strong><br />

the project management process and infrastructure <strong>to</strong> ensure that risk<br />

management is carried out as part of the day-<strong>to</strong>-day activities of the team. Risk<br />

scheduling explicitly c<strong>on</strong>nects risk planning with project planning.<br />

● Track and Report. Risk tracking m<strong>on</strong>i<strong>to</strong>rs the status of specific risks and the<br />

progress in their respective acti<strong>on</strong> plans. Risk tracking also includes m<strong>on</strong>i<strong>to</strong>ring the<br />

probability, impact, exposure, and other measures of risk <str<strong>on</strong>g>for</str<strong>on</strong>g> changes that could<br />

alter priority, risk plans, and project features, resources, or schedule. Risk tracking<br />

enables visibility of the risk management process within the project from the<br />

perspective of risk levels as opposed <strong>to</strong> the task completi<strong>on</strong> perspective of the<br />

standard operati<strong>on</strong>al project management process. Risk reporting ensures that the<br />

team, sp<strong>on</strong>sor, and other stakeholders are aware of the status of project risks and<br />

the plans <strong>to</strong> manage them.<br />

● C<strong>on</strong>trol. Risk c<strong>on</strong>trol is the process of executing risk acti<strong>on</strong> plans and their<br />

associated status reporting. Risk c<strong>on</strong>trol also includes initiati<strong>on</strong> of project change<br />

c<strong>on</strong>trol requests when changes in risk status or risk plans could result in changes<br />

in project features, resources, or schedule.<br />

● Learn. Risk learning <str<strong>on</strong>g>for</str<strong>on</strong>g>malizes the less<strong>on</strong>s learned from the project, collects the<br />

relevant project artifacts and <strong>to</strong>ols, and captures that knowledge in reusable <str<strong>on</strong>g>for</str<strong>on</strong>g>m.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 7<br />

Readiness Management<br />

The MSF Readiness Management Discipline defines readiness as a measurement of the<br />

current state versus the desired state of knowledge, skills, and abilities (KSAs) of<br />

individuals in an organizati<strong>on</strong>. This measurement is the real or perceived capabilities of<br />

the individuals at any point during the <strong>on</strong>going process of planning, building, and<br />

managing soluti<strong>on</strong>s.<br />

Each role <strong>on</strong> a project team includes key functi<strong>on</strong>al areas that the individuals undertaking<br />

those roles must be capable of fulfilling. Individual readiness is the measurement of the<br />

state of an individual with regard <strong>to</strong> the KSAs needed <strong>to</strong> meet the resp<strong>on</strong>sibilities required<br />

of their particular role. The MSF Readiness Management Discipline includes a process <strong>to</strong><br />

help teams prepare <str<strong>on</strong>g>for</str<strong>on</strong>g> the KSAs needed <strong>to</strong> build and manage projects and soluti<strong>on</strong>s.<br />

The most basic approach <strong>to</strong> the readiness process is simply <strong>to</strong> assess skills and make<br />

appropriate changes through training. On projects that are small or have short<br />

timeframes, this streamlined approach is quite effective. For l<strong>on</strong>ger term or serial<br />

projects, organizati<strong>on</strong>s can benefit from per<str<strong>on</strong>g>for</str<strong>on</strong>g>ming the steps of defining the skills<br />

needed, evaluating the results of change produced by training, and keeping track of<br />

KSAs. This allows <str<strong>on</strong>g>for</str<strong>on</strong>g> the full realizati<strong>on</strong> of readiness management, and is typically where<br />

organizati<strong>on</strong>s reap the rewards of investments in readiness activities.<br />

The readiness management process is composed of four steps: Define, Assess, Change,<br />

and Evaluate. Each process step includes a series of tasks <strong>to</strong> help reach the next step.<br />

Figure 1.5<br />

The readiness management process<br />

Define<br />

This step focuses <strong>on</strong> defining requirements. It identifies and describes the scenarios,<br />

competencies, and proficiency levels needed <strong>to</strong> successfully plan, build, and manage the<br />

soluti<strong>on</strong>s. It also determines which roles in the team should be proficient in the defined<br />

competencies. Depending <strong>on</strong> the role, the individual filling it may need <strong>to</strong> be proficient in<br />

<strong>on</strong>e or many of the defined competencies.<br />

Scenarios describe the different types of activities that occur in a typical enterprise.<br />

Scenarios generally fall in<strong>to</strong> <strong>on</strong>e of four categories defined in terms of the business value<br />

they offer the organizati<strong>on</strong> — High Potential, Strategic, Key Operati<strong>on</strong>al, and Support.<br />

Different scenarios call <str<strong>on</strong>g>for</str<strong>on</strong>g> different types of skills and knowledge and distinct approaches<br />

<strong>to</strong> obtaining the appropriate resources and skills <str<strong>on</strong>g>for</str<strong>on</strong>g> that project type.


8<br />

Introducti<strong>on</strong> <strong>to</strong> the Microsoft <str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g>s Framework<br />

●<br />

●<br />

●<br />

●<br />

High Potential. These focus <strong>on</strong> the situati<strong>on</strong>s an IT department encounters when<br />

planning and designing <strong>to</strong> deploy, upgrade, or implement a new product,<br />

technology, or service in its organizati<strong>on</strong>. These are typically research type<br />

situati<strong>on</strong>s in which the technology is brand new or in beta <str<strong>on</strong>g>for</str<strong>on</strong>g>m. The organizati<strong>on</strong><br />

needs <strong>to</strong> have a high degree of agility and the capability <strong>to</strong> investigate and<br />

evaluate new technologies. For these scenarios, it needs <strong>to</strong> be prepared <strong>to</strong> obtain<br />

(<str<strong>on</strong>g>for</str<strong>on</strong>g> a short period) the best expertise available.<br />

Strategic. Scenarios in this category focus <strong>on</strong> the situati<strong>on</strong>s an IT department is<br />

likely <strong>to</strong> encounter when exploiting new technologies, products, or services. These<br />

are typically market-leading soluti<strong>on</strong>s that could lead <strong>to</strong> business trans<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong><br />

defining the <strong>to</strong>-be l<strong>on</strong>g-term architecture. Here the organizati<strong>on</strong> needs in-house, indepth<br />

expertise at the soluti<strong>on</strong> architect level and the capability of bridging skills<br />

across technology <strong>to</strong> the business.<br />

Key Operati<strong>on</strong>al. Scenarios in this category focus <strong>on</strong> the situati<strong>on</strong>s an IT<br />

department is likely <strong>to</strong> encounter <strong>on</strong>ce it has deployed, upgraded, or implemented<br />

a new product, technology, or service that has <strong>to</strong> coexist, or c<strong>on</strong>tinue <strong>to</strong> seamlessly<br />

interact with legacy software and systems. These are typically <strong>to</strong>day's businesscritical<br />

systems, aligned with the as-is technology architecture. Quality of technical<br />

knowledge and process are critical, as is ready availability of the skills applicable <strong>to</strong><br />

the relevant technologies. The challenges are easier <strong>to</strong> plan <str<strong>on</strong>g>for</str<strong>on</strong>g> when the<br />

technologies are proven. Typically, organizati<strong>on</strong>s obtain the readiness and skills<br />

needed in this scenario by out-sourcing or by developing str<strong>on</strong>g in-house<br />

capability.<br />

Support. Scenarios in this category focus <strong>on</strong> situati<strong>on</strong>s in which it is necessary <strong>to</strong><br />

extend the product <strong>to</strong> fit the needs of a cus<strong>to</strong>mer’s envir<strong>on</strong>ment. These are<br />

typically valuable but not business-critical soluti<strong>on</strong>s and often involve legacy<br />

technology. Here, cost of delivery becomes paramount and the organizati<strong>on</strong> may<br />

decide <strong>to</strong> rely <strong>on</strong> external skills (particularly <str<strong>on</strong>g>for</str<strong>on</strong>g> legacy) <strong>on</strong> a reactive basis.<br />

When determining the most appropriate scenario <str<strong>on</strong>g>for</str<strong>on</strong>g> a migrati<strong>on</strong> project, keep in mind<br />

that the technology being migrated was initially deployed under <strong>on</strong>e scenario. For<br />

example, it might have been implemented when the technology was new, or it might have<br />

been a key operati<strong>on</strong>al technology. As the new migrated envir<strong>on</strong>ment is envisi<strong>on</strong>ed,<br />

though, a different scenario may apply. If the technology has matured, <str<strong>on</strong>g>for</str<strong>on</strong>g> example, what<br />

was a “high potential” project may be treated, in migrati<strong>on</strong>, as a “key operati<strong>on</strong>al”<br />

scenario. Alternatively, what might have originally been a classical support-scenario<br />

project might involve, as a result of migrati<strong>on</strong> <strong>to</strong> newer technology, something more akin<br />

<strong>to</strong> the high potential scenario. Identifying the most appropriate scenario helps <strong>to</strong> map the<br />

appropriate competencies and proficiencies required <str<strong>on</strong>g>for</str<strong>on</strong>g> the migrati<strong>on</strong>.<br />

● Competencies describe the measurable objectives, or tasks, in a given scenario<br />

that an individual needs <strong>to</strong> be able <strong>to</strong> complete with proficiency. A single<br />

competency is used <strong>to</strong> define a major part of an individual’s job or job resp<strong>on</strong>sibility<br />

relating <strong>to</strong> per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance. A competency can be c<strong>on</strong>sidered a combinati<strong>on</strong> of skills,<br />

knowledge, and per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance requirements<br />

● Proficiencies are the measure of the capability <strong>to</strong> execute tasks associated with a<br />

particular competency within a given scenario. An individual's proficiency level<br />

provides a baseline <str<strong>on</strong>g>for</str<strong>on</strong>g> analyzing the gap between that individual's current skill set<br />

and the necessary skills <str<strong>on</strong>g>for</str<strong>on</strong>g> completi<strong>on</strong> of the tasks associated with the given<br />

scenario.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 9<br />

Assess<br />

The assess step focuses <strong>on</strong> the individual team members. It determines the<br />

competencies that these individuals currently possess. It is during this step that analysis<br />

of the competencies as they relate <strong>to</strong> the various job roles is undertaken <strong>to</strong> determine the<br />

skills of individuals within each of these roles. The desired competencies are then<br />

analyzed against the current competencies — the “<strong>to</strong>-be" versus the “as-is.” This work<br />

enables the development of learning plans, so that desired competency levels can be<br />

reached. The following tasks need <strong>to</strong> be per<str<strong>on</strong>g>for</str<strong>on</strong>g>med <strong>to</strong> complete the assess step:<br />

● Measure individuals' knowledge, skills, and abilities through self-assessments or<br />

skills assessments (tests).<br />

● Analyze gaps by comparing the individual's KSA measurements <strong>to</strong> the expected<br />

proficiency level <str<strong>on</strong>g>for</str<strong>on</strong>g> the role. Individuals can then c<strong>on</strong>centrate <strong>on</strong> bridging these<br />

gaps through the use of learning plans.<br />

● Create learning plans that identify the appropriate resources and methods (such as<br />

training materials, courseware, white papers, computer based training, men<strong>to</strong>ring,<br />

<strong>on</strong>-the-job, and self-directed training) <strong>to</strong> fill the gaps. Learning plans should c<strong>on</strong>sist<br />

of both <str<strong>on</strong>g>for</str<strong>on</strong>g>mal and in<str<strong>on</strong>g>for</str<strong>on</strong>g>mal learning activities, and guide individuals through the<br />

process of moving from <strong>on</strong>e proficiency level <strong>to</strong> the next.<br />

Change<br />

In this step, individuals advance their skills through learning in order <strong>to</strong> bridge the gap<br />

between their current proficiency and desired proficiency levels. In this step, the following<br />

tasks are accomplished:<br />

● Train individuals using the actual training, hands-<strong>on</strong> learning, and men<strong>to</strong>ring<br />

techniques described in the learning plans.<br />

● Track the learning of each individual. M<strong>on</strong>i<strong>to</strong>r and report the progress of individuals<br />

and their skills by scenario and competency. Tracking progress enables individual<br />

and overall readiness <strong>to</strong> be determined at any time in the life cycle.<br />

Evaluate<br />

This step determines whether the learning plans were effective and whether the less<strong>on</strong>s<br />

learned were successfully implemented <strong>on</strong> the job. At this point it is time <strong>to</strong>:<br />

● Review results <strong>to</strong> see if more training is necessary or if what was learned is being<br />

implemented <strong>on</strong> the job.<br />

● Manage knowledge <strong>to</strong> foster the sharing of the new intellectual resources. This<br />

sharing of knowledge enhances the collective knowledge of the soluti<strong>on</strong> team and<br />

the enterprise and fosters a learning community. Additi<strong>on</strong>ally, a <str<strong>on</strong>g>for</str<strong>on</strong>g>mal knowledge<br />

management system can provide a way <strong>to</strong> share comm<strong>on</strong> and repeatable best<br />

practices that help reduce costs and risks <str<strong>on</strong>g>for</str<strong>on</strong>g> other project teams.<br />

The MSF Readiness Management Discipline is c<strong>on</strong>sidered an <strong>on</strong>going, iterative<br />

approach <strong>to</strong> readiness. Following the steps in the process helps manage the various<br />

tasks required <strong>to</strong> align individual, project team, or organizati<strong>on</strong>al KSAs. It can lead <strong>to</strong><br />

better individual, project team, and strategic planning success.


10<br />

Introducti<strong>on</strong> <strong>to</strong> the Microsoft <str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g>s Framework<br />

Project Management<br />

The third important discipline adopted by MSF is the Project Management Discipline. To<br />

deliver a soluti<strong>on</strong> within project c<strong>on</strong>straints, str<strong>on</strong>g project management skills are<br />

essential. The MSF Team Model does not c<strong>on</strong>tain a role known as Project Manager;<br />

however, most project management functi<strong>on</strong>s are c<strong>on</strong>ducted by the MSF Program<br />

Management Role.<br />

Project management is a set of skills and techniques that include:<br />

● Integrating planning d<strong>on</strong>e <str<strong>on</strong>g>for</str<strong>on</strong>g> each aspect of the project.<br />

● C<strong>on</strong>ducting change c<strong>on</strong>trol.<br />

● Defining and managing the scope of the project.<br />

● Preparing a budget and managing costs.<br />

● Preparing and tracking schedules.<br />

● Getting the right resources allocated <strong>to</strong> the project.<br />

● Managing c<strong>on</strong>tracts and vendors, and procuring project resources.<br />

● Facilitating team and external communicati<strong>on</strong>s.<br />

● Facilitating the risk management process.<br />

● Documenting and tracking the team’s quality management process.<br />

Three distinctive characteristics of the MSF approach <strong>to</strong> project management stand out:<br />

● Most of the resp<strong>on</strong>sibilities of the role comm<strong>on</strong>ly known as "Project Manager" are<br />

encompassed in the MSF Program Management Role Cluster. As the size and<br />

complexity of a project grows, this role cluster is broken out in<strong>to</strong> two branches of<br />

specializati<strong>on</strong>: <strong>on</strong>e dealing with architecture and specificati<strong>on</strong>s and the other<br />

dealing with project management.<br />

● In larger projects requiring scaled-up MSF teams, project management activities<br />

occur at multiple levels. As the teams grow in number, the project management<br />

activities become distributed am<strong>on</strong>g the team leads <str<strong>on</strong>g>for</str<strong>on</strong>g> each of the MSF team<br />

roles. The Program Management Role is then resp<strong>on</strong>sible <str<strong>on</strong>g>for</str<strong>on</strong>g> management of the<br />

“rolled up” work from the leads in order <strong>to</strong> manage the entire soluti<strong>on</strong>.<br />

● Some large or complex projects require a specialist Project Manager or project<br />

management team. As the size, complexity, or risk becomes very large, often<br />

specialist roles or teams are created <strong>to</strong> focus <strong>on</strong> <strong>on</strong>e particular area. For the<br />

Program Management Role, this can be d<strong>on</strong>e <strong>to</strong> break the many project<br />

management tasks in<strong>to</strong> smaller, more manageable resp<strong>on</strong>sibility areas. These<br />

could include a specialist project manager, risk manager, soluti<strong>on</strong> architect,<br />

schedule administra<strong>to</strong>r, and so <strong>on</strong>.<br />

The differentiating fac<strong>to</strong>r of the MSF approach <strong>to</strong> project management is that the project<br />

management job functi<strong>on</strong> and activities do not impose a hierarchical structure <strong>on</strong> the<br />

decisi<strong>on</strong>-making process. MSF advocates against a rigid, “dicta<strong>to</strong>r” project management<br />

style because it works against an effective team of peers.<br />

The team of peers approach is a key success fac<strong>to</strong>r of MSF. All roles in MSF are<br />

c<strong>on</strong>sidered equally important and major decisi<strong>on</strong>s are arrived at by c<strong>on</strong>sensus of the core<br />

team. If that c<strong>on</strong>sensus cannot be achieved, the Program Management Role plays a<br />

tiebreaker functi<strong>on</strong>, making the final decisi<strong>on</strong> <strong>on</strong> the issue by transiti<strong>on</strong>ing in<strong>to</strong> a decisi<strong>on</strong><br />

leader <strong>to</strong> drive the project <str<strong>on</strong>g>for</str<strong>on</strong>g>ward. This decisi<strong>on</strong> is made from the perspective of meeting<br />

the cus<strong>to</strong>mer’s requirements and delivering the soluti<strong>on</strong> within the c<strong>on</strong>straints. Afterward,<br />

the team immediately resumes their normal peer relati<strong>on</strong>ships.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 11<br />

Overview of MSF Phases<br />

The in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> in this secti<strong>on</strong> describes the MSF phases that structure the organizati<strong>on</strong><br />

of this migrati<strong>on</strong> guide. These phases create the structure used <str<strong>on</strong>g>for</str<strong>on</strong>g> the project throughout<br />

the rest of this guide.<br />

Envisi<strong>on</strong>ing Phase<br />

In the Envisi<strong>on</strong>ing Phase, the team identifies the visi<strong>on</strong> and scope of the project by<br />

preparing a visi<strong>on</strong> and scope document.<br />

During this phase, goals <str<strong>on</strong>g>for</str<strong>on</strong>g> the project are <str<strong>on</strong>g>for</str<strong>on</strong>g>med and a visi<strong>on</strong> statement is created that<br />

defines the entire project. This shared visi<strong>on</strong> helps the team <strong>to</strong> work <strong>to</strong>wards a comm<strong>on</strong><br />

objective. The project team is assembled and the team members are empowered by<br />

having roles and resp<strong>on</strong>sibilities assigned <strong>to</strong> them.<br />

Another important activity in this phase is the identificati<strong>on</strong> of risks and preparati<strong>on</strong> of<br />

mitigati<strong>on</strong> and c<strong>on</strong>tingency plans. The risks identified and the mitigati<strong>on</strong> plans are used<br />

throughout the life cycle of the project. Refer <strong>to</strong> Chapter 2, "Envisi<strong>on</strong>ing Phase," <str<strong>on</strong>g>for</str<strong>on</strong>g> more<br />

details <strong>on</strong> the tasks and deliverables of the Envisi<strong>on</strong>ing Phase.<br />

Planning Phase<br />

During this phase, the existing envir<strong>on</strong>ment is assessed <strong>to</strong> <str<strong>on</strong>g>for</str<strong>on</strong>g>m a soluti<strong>on</strong> design. The<br />

main activity of this phase is <strong>to</strong> do a detailed planning <strong>to</strong> ensure success of the project. In<br />

this phase, a master project plan deliverable is created that c<strong>on</strong>sists of all sub-plans,<br />

such as the test plan, and development plan.<br />

The plan focuses <strong>on</strong> budgets, quality, schedule, and the technical implementati<strong>on</strong> of the<br />

soluti<strong>on</strong>. The project team follows these plans in the subsequent phases. Refer <strong>to</strong><br />

Chapter 3, "Planning Phase," <str<strong>on</strong>g>for</str<strong>on</strong>g> more details <strong>on</strong> the tasks and deliverables of the<br />

Planning Phase.<br />

Developing Phase<br />

During this phase, the applicati<strong>on</strong> comp<strong>on</strong>ents undergo trans<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> based <strong>on</strong> the<br />

development plans.<br />

Comp<strong>on</strong>ents that need a rewrite are developed. In comp<strong>on</strong>ents that are ported, changes<br />

based <strong>on</strong> syntax compliancy, per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance, and security are carried out. The source code<br />

and executables help <strong>to</strong> create the deliverables of this stage. Refer <strong>to</strong> Chapter 4,<br />

"Developing: Databases — Introducti<strong>on</strong>," <str<strong>on</strong>g>for</str<strong>on</strong>g> more in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <strong>on</strong> how <strong>to</strong> migrate a<br />

database. Chapter 10, "Developing: Applicati<strong>on</strong>s — Introducti<strong>on</strong>," provides different<br />

scenarios <str<strong>on</strong>g>for</str<strong>on</strong>g> migrating an applicati<strong>on</strong>.<br />

Stabilizing Phase<br />

During this phase, all the comp<strong>on</strong>ents are tested collectively <strong>to</strong> ensure that the entire<br />

soluti<strong>on</strong> operates properly.<br />

The testing criteria include achieving the desired functi<strong>on</strong>ality, security, and per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance<br />

requirements. To ensure this, both white box and black box testing are per<str<strong>on</strong>g>for</str<strong>on</strong>g>med. The<br />

tested database and comp<strong>on</strong>ents <str<strong>on</strong>g>for</str<strong>on</strong>g>m the deliverables of this stage.<br />

Once testing is complete, the soluti<strong>on</strong> must be stabilized <strong>to</strong> ensure that it meets defined<br />

quality levels. If the migrati<strong>on</strong> is complex, a pilot test of the applicati<strong>on</strong> can also be<br />

per<str<strong>on</strong>g>for</str<strong>on</strong>g>med during the Stabilizing Phase. Refer <strong>to</strong> Chapter 18, "Stabilizing Phase," <str<strong>on</strong>g>for</str<strong>on</strong>g><br />

more details <strong>on</strong> the tasks and deliverables of the Stabilizing Phase.


12<br />

Introducti<strong>on</strong> <strong>to</strong> the Microsoft <str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g>s Framework<br />

Deploying Phase<br />

In this phase, the team deploys the soluti<strong>on</strong> and ensures that it is stable and can be<br />

used. The tested soluti<strong>on</strong> is moved in<strong>to</strong> producti<strong>on</strong> and transferred <strong>to</strong> operati<strong>on</strong>s.<br />

During this phase, the soluti<strong>on</strong> comp<strong>on</strong>ents are tuned in the producti<strong>on</strong> envir<strong>on</strong>ment. A<br />

soluti<strong>on</strong> signoff is obtained from all stakeholders that c<strong>on</strong>firms that the applicati<strong>on</strong> meets<br />

the requirements developed during the Envisi<strong>on</strong>ing and Planning Phases. Refer <strong>to</strong><br />

Chapter 19, "Deploying Phase," <str<strong>on</strong>g>for</str<strong>on</strong>g> more details <strong>on</strong> the tasks and deliverables of the<br />

Deploying Phase. The migrati<strong>on</strong> project and the guidance are deeply rooted in the MSF<br />

methodology, and the chapters are in chr<strong>on</strong>ological order of the MSF phases starting<br />

from Chapter 2, "Envisi<strong>on</strong>ing Phase, through Chapter 19, "Deploying Phase."


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 13<br />

2<br />

Envisi<strong>on</strong>ing Phase<br />

Introducti<strong>on</strong> and Goals<br />

This chapter provides the process and technical in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> required <strong>to</strong> complete the<br />

Envisi<strong>on</strong>ing Phase of an <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows® migrati<strong>on</strong> project.<br />

The Envisi<strong>on</strong>ing Phase is an early stage of planning. This is the period during which the<br />

team, the cus<strong>to</strong>mer, and the sp<strong>on</strong>sors define the high-level requirements and overall<br />

goals of the project. The main purpose of the work per<str<strong>on</strong>g>for</str<strong>on</strong>g>med during the phase is <strong>to</strong><br />

ensure a comm<strong>on</strong> visi<strong>on</strong> and reach c<strong>on</strong>sensus am<strong>on</strong>g the team members that the project<br />

is both valuable <strong>to</strong> the organizati<strong>on</strong> and likely <strong>to</strong> succeed. During the Envisi<strong>on</strong>ing Phase,<br />

the focus is <strong>on</strong> creating clear definiti<strong>on</strong>s of the problem and understanding the high level<br />

approach <strong>to</strong> solving the problem. This sets a solid foundati<strong>on</strong> from which specific plans<br />

can be developed during the Planning Phase and executed during all subsequent phases<br />

<strong>to</strong> achieve the migrati<strong>on</strong> objectives. The Envisi<strong>on</strong>ing Phase culminates in the<br />

Visi<strong>on</strong>/Scope Approved Milest<strong>on</strong>e.<br />

The key deliverables <str<strong>on</strong>g>for</str<strong>on</strong>g> the project team during the Envisi<strong>on</strong>ing Phase are:<br />

● Visi<strong>on</strong>/scope document. The visi<strong>on</strong>/scope document describes the project goals<br />

and c<strong>on</strong>straints. It outlines the soluti<strong>on</strong> being developed, the requirements the<br />

soluti<strong>on</strong> will meet, and the approach that the team will take <strong>to</strong> complete the project.<br />

The visi<strong>on</strong>/scope document is an early <str<strong>on</strong>g>for</str<strong>on</strong>g>m of the functi<strong>on</strong>al specificati<strong>on</strong> that is<br />

developed during the Planning Phase. For more in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <strong>on</strong> creating your<br />

visi<strong>on</strong>/scope document, refer <strong>to</strong> the visi<strong>on</strong>/scope template.<br />

● Project structure document. The project structure document defines the approach<br />

the team will take <strong>to</strong> manage the project. It defines the team’s administrative<br />

structure, standards, processes (such as versi<strong>on</strong> c<strong>on</strong>trol and change c<strong>on</strong>trol),<br />

project resources, and c<strong>on</strong>straints. The document identifies the team lead<br />

resp<strong>on</strong>sible <str<strong>on</strong>g>for</str<strong>on</strong>g> each MSF role.<br />

● Risk assessment document. The risk assessment document provides an initial<br />

identificati<strong>on</strong> and analysis of risks associated with a project. This analysis includes<br />

mitigati<strong>on</strong> and c<strong>on</strong>tingency plans <strong>to</strong> help the team manage specific risks. Refer <strong>to</strong><br />

the Risk Assessment template <str<strong>on</strong>g>for</str<strong>on</strong>g> more in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong>.<br />

Templates <str<strong>on</strong>g>for</str<strong>on</strong>g> each of these key deliverables are available in the Tools and Templates<br />

folder in the zip file download of this guidance at<br />

http://go.microsoft.com/fwlink/?LinkId=45289.<br />

Table 2.1 lists the key activities that the team undertakes in the Envisi<strong>on</strong>ing Phase. The<br />

results of these activities are documented in this phase's deliverables.


14<br />

Envisi<strong>on</strong>ing Phase<br />

Table 2.1: Major Tasks, Deliverables, and Primary Owners<br />

Tasks Project Deliverable Primary Owner<br />

Understand the goals of the Visi<strong>on</strong>/scope document Product Management<br />

migrati<strong>on</strong> project (business<br />

and design)<br />

Create the problem<br />

Visi<strong>on</strong>/scope document Product Management<br />

statement<br />

Create the visi<strong>on</strong> statement Visi<strong>on</strong>/scope document Product Management<br />

Define end user profiles Visi<strong>on</strong>/scope document Product Management<br />

Assess the current situati<strong>on</strong> Visi<strong>on</strong>/scope document Program Management<br />

(high level)<br />

Identify high level<br />

Visi<strong>on</strong>/scope document Product Management<br />

requirements<br />

Define the project scope Visi<strong>on</strong>/scope document Program Management<br />

Define the soluti<strong>on</strong> c<strong>on</strong>cept Visi<strong>on</strong>/scope document Program Management<br />

Set up a team Project structure document Program Management<br />

Product Management<br />

Define the project structure Project structure document Program Management<br />

Assess risk Risk assessment document Program Management<br />

Note This chapter provides in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> about the essential tasks of the Envisi<strong>on</strong>ing<br />

Phase <str<strong>on</strong>g>for</str<strong>on</strong>g> an <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows migrati<strong>on</strong> project. The chapter<br />

is not exhaustive. For a detailed descripti<strong>on</strong> of all the activities and deliverables <str<strong>on</strong>g>for</str<strong>on</strong>g> the<br />

MSF Envisi<strong>on</strong>ing Phase, refer <strong>to</strong> the <strong>UNIX</strong> Migrati<strong>on</strong> Project <str<strong>on</strong>g>Guide</str<strong>on</strong>g> (UMPG) available at<br />

http://go.microsoft.com/fwlink/?LinkId=19832.<br />

Understand the Goals of the Migrati<strong>on</strong> Project<br />

An early, clear understanding of the goals of the migrati<strong>on</strong> project by the project team is<br />

imperative <str<strong>on</strong>g>for</str<strong>on</strong>g> its success. These high level goals are not defined by the project team;<br />

they are defined by the business managers and major stakeholders. The reas<strong>on</strong>ing <str<strong>on</strong>g>for</str<strong>on</strong>g><br />

reaching an early c<strong>on</strong>sensus <strong>on</strong> the goals includes:<br />

● The migrati<strong>on</strong> goals, <strong>on</strong>ce identified, are used <strong>to</strong> create a visi<strong>on</strong> statement <str<strong>on</strong>g>for</str<strong>on</strong>g> the<br />

migrati<strong>on</strong> project. This visi<strong>on</strong> statement is the key driver <str<strong>on</strong>g>for</str<strong>on</strong>g> all acti<strong>on</strong>s and<br />

decisi<strong>on</strong>s made by the team during the course of the migrati<strong>on</strong> project.<br />

● The goals determine the aggregate skill set required by the project team <strong>to</strong><br />

successfully execute the migrati<strong>on</strong> project.<br />

● The project team uses these goals <strong>to</strong> scope specific requirements that, in turn,<br />

serve as the basis <str<strong>on</strong>g>for</str<strong>on</strong>g> detailed soluti<strong>on</strong> designs and plans.<br />

● The goals serve as the basis <str<strong>on</strong>g>for</str<strong>on</strong>g> rec<strong>on</strong>ciling c<strong>on</strong>flicts and establishing priorities that<br />

guide any trade-off decisi<strong>on</strong>s (schedule, features, resources, budgetary<br />

restricti<strong>on</strong>s) that need <strong>to</strong> be made later in the project.<br />

The project goals can be classified as business goals and design goals. Both types of<br />

goals are described in detail in the following secti<strong>on</strong>s.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 15<br />

Define the Business Goals<br />

Business goals are established either <strong>to</strong> take advantage of an opportunity or <strong>to</strong> solve a<br />

problem in the current business. Each organizati<strong>on</strong> has business goals specific <strong>to</strong> them.<br />

For example, a business goal <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>on</strong>e organizati<strong>on</strong> could be <strong>to</strong> “c<strong>on</strong>solidate the ERP<br />

applicati<strong>on</strong>s across all worldwide units <strong>on</strong> <strong>on</strong>e software plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m after a merger with<br />

another company,” while a different organizati<strong>on</strong> may have compliance with new federal<br />

regulati<strong>on</strong>s as its primary business goal. Because business goals can vary widely, this<br />

guide does not provide a specific, comprehensive list of business goals. Your<br />

organizati<strong>on</strong> will have <strong>to</strong> determine the business goals specific <strong>to</strong> it. However, the two<br />

most comm<strong>on</strong> business goals <str<strong>on</strong>g>for</str<strong>on</strong>g> IT projects are:<br />

● Reduce <strong>to</strong>tal cost of ownership (TCO) of the IT plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m<br />

● Maximize return <strong>on</strong> investment (ROI)<br />

Because these two business goals are so comm<strong>on</strong>, they are discussed in more detail<br />

under the following headings.<br />

Reduce TCO of IT Plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m<br />

TCO of a system includes not <strong>on</strong>ly the price of purchasing software and hardware, but<br />

also the cost of training users and supporting and maintaining the system. There<str<strong>on</strong>g>for</str<strong>on</strong>g>e,<br />

while evaluating the TCO of any system, there are several fac<strong>to</strong>rs <strong>to</strong> c<strong>on</strong>sider.<br />

● Cost of hardware. Evaluate the cost of server hardware, networking equipment<br />

such as hubs and routers, and other equipment. Also include facilities cost <str<strong>on</strong>g>for</str<strong>on</strong>g><br />

hosting the hardware.<br />

● Cost of software. Evaluate the cost of all software including the operating system<br />

and applicati<strong>on</strong>s, such as database systems, developer <strong>to</strong>ols, and management<br />

software.<br />

● Reliability of the system. If the system fails or crashes often, the support cost <str<strong>on</strong>g>for</str<strong>on</strong>g><br />

such a system would increase.<br />

● Cost of system maintenance. System administrati<strong>on</strong> is single highest cost fac<strong>to</strong>r<br />

<str<strong>on</strong>g>for</str<strong>on</strong>g> any IT organizati<strong>on</strong>. Evaluate the staff strength needed and associated costs<br />

<str<strong>on</strong>g>for</str<strong>on</strong>g> maintaining the system.<br />

● Cost of supporting the users. Users may need extensive training and frequent<br />

support, significantly adding <strong>to</strong> the TCO.<br />

● Projected cost of the migrati<strong>on</strong> project itself. Fac<strong>to</strong>rs such as availability of<br />

skills in-house versus hiring external c<strong>on</strong>sultants will influence the project cost. You<br />

will be able <strong>to</strong> estimate these costs better after completing the Planning Phase.<br />

Microsoft offers several soluti<strong>on</strong>s <strong>to</strong> help reduce TCO.<br />

For example, Microsoft Visual Studio .NET provides an Integrated Development<br />

Envir<strong>on</strong>ment (IDE) <str<strong>on</strong>g>for</str<strong>on</strong>g> rapid development of applicati<strong>on</strong>s that reduces the cost of<br />

developing and upgrading applicati<strong>on</strong>s. The Windows graphical user interface (GUI)<br />

envir<strong>on</strong>ment provides an easy-<strong>to</strong>-use interface <str<strong>on</strong>g>for</str<strong>on</strong>g> Windows users. The Windows<br />

standard GUI and GUI-based management applicati<strong>on</strong>s simplify server administrati<strong>on</strong><br />

and thus c<strong>on</strong>tribute <strong>to</strong> reducing support costs.<br />

For more in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> about TCO <strong>on</strong> the Windows plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m, refer <strong>to</strong><br />

http://www.microsoft.com/business/reducecosts/efficiency/c<strong>on</strong>solidate/tco.mspx.<br />

For cus<strong>to</strong>mer case studies about reduced TCO <strong>on</strong> a Windows plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m, refer <strong>to</strong><br />

http://www.microsoft.com/business/reducecosts/efficiency/c<strong>on</strong>solidate/casestudies.mspx<br />

#EBAA.


16<br />

Envisi<strong>on</strong>ing Phase<br />

Maximize ROI<br />

TCO is c<strong>on</strong>cerned with an organizati<strong>on</strong>’s bot<strong>to</strong>m-line (cutting costs), and ROI is related <strong>to</strong><br />

the <strong>to</strong>p line (increasing revenue). A lowered TCO and increased ROI scenario is the<br />

ultimate goal of any migrati<strong>on</strong> project. To estimate the ROI due <strong>to</strong> the migrati<strong>on</strong> ef<str<strong>on</strong>g>for</str<strong>on</strong>g>t,<br />

you should take in<strong>to</strong> account the following c<strong>on</strong>siderati<strong>on</strong>s:<br />

● Creati<strong>on</strong> of new business opportunities. The migrati<strong>on</strong> may provide new<br />

technological capabilities and drive new business innovati<strong>on</strong>s that lead <strong>to</strong><br />

increased revenue.<br />

● Opportunities created by improved per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance. For example, a faster<br />

resp<strong>on</strong>se time <strong>to</strong> <strong>on</strong>line users <strong>on</strong> a Web site can drive more satisfied cus<strong>to</strong>mers <strong>to</strong><br />

the site and increase profitability.<br />

● Total downtime required <strong>to</strong> complete the migrati<strong>on</strong>. System downtime can<br />

affect revenue and should be minimized.<br />

● Reliability of the system. Unplanned system downtime can negatively affect<br />

productivity and revenue.<br />

● Time <strong>to</strong> recover investment costs. The business needs <strong>to</strong> understand how l<strong>on</strong>g<br />

it expects <strong>to</strong> realize a return <strong>on</strong> the investment in the project.<br />

● Impact <strong>on</strong> user productivity due <strong>to</strong> the migrati<strong>on</strong>. If users are going <strong>to</strong> take a<br />

l<strong>on</strong>g time <strong>to</strong> ramp up <strong>on</strong> the new technology, it can impact the near term<br />

productivity and profitability of the organizati<strong>on</strong>. Productivity can also be affected<br />

positively by easing the integrati<strong>on</strong> between the database applicati<strong>on</strong> and other<br />

office software.<br />

● Managing risk. The organizati<strong>on</strong> needs <strong>to</strong> evaluate the risk of doing the project as<br />

well as not doing the project. Not taking the risk may be the path of least<br />

resistance, but it may deprive you of significant revenue opportunities. Proven best<br />

practices and processes can minimize risk and make the migrati<strong>on</strong> more<br />

predictable. Several system integra<strong>to</strong>rs (SIs) offer service offerings that can greatly<br />

mitigate the risk. The SIs who are known <strong>to</strong> offer <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>to</strong> <strong>SQL</strong> migrati<strong>on</strong><br />

offerings, as of publishing this soluti<strong>on</strong>, are listed in the "Set Up a Team" secti<strong>on</strong><br />

later in this chapter.<br />

Some of the questi<strong>on</strong>s that result from these c<strong>on</strong>siderati<strong>on</strong>s can be answered by<br />

analysis. However, a proof-of-c<strong>on</strong>cept or a limited pilot exercise can help provide<br />

quantifiable answers <strong>to</strong> these questi<strong>on</strong>s, including estimating applicati<strong>on</strong> migrati<strong>on</strong> costs<br />

and determining the reliability of software. More in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> is available in the "Technical<br />

Proof of C<strong>on</strong>cept" secti<strong>on</strong> of Chapter 3, "Planning Phase."<br />

Identify the Design Goals<br />

Design goals are similar <strong>to</strong> business goals in many ways. The difference is that design<br />

goals focus more <strong>on</strong> the attributes of the soluti<strong>on</strong> and less <strong>on</strong> what the soluti<strong>on</strong> will<br />

accomplish <str<strong>on</strong>g>for</str<strong>on</strong>g> the business. As with business goals, an organizati<strong>on</strong>'s design goals are<br />

unique and specific <strong>to</strong> that organizati<strong>on</strong>. For example, <strong>on</strong>e organizati<strong>on</strong> may determine<br />

that “corporate data should be accessible from the mobile devices issued <strong>to</strong> company<br />

employees.” A different organizati<strong>on</strong>'s primary design goal may be <strong>to</strong> “reduce the time<br />

and level of ef<str<strong>on</strong>g>for</str<strong>on</strong>g>t required <str<strong>on</strong>g>for</str<strong>on</strong>g> a user <strong>to</strong> c<strong>on</strong>nect <strong>to</strong> the server and complete a task.” This<br />

guide does not provide a specific list of design goals. Your organizati<strong>on</strong> will have <strong>to</strong><br />

determine the design goals specific <strong>to</strong> it. However, the following list provides the six most<br />

comm<strong>on</strong> and generic design goals <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>UNIX</strong> <strong>to</strong> Windows migrati<strong>on</strong> projects.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 17<br />

●<br />

●<br />

●<br />

●<br />

High availability and reliability. The soluti<strong>on</strong> should process requests without<br />

interrupti<strong>on</strong>, even in the event of a failure. For more in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <strong>on</strong> Windows<br />

reliability, refer <strong>to</strong> http://www.microsoft.com/mscorp/twc/reliability/default.mspx<br />

<strong>SQL</strong> <strong>Server</strong> allows <str<strong>on</strong>g>for</str<strong>on</strong>g> servers <strong>to</strong> be clustered in<strong>to</strong> groups of c<strong>on</strong>nected nodes. The<br />

soluti<strong>on</strong> described in this guide provides high availability <str<strong>on</strong>g>for</str<strong>on</strong>g> business applicati<strong>on</strong>s.<br />

If there is a failure of the operating system, hardware, or any planned upgrade<br />

event <strong>on</strong> a single machine, <strong>SQL</strong> <strong>Server</strong> can be c<strong>on</strong>figured <strong>to</strong> fail over <strong>to</strong> another<br />

node, minimizing down time. For more in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> about <strong>SQL</strong> <strong>Server</strong> clustering,<br />

refer <strong>to</strong> http://www.microsoft.com/resources/documentati<strong>on</strong>/sql/2000/all/reskit/enus/part4/c1261.mspx.<br />

Robust security. In business, data security is vital. Launched under the<br />

Trustworthy Computing Initiative, Windows <strong>Server</strong> 2003 was designed with an<br />

emphasis <strong>on</strong> security.<br />

Many new features have been added, including support <str<strong>on</strong>g>for</str<strong>on</strong>g> str<strong>on</strong>g authenticati<strong>on</strong><br />

pro<strong>to</strong>cols such as Kerberos, 802.11x (WiFi) and Internet Pro<strong>to</strong>col Security (IPSec).<br />

For more in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> about Windows <strong>Server</strong> 2003 security, refer <strong>to</strong><br />

http://www.microsoft.com/windowsserver2003/technologies/security.<br />

For more in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> about <strong>SQL</strong> <strong>Server</strong> 2000 security, refer <strong>to</strong> the following three<br />

resources:<br />

http://www.microsoft.com/technet/prodtechnol/sql/2000/maintain/sp3sec01.mspx<br />

http://www.microsoft.com/sql/techinfo/administrati<strong>on</strong>/2000/security/default.asp<br />

http://www.microsoft.com/sql/evaluati<strong>on</strong>/features/security.asp<br />

High per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance and scalability. The system should show an acceptable level<br />

of per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance even when the number of users increases.<br />

<strong>SQL</strong> <strong>Server</strong> 2000 can support multi-terabyte databases served <strong>to</strong> milli<strong>on</strong>s of users.<br />

This scalability is achieved by supporting scale up <strong>on</strong> symmetric multiprocessor<br />

(SMP) systems, allowing the installati<strong>on</strong> of additi<strong>on</strong>al processors, memory, disks<br />

and networking <strong>to</strong> build a large single node. In additi<strong>on</strong>, <strong>SQL</strong> <strong>Server</strong> supports scale<br />

out, or allowing large databases <strong>to</strong> be split between a cluster of servers. Each<br />

server s<strong>to</strong>res a porti<strong>on</strong> of the database and assists in processing functi<strong>on</strong>s. For<br />

more in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> about Windows per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance and scalability, refer <strong>to</strong> the following<br />

two resources:<br />

http://www.microsoft.com/windowsserver2003/evaluati<strong>on</strong>/per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance/default.msp<br />

x<br />

http://www.microsoft.com/windowsserver2003/techinfo/serverroles/appserver/scale<br />

.mspx<br />

For more in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> about <strong>SQL</strong> <strong>Server</strong> per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance and scalability, refer <strong>to</strong> the<br />

following two resources:<br />

http://www.microsoft.com/technet/prodtechnol/sql/2000/plan/ssmsam.mspx<br />

http://www.microsoft.com/sql/evaluati<strong>on</strong>/compare/benchmarks.asp<br />

Easy manageability. The system should provide easy ways <str<strong>on</strong>g>for</str<strong>on</strong>g> the administra<strong>to</strong>rs<br />

<strong>to</strong> install, manage, and maintain the operating system, applicati<strong>on</strong> software, and<br />

updates. For more in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <strong>on</strong> management products from Microsoft, refer <strong>to</strong><br />

http://www.microsoft.com/management/default.mspx.<br />

<strong>SQL</strong> <strong>Server</strong> provides a number of robust administrati<strong>on</strong> <strong>to</strong>ols <str<strong>on</strong>g>for</str<strong>on</strong>g> managing data.<br />

Tools include graphic administrati<strong>on</strong> <strong>to</strong>ols, task wizards, and command line utilities.<br />

For detailed in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> about the <strong>SQL</strong> <strong>Server</strong> <strong>to</strong>ol set, refer <strong>to</strong> the following two<br />

resources:<br />

http://www.microsoft.com/technet/prodtechnol/sql/2000/books/c01ppcsq.mspx


18<br />

Envisi<strong>on</strong>ing Phase<br />

●<br />

●<br />

http://msdn.microsoft.com/library/default.asp?url=/library/enus/use<strong>to</strong>ols/use<strong>to</strong>ols_4ovn.asp<br />

C<strong>on</strong>solidati<strong>on</strong> of servers. The new system should allow <str<strong>on</strong>g>for</str<strong>on</strong>g> the c<strong>on</strong>solidati<strong>on</strong> of<br />

existing databases in<strong>to</strong> a small number of servers. If the existing soluti<strong>on</strong> is based<br />

<strong>on</strong> older hardware, a migrati<strong>on</strong> presents an opportunity <strong>to</strong> c<strong>on</strong>solidate <strong>to</strong> fewer and<br />

more powerful servers.<br />

For more in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> about Windows <strong>Server</strong> 2003 Datacenter Editi<strong>on</strong> — the<br />

Microsoft server operating system optimized <str<strong>on</strong>g>for</str<strong>on</strong>g> server c<strong>on</strong>solidati<strong>on</strong> — refer <strong>to</strong><br />

http://www.microsoft.com/windowsserver2003/datacenter/default.mspx.<br />

Interoperability with the existing <strong>UNIX</strong> plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m. The new system should<br />

integrate with the existing applicati<strong>on</strong>s and infrastructure <strong>on</strong> the <strong>UNIX</strong> plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m. For<br />

more in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> about Windows interoperability with <strong>UNIX</strong>, refer <strong>to</strong><br />

http://www.microsoft.com/sfu.<br />

For a detailed comparis<strong>on</strong> of the system abilities of existing <strong>UNIX</strong> systems and<br />

Windows <strong>Server</strong> 2003 and <strong>SQL</strong> <strong>Server</strong> 2000, refer <strong>to</strong><br />

http://go.microsoft.com/fwlink/?linkid=37907<br />

Create the Problem Statement<br />

A problem statement is usually a short narrative describing the specific issues that the<br />

business hopes <strong>to</strong> address with the project. It relates primarily <strong>to</strong> the current state of<br />

business activities and is a direct result of the business goals or design goals not being<br />

met adequately. The more precisely the problem statement is recorded, the easier it will<br />

be <strong>to</strong> measure the success of the project.<br />

Because the aim of the project is <strong>to</strong> solve a problem, the understanding of the problem<br />

determines the design of the soluti<strong>on</strong>. A good problem statement provides sufficient<br />

in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> about the business problem <str<strong>on</strong>g>for</str<strong>on</strong>g> a new team member <strong>to</strong> use the problem<br />

statement and the rest of the documentati<strong>on</strong> <strong>to</strong> put the project in<strong>to</strong> c<strong>on</strong>text.<br />

The following are some examples of problem statements that may be relevant in an<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows migrati<strong>on</strong> project:<br />

● Cus<strong>to</strong>mer support cannot effectively process the high number of cus<strong>to</strong>mer calls<br />

because of the time it takes <str<strong>on</strong>g>for</str<strong>on</strong>g> them <strong>to</strong> retrieve cus<strong>to</strong>mer data from the existing<br />

cus<strong>to</strong>mer database.<br />

● Product managers cannot make in<str<strong>on</strong>g>for</str<strong>on</strong>g>med decisi<strong>on</strong>s about sales promoti<strong>on</strong>s<br />

because they do not have recent sales trends.<br />

Create the Visi<strong>on</strong> Statement<br />

The visi<strong>on</strong> statement addresses the problem statement and establishes a comm<strong>on</strong> visi<strong>on</strong><br />

of the end state that can be shared am<strong>on</strong>g team members. While brief, this statement<br />

provides a comm<strong>on</strong> starting point <str<strong>on</strong>g>for</str<strong>on</strong>g> future decisi<strong>on</strong>s throughout the rest of the project.<br />

A good visi<strong>on</strong> statement has the following characteristics:<br />

● Specific. A visi<strong>on</strong> statement should be specific and include the ideal state of the<br />

business problem soluti<strong>on</strong> so that the end result is meaningful.<br />

● Measurable. By creating a visi<strong>on</strong> statement that is measurable, the project team<br />

can determine the degree of success at the completi<strong>on</strong> of the project.<br />

● Achievable. Given the resources, the time frame, and the skills of the team<br />

members, the visi<strong>on</strong> statement should be achievable. An achievable and<br />

challenging visi<strong>on</strong> statement can motivate team members.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 19<br />

●<br />

●<br />

Relevant. The visi<strong>on</strong> statement should relate <strong>to</strong> the business problem being<br />

addressed. If not, the project team might realize that they are solving the wr<strong>on</strong>g<br />

problem, or <strong>on</strong>e that does not exist, and — in the process — lose sp<strong>on</strong>sorship.<br />

Time-based. The visi<strong>on</strong> statement should clearly indicate the estimated time frame<br />

<str<strong>on</strong>g>for</str<strong>on</strong>g> the delivery of the soluti<strong>on</strong>.<br />

The following two examples are visi<strong>on</strong> statements <str<strong>on</strong>g>for</str<strong>on</strong>g> an <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong><br />

<strong>on</strong> Windows migrati<strong>on</strong> project:<br />

● Be<str<strong>on</strong>g>for</str<strong>on</strong>g>e the end of the year, our cus<strong>to</strong>mer support staff will be able <strong>to</strong> retrieve all<br />

cus<strong>to</strong>mer data and account his<strong>to</strong>ry within three sec<strong>on</strong>ds of the cus<strong>to</strong>mer identifying<br />

himself or herself.<br />

● Be<str<strong>on</strong>g>for</str<strong>on</strong>g>e the start of the next fiscal year, our product managers will have access <strong>to</strong><br />

daily sales reports from all the showrooms in the country.<br />

Define the User Profiles<br />

Understanding the users <str<strong>on</strong>g>for</str<strong>on</strong>g> whom the soluti<strong>on</strong> is being developed is critical <strong>to</strong> the<br />

project's success. To capture a clear descripti<strong>on</strong> of each user, the team creates profiles<br />

of each user class. The process of profiling develops a set of user requirements. The<br />

combinati<strong>on</strong> of these user requirements with the business and design requirements will<br />

help <strong>to</strong> define the project scope later in the Envisi<strong>on</strong>ing Phase.<br />

In an <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows migrati<strong>on</strong> project, the most important<br />

profiles are that of the system managers and users of the migrated applicati<strong>on</strong>. C<strong>on</strong>sider<br />

the following while profiling the user types:<br />

● Proficiency of the users in using Microsoft applicati<strong>on</strong>s and the Windows<br />

envir<strong>on</strong>ment. Administra<strong>to</strong>rs largely use command line <strong>to</strong>ols in the <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>/<strong>UNIX</strong><br />

world. While Windows also provides some command line interfaces, Windows<br />

<strong>to</strong>ols tend <strong>to</strong> be graphical user interfaces (GUIs). Users new <strong>to</strong> the Windows<br />

envir<strong>on</strong>ment may need training.<br />

● The type of tasks that the users will per<str<strong>on</strong>g>for</str<strong>on</strong>g>m <strong>on</strong> the new system.<br />

● Essential expectati<strong>on</strong>s of the end user from the current applicati<strong>on</strong> interface that<br />

will have <strong>to</strong> be met in the new envir<strong>on</strong>ment.<br />

● The language localizati<strong>on</strong> needs <str<strong>on</strong>g>for</str<strong>on</strong>g> the end users, if necessary. C<strong>on</strong>sider the GUI<br />

as well as user documentati<strong>on</strong>.<br />

● The physical locati<strong>on</strong> of the end users. Fac<strong>to</strong>rs such as locati<strong>on</strong>s, number of users<br />

at each locati<strong>on</strong>, and the bandwidth and usage of network links between the sites<br />

should be unders<strong>to</strong>od and documented.<br />

Assess the Current Situati<strong>on</strong> (High Level)<br />

Organizati<strong>on</strong>s planning an <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows migrati<strong>on</strong> need <strong>to</strong><br />

c<strong>on</strong>sider the following five entities <str<strong>on</strong>g>for</str<strong>on</strong>g> a successful migrati<strong>on</strong>. While these entities are<br />

assessed in detail in the Planning Phase of the project, a high level preliminary<br />

assessment is essential in the Envisi<strong>on</strong>ing Phase <strong>to</strong> evaluate the feasibility of the project.<br />

● Applicati<strong>on</strong><br />

This entity includes the target applicati<strong>on</strong>s that are migrati<strong>on</strong> candidates. While<br />

assessing applicati<strong>on</strong>s, the following questi<strong>on</strong>s should be asked:<br />

● Which are the specific applicati<strong>on</strong>s that are <strong>to</strong> be migrated?<br />

● What languages are these applicati<strong>on</strong>s written in?


20<br />

Envisi<strong>on</strong>ing Phase<br />

●<br />

●<br />

●<br />

If there are cus<strong>to</strong>m applicati<strong>on</strong>s <strong>to</strong> be migrated, is the source code available?<br />

Are the developers of the applicati<strong>on</strong> still a part of the team?<br />

Do the applicati<strong>on</strong>s <strong>to</strong> be migrated interoperate with other applicati<strong>on</strong>s or<br />

systems?<br />

●<br />

●<br />

●<br />

●<br />

Database<br />

This entity includes the <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> databases that need <strong>to</strong> be migrated <strong>to</strong> <strong>SQL</strong> <strong>Server</strong>.<br />

The following are some of the high level questi<strong>on</strong>s you need <strong>to</strong> ask:<br />

●<br />

●<br />

●<br />

●<br />

Do your existing databases implement specialized features of <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> or any<br />

other third-party cus<strong>to</strong>mizati<strong>on</strong>s <strong>to</strong> provide additi<strong>on</strong>al database features?<br />

Are the databases that need <strong>to</strong> be migrated shared by multiple applicati<strong>on</strong>s?<br />

What are the sizes of the databases being migrated?<br />

What is the user populati<strong>on</strong> of the databases?<br />

Applicati<strong>on</strong> infrastructure<br />

This entity includes server and network-related resources, such as compute nodes,<br />

s<strong>to</strong>rage, file systems, routers, firewalls, hubs, and so <strong>on</strong>. The following are some of<br />

the questi<strong>on</strong>s you need <strong>to</strong> ask <strong>to</strong> assess the current state:<br />

● Do you already have an existing infrastructure based <strong>on</strong> Windows that can be<br />

readily used or expanded, or do you have <strong>to</strong> set up the infrastructure from<br />

scratch?<br />

● What are the other external systems, such as those of your partners or clients,<br />

that would be impacted by the migrati<strong>on</strong>?<br />

Microsoft provides a standardized infrastructure architecture named Windows<br />

<strong>Server</strong> System Reference Architecture (WSSRA). WSSRA provides lab and real<br />

world tested, architectural blueprints and proven best practices <strong>to</strong> design and<br />

implement enterprise infrastructure soluti<strong>on</strong>s with minimal risk and cost. The<br />

guidance addresses infrastructure issues including availability, security, scalability,<br />

and manageability of the plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m in a fully integrated fashi<strong>on</strong>. For detailed<br />

in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <strong>on</strong> WSSRA, refer <strong>to</strong><br />

http://www.microsoft.com/windowsserversystem/overview/referencearchitecture.ms<br />

px.<br />

Development envir<strong>on</strong>ment<br />

This entity includes software c<strong>on</strong>structi<strong>on</strong> envir<strong>on</strong>ments such as the <strong>UNIX</strong> make<br />

envir<strong>on</strong>ment, developer <strong>to</strong>ols, and so <strong>on</strong>. Migrati<strong>on</strong> of the database and data can<br />

be achieved by using <strong>to</strong>ols bundled with <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong>, such as<br />

<strong>SQL</strong>*Plus, Enterprise Manager, and Query Analyzer. Microsoft offers a set of <strong>to</strong>ols<br />

called <strong>SQL</strong> <strong>Server</strong> Migrati<strong>on</strong> Assistant <str<strong>on</strong>g>for</str<strong>on</strong>g> migrating <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> databases <strong>to</strong><br />

<strong>SQL</strong> <strong>Server</strong>.<br />

Questi<strong>on</strong>s <strong>to</strong> ask while assessing the development envir<strong>on</strong>ment include:<br />

● What is the software c<strong>on</strong>structi<strong>on</strong> envir<strong>on</strong>ment that you have <strong>to</strong> build the <strong>UNIX</strong><br />

applicati<strong>on</strong>s? A comm<strong>on</strong>ly used software c<strong>on</strong>structi<strong>on</strong> mechanism is the use of<br />

makefiles. For detailed process and technical guidance <strong>on</strong> using a makebased<br />

build envir<strong>on</strong>ment <strong>to</strong> build Windows executables, refer <strong>to</strong><br />

http://go.microsoft.com/fwlink/?LinkId=22225<br />

● Are the required licenses <str<strong>on</strong>g>for</str<strong>on</strong>g> the appropriate <strong>SQL</strong> <strong>Server</strong> editi<strong>on</strong> available?<br />

● What are the server, s<strong>to</strong>rage, and network resources <strong>to</strong> support the<br />

development and testing activities?<br />

Existing documentati<strong>on</strong>


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 21<br />

This entity includes end user documentati<strong>on</strong>, requirements analysis, functi<strong>on</strong>al<br />

specificati<strong>on</strong>s, design documents, and so <strong>on</strong>. The existing documentati<strong>on</strong> should<br />

be scrutinized as part of the task of assessing your current envir<strong>on</strong>ment. This is<br />

something that is often overlooked. Existing design documentati<strong>on</strong> is a valuable<br />

resource <str<strong>on</strong>g>for</str<strong>on</strong>g> building project documents and plans, especially when a large porti<strong>on</strong><br />

of the existing functi<strong>on</strong>ality is carried over <strong>to</strong> the new soluti<strong>on</strong>. Developing test<br />

plans and test cases <str<strong>on</strong>g>for</str<strong>on</strong>g> the new applicati<strong>on</strong> based up<strong>on</strong> existing documentati<strong>on</strong> is<br />

especially useful. Modificati<strong>on</strong>s <strong>to</strong> existing documentati<strong>on</strong> are almost certainly<br />

needed <strong>to</strong> support the migrated soluti<strong>on</strong>. One problem often encountered is that<br />

the existing documentati<strong>on</strong> is incorrect or insufficient, which may <str<strong>on</strong>g>for</str<strong>on</strong>g>ce the<br />

migrati<strong>on</strong> project <strong>to</strong> absorb the ef<str<strong>on</strong>g>for</str<strong>on</strong>g>t of bringing it up <strong>to</strong> date.<br />

These are some of the questi<strong>on</strong>s that you need <strong>to</strong> ask:<br />

● Are the original requirements <str<strong>on</strong>g>for</str<strong>on</strong>g> each of the applicati<strong>on</strong>s <strong>to</strong> be migrated<br />

available?<br />

● Are database and applicati<strong>on</strong> design (high level as well as detailed) documents<br />

available?<br />

● Are the logical and physical data models available <str<strong>on</strong>g>for</str<strong>on</strong>g> all databases <strong>to</strong> be<br />

migrated?<br />

● Is documentati<strong>on</strong> <str<strong>on</strong>g>for</str<strong>on</strong>g> the applicati<strong>on</strong> code maintained?<br />

● Are user manuals available <str<strong>on</strong>g>for</str<strong>on</strong>g> client applicati<strong>on</strong>s?<br />

● Are training documents available <str<strong>on</strong>g>for</str<strong>on</strong>g> support, end users, and operati<strong>on</strong>s<br />

pers<strong>on</strong>nel?<br />

●<br />

Applicati<strong>on</strong> users<br />

User accounts that exist in the <strong>UNIX</strong> domain need <strong>to</strong> be migrated or recreated in<br />

the Windows-based domain al<strong>on</strong>g with the necessary permissi<strong>on</strong>s <str<strong>on</strong>g>for</str<strong>on</strong>g> users <strong>to</strong> start<br />

using the applicati<strong>on</strong> <strong>on</strong> the Windows domain. Ask the following questi<strong>on</strong>s:<br />

● What security services are in use (examples include local, Kerberos, NIS,<br />

NIS+, and LDAP)?<br />

● What is the authenticati<strong>on</strong> method in use (examples include password, digital<br />

certificate, and so <strong>on</strong>)?<br />

● What authority does the user have <strong>on</strong> the system?<br />

● How is authorizati<strong>on</strong> implemented?<br />

● What activities of the users are audited?<br />

● Are users required <strong>to</strong> use secure communicati<strong>on</strong> methods such as SSH?<br />

● Are applicati<strong>on</strong> users authenticated by the operating system as well as by the<br />

database?<br />

For prescriptive guidance <strong>on</strong> how <strong>to</strong> enable Windows <strong>Server</strong> 2003 <strong>to</strong> be used <str<strong>on</strong>g>for</str<strong>on</strong>g><br />

authenticati<strong>on</strong> and as an identity s<strong>to</strong>re within Windows and <strong>UNIX</strong> envir<strong>on</strong>ments,<br />

refer <strong>to</strong> http://go.microsoft.com/fwlink/?LinkId=23120.<br />

Note The primary purpose of this soluti<strong>on</strong> is <strong>to</strong> provide guidance <strong>on</strong> migrating the<br />

applicati<strong>on</strong>s and databases from an <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> envir<strong>on</strong>ment <strong>to</strong> a <strong>SQL</strong> <strong>Server</strong> <strong>on</strong><br />

Windows envir<strong>on</strong>ment. The discussi<strong>on</strong>s about migrating the infrastructure, development<br />

envir<strong>on</strong>ment, user accounts, and documentati<strong>on</strong> are, there<str<strong>on</strong>g>for</str<strong>on</strong>g>e, limited in this soluti<strong>on</strong>.<br />

The discussi<strong>on</strong>s have been included <strong>to</strong> provide readers a holistic perspective of the<br />

migrati<strong>on</strong>. Pointers <strong>to</strong> other resources that provide more in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong>, including<br />

prescriptive guidance, are provided when relevant.


22<br />

Envisi<strong>on</strong>ing Phase<br />

Figure 2.1 represents the primary entities involved in an <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong><br />

<strong>on</strong> Windows migrati<strong>on</strong>. To reiterate: this guide provides prescriptive guidance <str<strong>on</strong>g>for</str<strong>on</strong>g><br />

migrating the applicati<strong>on</strong>, database, and applicati<strong>on</strong> infrastructure entities <strong>on</strong>ly.<br />

In<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> about the other entities is available from the sources cited earlier.<br />

Figure 2.1<br />

Primary Migrati<strong>on</strong> Entities<br />

Capture High Level Requirements<br />

An important task in the Envisi<strong>on</strong>ing Phase is <strong>to</strong> document the high-level business, user,<br />

and design requirements. These requirements are refined further in the c<strong>on</strong>ceptual<br />

design stage of the Planning Phase (discussed in Chapter 3, "Planning Phase").<br />

A comm<strong>on</strong> way of gathering and analyzing in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> is through developing use-cases<br />

and building usage scenarios <strong>to</strong> document the business processes and user<br />

requirements. While use cases describe the high level interacti<strong>on</strong>s between an individual<br />

and the system, usage scenarios provide additi<strong>on</strong>al in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> about the activities and<br />

task sequences that c<strong>on</strong>stitute a process.<br />

A detailed discussi<strong>on</strong> of use-case analysis is out of scope of this soluti<strong>on</strong>. Please refer <strong>to</strong><br />

the following resource <str<strong>on</strong>g>for</str<strong>on</strong>g> additi<strong>on</strong>al guidance: Advanced Use Case Modeling (Armour<br />

and Miller, 2000).<br />

Define the Project Scope<br />

One of the critical fac<strong>to</strong>rs in the success of a project is clearly defining the scope of the<br />

project. Scope defines what will be and what will not be included in the project. The<br />

scope uses the high level requirements gathered earlier in the Envisi<strong>on</strong>ing Phase and<br />

incorporates the c<strong>on</strong>straints imposed <strong>on</strong> the project by resources, schedule, budget, and<br />

other limiting fac<strong>to</strong>rs. A good way of scoping is <strong>to</strong> address use cases and usage<br />

scenarios that impact the business the most.<br />

As with the business and design goals, the scope <str<strong>on</strong>g>for</str<strong>on</strong>g> projects is organizati<strong>on</strong>-specific,<br />

and you will need <strong>to</strong> determine the scope <str<strong>on</strong>g>for</str<strong>on</strong>g> your project and document it in the


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 23<br />

visi<strong>on</strong>/scope document. However, when producing the scope <str<strong>on</strong>g>for</str<strong>on</strong>g> your <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong><br />

<strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows migrati<strong>on</strong> project, some general guidelines should be followed:<br />

●<br />

●<br />

●<br />

●<br />

●<br />

●<br />

●<br />

C<strong>on</strong>sider a multiphase approach <strong>to</strong> the migrati<strong>on</strong>. In the first phase, c<strong>on</strong>sider<br />

migrating <strong>on</strong>ly the database and rec<strong>on</strong>nect the <strong>UNIX</strong> applicati<strong>on</strong>s <strong>to</strong> c<strong>on</strong>nect <strong>to</strong><br />

<strong>SQL</strong> <strong>Server</strong>. Limiting the scope <str<strong>on</strong>g>for</str<strong>on</strong>g> each phase of the migrati<strong>on</strong> increases your<br />

ability <strong>to</strong> m<strong>on</strong>i<strong>to</strong>r and measure the migrati<strong>on</strong> project's success.<br />

C<strong>on</strong>sider migrating the portable applicati<strong>on</strong>s first. These include applicati<strong>on</strong>s<br />

written using Java, Perl, PHP, and Pyth<strong>on</strong>. Portable applicati<strong>on</strong>s can usually be<br />

ported or c<strong>on</strong>figured <strong>to</strong> interoperate with relative ease, and this helps build user<br />

and management c<strong>on</strong>fidence.<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms and Pro*C applicati<strong>on</strong>s are the hardest <strong>to</strong> migrate because they<br />

have <strong>to</strong> be rewritten; per<str<strong>on</strong>g>for</str<strong>on</strong>g>m them in a later phase, if possible.<br />

The migrati<strong>on</strong> of code present in the database in the <str<strong>on</strong>g>for</str<strong>on</strong>g>m of triggers, functi<strong>on</strong>s,<br />

s<strong>to</strong>red procedures, and packages impacts the migrati<strong>on</strong> of applicati<strong>on</strong>s that are<br />

dependent <strong>on</strong> them. As a result, these have <strong>to</strong> be migrated first.<br />

Databases using advanced <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> functi<strong>on</strong>ality, such as advanced queuing, Java<br />

packages, objects, and so <strong>on</strong> are more difficult <strong>to</strong> migrate, and a proof-of-c<strong>on</strong>cept<br />

should be created <strong>to</strong> verify the soluti<strong>on</strong>.<br />

Smaller databases with less stringent requirements <strong>on</strong> per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance and availability<br />

should be migrated be<str<strong>on</strong>g>for</str<strong>on</strong>g>e attempting larger <strong>on</strong>es.<br />

To reduce the complexity, migrati<strong>on</strong> at the schema level should be c<strong>on</strong>sidered<br />

where feasible instead of entire databases.<br />

Define the <str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> C<strong>on</strong>cept<br />

The soluti<strong>on</strong> c<strong>on</strong>cept outlines the high level approach the team will take <strong>to</strong> meet the goals<br />

of the project and provides the basis <str<strong>on</strong>g>for</str<strong>on</strong>g> proceeding <strong>to</strong> the Planning Phase. This<br />

approach includes the assessment of technologies, development, test, quality assurance,<br />

training, deployment, release, operati<strong>on</strong>s and so <strong>on</strong>. These approaches can be<br />

developed in<strong>to</strong> full-fledged plans in the Planning Phase. Because the soluti<strong>on</strong> c<strong>on</strong>cept<br />

focuses <strong>on</strong> the c<strong>on</strong>cepts and not the details, it is not very technical.<br />

The soluti<strong>on</strong> c<strong>on</strong>cept also includes a high-level soluti<strong>on</strong> design strategy <str<strong>on</strong>g>for</str<strong>on</strong>g> all the<br />

software and hardware comp<strong>on</strong>ents of the system. Because the primary focus of this<br />

soluti<strong>on</strong> is migrating the <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> databases and associated applicati<strong>on</strong>s <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong><br />

Windows, the rest of this secti<strong>on</strong> discusses <strong>on</strong>ly soluti<strong>on</strong> design strategies <str<strong>on</strong>g>for</str<strong>on</strong>g> the<br />

database and applicati<strong>on</strong>s.<br />

Applicati<strong>on</strong> and Database Migrati<strong>on</strong> <str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> Design<br />

Strategy<br />

For the purposes of explanati<strong>on</strong>, the applicati<strong>on</strong> and database ecosystem can be viewed<br />

in terms of three comp<strong>on</strong>ents:<br />

● Applicati<strong>on</strong>. This comp<strong>on</strong>ent includes applicati<strong>on</strong>s written in a variety of<br />

programming languages, including <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms, Perl, Pyth<strong>on</strong>, and so <strong>on</strong>.<br />

● C<strong>on</strong>nectivity interface. This is the intermediate tier between the applicati<strong>on</strong> and the<br />

database. The c<strong>on</strong>nectivity tier is also referred <strong>to</strong> as the applicati<strong>on</strong> programming<br />

interface (API). This layer facilitates the communicati<strong>on</strong> between the applicati<strong>on</strong><br />

and the database. <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong> support different c<strong>on</strong>nectivity interfaces,<br />

some proprietary and some standard. <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Call Interface (OCI) is an example of<br />

a proprietary interface <str<strong>on</strong>g>for</str<strong>on</strong>g> an applicati<strong>on</strong> <strong>to</strong> communicate with <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>. Object


24<br />

Envisi<strong>on</strong>ing Phase<br />

●<br />

Database C<strong>on</strong>nectivity (ODBC) is an example of a standards-based interface. The<br />

available API also differs from <strong>UNIX</strong> <strong>to</strong> Windows.<br />

Database. The database tier c<strong>on</strong>sists of the database management system and<br />

the objects that s<strong>to</strong>re and facilitate access <strong>to</strong> the data in the database.<br />

The relati<strong>on</strong>ship between these three comp<strong>on</strong>ents is shown in Figure 2.2. The<br />

c<strong>on</strong>nectivity interface binds the applicati<strong>on</strong> <strong>to</strong> the database and allows in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <strong>to</strong><br />

pass between them.<br />

Figure 2.2<br />

Applicati<strong>on</strong>, database, and c<strong>on</strong>nectivity tiers<br />

Once the database is migrated from <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong>, there are four different<br />

approaches <strong>to</strong> c<strong>on</strong>nect the applicati<strong>on</strong> <strong>to</strong> the <strong>SQL</strong> <strong>Server</strong> database using an appropriate<br />

c<strong>on</strong>nectivity layer.<br />

1. Interoperati<strong>on</strong><br />

The applicati<strong>on</strong> comp<strong>on</strong>ents remain <strong>on</strong> the <strong>UNIX</strong> plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m.<br />

2. Port or rewrite applicati<strong>on</strong> <strong>to</strong> the .NET plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m<br />

The.NET framework is the next generati<strong>on</strong> plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m from Microsoft <str<strong>on</strong>g>for</str<strong>on</strong>g> building,<br />

deploying, and running Windows applicati<strong>on</strong>s. It provides a standards-based, multilanguage<br />

envir<strong>on</strong>ment <str<strong>on</strong>g>for</str<strong>on</strong>g> integrating existing investments with next-generati<strong>on</strong><br />

applicati<strong>on</strong>s and services.<br />

3. Port or rewrite applicati<strong>on</strong> <strong>to</strong> Win32 plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m<br />

The Win32 API is <strong>on</strong>e of the primary programming interfaces <strong>to</strong> the Windows<br />

operating system family, including Windows 2003. The Win32 API provides<br />

functi<strong>on</strong>s <str<strong>on</strong>g>for</str<strong>on</strong>g> processes, memory management, security, windowing, and graphics.<br />

4. Quick port: port applicati<strong>on</strong> <strong>to</strong> the Windows Services <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>UNIX</strong> 3.5 plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m<br />

Port applicati<strong>on</strong>s <strong>to</strong> an envir<strong>on</strong>ment <strong>on</strong> Windows named Interix, which is similar <strong>to</strong><br />

<strong>UNIX</strong>. Interix is a complete, POSIX-compliant development envir<strong>on</strong>ment that is<br />

tightly integrated with the Windows kernel. It is a part of the Microsoft<br />

Windows Services <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>UNIX</strong> 3.5 product suite from Microsoft.<br />

Each of these four opti<strong>on</strong>s c<strong>on</strong>stitutes a separate design strategy <str<strong>on</strong>g>for</str<strong>on</strong>g> your migrati<strong>on</strong><br />

project, and each of the four is discussed in more detail under the following headings.<br />

One, some, or all of these soluti<strong>on</strong> design strategies will <str<strong>on</strong>g>for</str<strong>on</strong>g>m the basis of the soluti<strong>on</strong><br />

c<strong>on</strong>cept you will produce as a part of completing the Envisi<strong>on</strong>ing Phase. Even when the<br />

goal is <strong>to</strong> standardize <strong>on</strong> the Windows plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m, some of these strategies may be<br />

employed as intermediary steps in a multi-phased migrati<strong>on</strong>. This soluti<strong>on</strong> c<strong>on</strong>cept —<br />

documented in the visi<strong>on</strong>/scope document — will be used <strong>to</strong> develop detailed plans<br />

during the Planning Phase and code during the Developing Phase.<br />

Note Due <strong>to</strong> the complexities inherent in a migrati<strong>on</strong> project, it may not be possible <strong>to</strong><br />

immediately select a migrati<strong>on</strong> strategy. Proof-of-c<strong>on</strong>cept testing may need <strong>to</strong> occur<br />

be<str<strong>on</strong>g>for</str<strong>on</strong>g>e the design strategy is decided up<strong>on</strong>.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 25<br />

<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> Design Strategy A: Interoperability<br />

In this strategy, the applicati<strong>on</strong>s remain <strong>on</strong> the <strong>UNIX</strong> plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m while the database al<strong>on</strong>e is<br />

migrated from <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong>.<br />

Interoperati<strong>on</strong> is preferred in the following situati<strong>on</strong>s:<br />

●<br />

●<br />

●<br />

●<br />

The migrati<strong>on</strong> ef<str<strong>on</strong>g>for</str<strong>on</strong>g>t and risks need <strong>to</strong> be minimized at the expense of not being<br />

able <strong>to</strong> fully realize the benefits of migrating the applicati<strong>on</strong> <strong>to</strong> Windows.<br />

A multiphased approach <str<strong>on</strong>g>for</str<strong>on</strong>g> migrati<strong>on</strong> is more appropriate. The first phase of<br />

migrati<strong>on</strong> could involve migrating the database <strong>on</strong>ly, and later phases could focus<br />

<strong>on</strong> migrating the applicati<strong>on</strong>s.<br />

The needs served by the applicati<strong>on</strong> are static; the evoluti<strong>on</strong> of the applicati<strong>on</strong> is<br />

not a business or design goal of the project.<br />

Maintaining a tight or complex integrati<strong>on</strong> of <strong>UNIX</strong> applicati<strong>on</strong>s with other services<br />

is required.<br />

Interoperati<strong>on</strong> is not recommended in the following situati<strong>on</strong>s:<br />

●<br />

●<br />

●<br />

●<br />

●<br />

The cost of maintaining two envir<strong>on</strong>ments is prohibitive.<br />

The goals of the project include changing the applicati<strong>on</strong> <strong>to</strong> take advantage of the<br />

greater business value of Windows technologies.<br />

Comp<strong>on</strong>ents being <strong>on</strong> two different plat<str<strong>on</strong>g>for</str<strong>on</strong>g>ms do not produce acceptable<br />

per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance or service levels.<br />

The required measure of security cannot be achieved because of disparate<br />

technologies.<br />

When the interoperati<strong>on</strong> is complex and requires huge ef<str<strong>on</strong>g>for</str<strong>on</strong>g>t in development and<br />

implementati<strong>on</strong> as compared <strong>to</strong> employing <strong>on</strong>e of the other methods.<br />

<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> Design Strategy B: Port or Rewrite <strong>to</strong> .NET Framework<br />

When migrating an applicati<strong>on</strong> <strong>to</strong> the .NET framework, there are two different opti<strong>on</strong>s.<br />

One is <strong>to</strong> per<str<strong>on</strong>g>for</str<strong>on</strong>g>m a full port of the applicati<strong>on</strong>, and the other is <strong>to</strong> rewrite the applicati<strong>on</strong><br />

using the .NET applicati<strong>on</strong> programming interfaces (APIs).<br />

A full port is defined as the capability <strong>to</strong> execute the applicati<strong>on</strong> in the Windows<br />

envir<strong>on</strong>ment in its native <str<strong>on</strong>g>for</str<strong>on</strong>g>m. Applicati<strong>on</strong>s written using languages such as Java, Perl,<br />

PHP, and Pyth<strong>on</strong>, which are available <strong>on</strong> both the <strong>UNIX</strong> and Windows plat<str<strong>on</strong>g>for</str<strong>on</strong>g>ms, can<br />

take advantage of a full port. In most cases, <strong>SQL</strong> <strong>Server</strong> database drivers are available<br />

<str<strong>on</strong>g>for</str<strong>on</strong>g> the specific applicati<strong>on</strong> languages. A full port requires minimum changes <strong>to</strong> be d<strong>on</strong>e <strong>to</strong><br />

the source code, and a full port uses standard libraries and utilities that exist <strong>on</strong> the<br />

Windows plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m. New documentati<strong>on</strong> and user training is not required in the case of a<br />

full port because the business logic and the user interface remain the same.<br />

A full port <strong>to</strong> the .NET framework is preferred in the following situati<strong>on</strong>s:<br />

● The programming envir<strong>on</strong>ment in which the applicati<strong>on</strong> was written is fully<br />

supported in the .NET framework.<br />

● Appropriate .NET database drivers are available and support all the functi<strong>on</strong> calls<br />

made in the applicati<strong>on</strong> code.<br />

● Rewriting an applicati<strong>on</strong> c<strong>on</strong>sumes <strong>to</strong>o much time and increases cost prohibitively.<br />

● When ported in<strong>to</strong> the .NET framework, the applicati<strong>on</strong> successfully interacts with<br />

other applicati<strong>on</strong>s.<br />

A rewrite of the applicati<strong>on</strong> would be required when there are no equivalents <strong>on</strong> the .NET<br />

plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m <str<strong>on</strong>g>for</str<strong>on</strong>g> the language in use. An example of this would be applicati<strong>on</strong>s based <strong>on</strong>


26<br />

Envisi<strong>on</strong>ing Phase<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms. The best opti<strong>on</strong> in this case would be <strong>to</strong> rewrite the applicati<strong>on</strong> <strong>on</strong><br />

Windows using Visual Basic .NET.<br />

A rewrite of the applicati<strong>on</strong> is preferred in the following situati<strong>on</strong>s:<br />

● The cost and complexity of porting is prohibitively high. It may be easier <strong>to</strong> recreate<br />

the applicati<strong>on</strong> rapidly using Visual Basic.NET, rather than porting the applicati<strong>on</strong>.<br />

● The business logic is likely <strong>to</strong> change significantly in the new envir<strong>on</strong>ment, which<br />

would limit the amount of code reused from the source plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m.<br />

● The applicati<strong>on</strong> requires new features and code that is specific <strong>to</strong> the Windows<br />

envir<strong>on</strong>ment.<br />

● Tight integrati<strong>on</strong> with Windows features is required in the new applicati<strong>on</strong>.<br />

● The best possible integrati<strong>on</strong> with other Windows-based applicati<strong>on</strong>s is required.<br />

● A port is not possible either because the language is not supported or API libraries<br />

<str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>SQL</strong> <strong>Server</strong> do not exist.<br />

Potentially, rewriting an applicati<strong>on</strong> can be challenging. It can be a time-c<strong>on</strong>suming, risky,<br />

and costly opti<strong>on</strong>. The risk inherent in a rewrite is that the business logic or an important<br />

functi<strong>on</strong>ality is changed while rewriting the code. Careful testing and stabilizing of the<br />

rewritten applicati<strong>on</strong> needs <strong>to</strong> be c<strong>on</strong>ducted <strong>to</strong> ensure proper business logic and<br />

functi<strong>on</strong>ality.<br />

When porting or rewriting <strong>to</strong> Windows, migrati<strong>on</strong> <strong>to</strong> the .NET plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m is preferred. .NET<br />

technology provides the ability <strong>to</strong> build, deploy, manage, and use c<strong>on</strong>nected, securityenhanced<br />

soluti<strong>on</strong>s with Web services. For more in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> about the .NET plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m<br />

and its key capabilities, refer <strong>to</strong> the following two resources:<br />

http://www.microsoft.com/net/basics/<br />

http://msdn.microsoft.com/netframework/programming/fundamentals/default.aspx<br />

There are situati<strong>on</strong>s when moving <strong>to</strong> .NET may not be feasible. For instance, at the time<br />

that this guide was published no producti<strong>on</strong>-ready implementati<strong>on</strong>s of Pyth<strong>on</strong> <strong>on</strong> the<br />

.NET framework existed. However, this technology is currently available in a beta <str<strong>on</strong>g>for</str<strong>on</strong>g>mat,<br />

and investigati<strong>on</strong> of current technologies is recommended.<br />

<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> Design Strategy C: Port or Rewrite <strong>to</strong> Win32<br />

The.NET Framework offers the next generati<strong>on</strong> of applicati<strong>on</strong>s and services. Migrati<strong>on</strong> <strong>to</strong><br />

the Win32 plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m should be c<strong>on</strong>sidered when migrati<strong>on</strong> <strong>to</strong> .NET is not technically<br />

feasible <str<strong>on</strong>g>for</str<strong>on</strong>g> your organizati<strong>on</strong>. As with strategy B, two migrati<strong>on</strong> opti<strong>on</strong>s are available<br />

when moving <strong>to</strong> a Win32-based plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m. The first is <strong>to</strong> per<str<strong>on</strong>g>for</str<strong>on</strong>g>m a full port of the<br />

applicati<strong>on</strong>, and the other is <strong>to</strong> rewrite the applicati<strong>on</strong> using the Win32 APIs. The rati<strong>on</strong>ale<br />

<str<strong>on</strong>g>for</str<strong>on</strong>g> deciding whether <strong>to</strong> port or rewrite the applicati<strong>on</strong> <strong>to</strong> functi<strong>on</strong> with Win32 is the same<br />

as the rati<strong>on</strong>ale <str<strong>on</strong>g>for</str<strong>on</strong>g> using .NET. Please refer <strong>to</strong> the descripti<strong>on</strong> in the "<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> Design<br />

Strategy B: Port or Rewrite <strong>to</strong> .NET Framework" secti<strong>on</strong> <str<strong>on</strong>g>for</str<strong>on</strong>g> more details.<br />

<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> Design Strategy D: Quick Port by <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <strong>to</strong><br />

Windows Services <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>UNIX</strong><br />

One of the quickest migrati<strong>on</strong> paths possible is <strong>to</strong> port the code directly <strong>to</strong><br />

Windows Services <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>UNIX</strong>. Windows Services <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>UNIX</strong> includes Microsoft Interix, which<br />

provides a <strong>UNIX</strong> envir<strong>on</strong>ment that runs <strong>on</strong> <strong>to</strong>p of the Windows kernel. Interix allows<br />

native <strong>UNIX</strong> applicati<strong>on</strong>s and scripts <strong>to</strong> work al<strong>on</strong>gside Windows applicati<strong>on</strong>s. The best<br />

way <strong>to</strong> view Interix is <strong>to</strong> understand it as a POSIX-compliant versi<strong>on</strong> of <strong>UNIX</strong> built <strong>on</strong> <strong>to</strong>p<br />

of the Windows kernel. It is not an emulati<strong>on</strong> of a <strong>UNIX</strong> envir<strong>on</strong>ment <strong>on</strong> the Windows<br />

APIs. Migrati<strong>on</strong> using Windows Services <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>UNIX</strong> involves obtaining the source code,


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 27<br />

installing it in the Interix development envir<strong>on</strong>ment, modifying the c<strong>on</strong>figurati<strong>on</strong> scripts<br />

and makefiles, and recompiling the applicati<strong>on</strong>. This strategy is referred <strong>to</strong> as a quick<br />

port.<br />

The ported applicati<strong>on</strong> may be successful immediately, or it may require modificati<strong>on</strong>s <strong>to</strong><br />

the c<strong>on</strong>figurati<strong>on</strong> scripts or makefiles <strong>to</strong> account <str<strong>on</strong>g>for</str<strong>on</strong>g> the new hardware plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m, the target<br />

operating systems, and local c<strong>on</strong>figurati<strong>on</strong> in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong>. A detailed assessment of the<br />

applicati<strong>on</strong> has <strong>to</strong> be c<strong>on</strong>ducted <strong>to</strong> inven<strong>to</strong>ry the various APIs and utilities in use. The<br />

support <str<strong>on</strong>g>for</str<strong>on</strong>g> these in the Windows Services <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>UNIX</strong> envir<strong>on</strong>ment has <strong>to</strong> be verified.<br />

Extensive testing of the applicati<strong>on</strong> is essential after the port <strong>to</strong> ensure that all features<br />

have been migrated successfully.<br />

A quick port is preferred in the following situati<strong>on</strong>s:<br />

● A port <str<strong>on</strong>g>for</str<strong>on</strong>g> the language the applicati<strong>on</strong> was written in does not exist in .NET or<br />

Win32. An example applicati<strong>on</strong> is X Windows.<br />

● Applicati<strong>on</strong> investments <strong>on</strong> the <strong>UNIX</strong> plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m need <strong>to</strong> be reused. Interix can<br />

optimize your investments in <strong>UNIX</strong> applicati<strong>on</strong>s by reusing code. New functi<strong>on</strong>ality<br />

and value can be added <strong>to</strong> your existing <strong>UNIX</strong> applicati<strong>on</strong>s by integrating the <strong>UNIX</strong><br />

code with .NET or Win32 functi<strong>on</strong>ality.<br />

● It is <strong>to</strong>o expensive and time-c<strong>on</strong>suming <strong>to</strong> do a full port or complete rewrite of the<br />

applicati<strong>on</strong>.<br />

● A large set of <strong>UNIX</strong> scripts need <strong>to</strong> be ported. Interix allows you <strong>to</strong> get the most out<br />

of existing <strong>UNIX</strong> network administra<strong>to</strong>r <strong>to</strong>ols and skill sets. It provides more than<br />

300 <strong>UNIX</strong> utilities, and it provides shells and scripting languages (including Perl)<br />

that enable you <strong>to</strong> run existing shell scripts with little or no change <strong>on</strong> Windows.<br />

A quick port is not recommended in the following situati<strong>on</strong>s:<br />

● A port of the applicati<strong>on</strong> is available in Win32 or .NET.<br />

● You can af<str<strong>on</strong>g>for</str<strong>on</strong>g>d the rewrite or port <strong>to</strong> Win32 or .NET and wants <strong>to</strong> tightly integrate<br />

the applicati<strong>on</strong> with other Windows technologies.<br />

● You want <strong>to</strong> significantly evolve the applicati<strong>on</strong> by using the capabilities of the<br />

Windows envir<strong>on</strong>ment.<br />

● A quick port requires huge ef<str<strong>on</strong>g>for</str<strong>on</strong>g>t in development and implementati<strong>on</strong> as compared<br />

<strong>to</strong> employing <strong>on</strong>e of the other methods. For example, when the required libraries<br />

available <strong>on</strong> the original <strong>UNIX</strong> plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m are not available <strong>on</strong> Interix.<br />

Most <strong>UNIX</strong> database envir<strong>on</strong>ments use scripts <strong>to</strong> support databases and client<br />

applicati<strong>on</strong>s. You should evaluate the importance of the services that these scripts<br />

per<str<strong>on</strong>g>for</str<strong>on</strong>g>m. <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> the scripts <strong>to</strong> Windows Services <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>UNIX</strong> is an opti<strong>on</strong>; however,<br />

scripts that make use of <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> utility programs must be modified <strong>to</strong> use suitable<br />

replacements <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>SQL</strong> <strong>Server</strong>.<br />

Using Windows Services <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>UNIX</strong>, organizati<strong>on</strong>s can rapidly c<strong>on</strong>solidate diverse<br />

plat<str<strong>on</strong>g>for</str<strong>on</strong>g>ms, maximizing their previous investments in <strong>UNIX</strong> infrastructure, applicati<strong>on</strong>s, and<br />

knowledge while capitalizing <strong>on</strong> Windows innovati<strong>on</strong>. Moreover,<br />

Windows Services <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>UNIX</strong> provides a full range of supported and fully integrated, crossplat<str<strong>on</strong>g>for</str<strong>on</strong>g>m<br />

network services <str<strong>on</strong>g>for</str<strong>on</strong>g> blending Windows and <strong>UNIX</strong> networks.<br />

For a detailed discussi<strong>on</strong> of Windows Services <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>UNIX</strong> in migrati<strong>on</strong> projects, refer <strong>to</strong> the<br />

<strong>UNIX</strong> Applicati<strong>on</strong> Migrati<strong>on</strong> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> available at<br />

http://go.microsoft.com/fwlink/?LinkId=30832<br />

Windows Services <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>UNIX</strong> 3.5 is available as a complimentary download from Microsoft<br />

<str<strong>on</strong>g>for</str<strong>on</strong>g> Windows <strong>Server</strong> 2003, Windows® XP Professi<strong>on</strong>al, and Windows® 2000.<br />

Some Windows Services <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>UNIX</strong> 3.5 features include:


28<br />

Envisi<strong>on</strong>ing Phase<br />

●<br />

●<br />

●<br />

It is designed <strong>to</strong> work well with other major <strong>UNIX</strong> plat<str<strong>on</strong>g>for</str<strong>on</strong>g>ms and versi<strong>on</strong>s. It has<br />

been tested specifically with Sun Solaris 7 and 8, HP-UX 11i, AIX 5L 5.2, and Red<br />

Hat Linux 8.0.<br />

It includes versi<strong>on</strong> 5.6 of the ActiveState Perl distributi<strong>on</strong> <str<strong>on</strong>g>for</str<strong>on</strong>g> native Windows<br />

scripting and Perl 5.6.1 <str<strong>on</strong>g>for</str<strong>on</strong>g> scripting in the Interix envir<strong>on</strong>ment.<br />

It includes more than 300 <strong>UNIX</strong> utilities and <strong>to</strong>ols that per<str<strong>on</strong>g>for</str<strong>on</strong>g>m <strong>on</strong> <strong>UNIX</strong> and<br />

Windows systems in a similar manner. In additi<strong>on</strong>, Windows Services <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>UNIX</strong> 3.5<br />

also c<strong>on</strong>tains a Software Development Kit (SDK) that supports more than 1,900<br />

<strong>UNIX</strong> APIs and migrati<strong>on</strong> <strong>to</strong>ols, such as make, rcs, yacc, lex, cc, c89, nm, strip,<br />

and gbd, as well as the gcc, g++, and g77 compilers.<br />

More in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> about Windows Services <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>UNIX</strong> is available from the following two<br />

resources:<br />

http://www.microsoft.com/windows/sfu/productinfo/overview/default.asp<br />

http://www.microsoft.com/windows/sfu/<br />

Migrati<strong>on</strong> Strategy Scenarios<br />

Tables 2.2 through 2.5 show the migrati<strong>on</strong> opportunities <str<strong>on</strong>g>for</str<strong>on</strong>g> several scenarios of the<br />

source <strong>UNIX</strong> envir<strong>on</strong>ment. Each scenario is a combinati<strong>on</strong> of the three comp<strong>on</strong>ents of<br />

database, applicati<strong>on</strong>, and c<strong>on</strong>nectivity (API). The first column of the tables represents<br />

the current state in the <strong>UNIX</strong> envir<strong>on</strong>ment, and the third column shows the migrati<strong>on</strong><br />

possibilities <str<strong>on</strong>g>for</str<strong>on</strong>g> each of the migrati<strong>on</strong> strategies: interoperate, port or rewrite <strong>to</strong> the .NET<br />

Framework, port or rewrite <strong>to</strong> Win32, and port <strong>to</strong> Windows Services <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>UNIX</strong>.<br />

Table 2.2: Applicati<strong>on</strong> Interoperati<strong>on</strong> Strategy<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g>/<strong>UNIX</strong><br />

language<br />

PHP<br />

API<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> or OCI8 or<br />

ODBC<br />

Interoperate <strong>SQL</strong><br />

<strong>Server</strong>/<strong>UNIX</strong><br />

language<br />

PHP<br />

API<br />

MS <strong>SQL</strong> <strong>Server</strong> or<br />

ODBC<br />

Pro*C OCI <str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> not available<br />

or feasible<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms Forms C or JDAPI <str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> not available<br />

or feasible<br />

Perl <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> or ODBC Perl ODBC or Sybase<br />

Pyth<strong>on</strong> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> or ODBC Pyth<strong>on</strong> ODBC<br />

Java JDBC Java JDBC


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 29<br />

Table 2.3: Applicati<strong>on</strong> Port <strong>to</strong> Windows Services <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>UNIX</strong> Strategy<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g>/<strong>UNIX</strong><br />

language<br />

PHP<br />

API<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> or OCI8 or<br />

ODBC<br />

Port <strong>SQL</strong><br />

<strong>Server</strong>/Windows<br />

Services <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>UNIX</strong><br />

language<br />

PHP<br />

Pro*C OCI <str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> not available<br />

or feasible<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms Forms C or JDAPI <str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> not available<br />

or feasible<br />

API<br />

MS <strong>SQL</strong> <strong>Server</strong> or<br />

ODBC<br />

Perl <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> or ODBC Perl ODBC or Sybase<br />

Pyth<strong>on</strong> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> or ODBC Pyth<strong>on</strong> ODBC<br />

Java JDBC Java JDBC<br />

Table 2.4: Applicati<strong>on</strong> Port or Rewrite <strong>to</strong> Win32 Strategy<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g>/<strong>UNIX</strong><br />

language<br />

PHP<br />

API<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> or OCI8 or<br />

ODBC<br />

Port/rewrite <strong>SQL</strong><br />

<strong>Server</strong>/WIN32<br />

language<br />

PHP<br />

API<br />

MS <strong>SQL</strong> <strong>Server</strong> or<br />

ODBC<br />

Pro*C OCI VB ODBC or ADO<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms Forms C or JDAPI VB ODBC or ADO<br />

Perl <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> or ODBC Perl ODBC or ADO<br />

Pyth<strong>on</strong> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> or ODBC Pyth<strong>on</strong> ODBC<br />

Java JDBC Java JDBC<br />

Table 2.5: Applicati<strong>on</strong> Port or Rewrite <strong>to</strong> .NET Strategy<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g>/<strong>UNIX</strong><br />

language<br />

PHP<br />

API<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> or OCI8 or<br />

ODBC<br />

Port/rewrite <strong>SQL</strong><br />

<strong>Server</strong>/.NET<br />

language<br />

<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> not available<br />

or feasible<br />

Pro*C OCI VB.NET ODBC or ADO.NET<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms Forms C or JDAPI VB.NET ODBC or ADO.NET<br />

Perl <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> or ODBC Perl PerlNET<br />

Pyth<strong>on</strong> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> or ODBC <str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> not available<br />

or feasible<br />

Java JDBC <str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> not available<br />

or feasible<br />

API


30<br />

Envisi<strong>on</strong>ing Phase<br />

Optimal Strategy<br />

The fac<strong>to</strong>rs that need <strong>to</strong> be c<strong>on</strong>sidered while deciding a migrati<strong>on</strong> strategy are:<br />

●<br />

●<br />

●<br />

●<br />

Business needs. The migrati<strong>on</strong> strategy should meet the present and future<br />

needs of the organizati<strong>on</strong>.<br />

For example, an organizati<strong>on</strong> may need <strong>to</strong> open its existing applicati<strong>on</strong> <strong>to</strong> external<br />

users. Security needs <strong>to</strong> be implemented <str<strong>on</strong>g>for</str<strong>on</strong>g> the external users. The organizati<strong>on</strong><br />

may select the rewrite strategy.<br />

Technical feasibility. <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms <strong>to</strong> the Windows plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m may not be<br />

technically feasible. If the new features warrant a lot of change <strong>to</strong> the current<br />

applicati<strong>on</strong>, the organizati<strong>on</strong> may opt <strong>to</strong> select rewriting as a strategy.<br />

Time. The time frame within which the migrati<strong>on</strong> has <strong>to</strong> be planned, developed,<br />

tested, and deployed needs <strong>to</strong> be decided. In additi<strong>on</strong>, the actual time taken in the<br />

migrati<strong>on</strong> needs <strong>to</strong> be minimized <strong>to</strong> reduce the business risk.<br />

For example, an organizati<strong>on</strong> may plan <strong>to</strong> provide access <strong>to</strong> its applicati<strong>on</strong> <strong>to</strong> the<br />

external users within three m<strong>on</strong>ths. A quick port <strong>to</strong> the Windows Services <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>UNIX</strong><br />

plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m may be the best opti<strong>on</strong>.<br />

Budget. The budget available needs <strong>to</strong> be planned. According <strong>to</strong> the m<strong>on</strong>ey<br />

available, the infrastructure, human resources, and cost need <strong>to</strong> be planned.<br />

For example, the direct cost of porting may be lower than the cost of a rewrite.<br />

Also, porting an applicati<strong>on</strong> minimizes the cost of training, as the same applicati<strong>on</strong><br />

is used in the new envir<strong>on</strong>ment. The indirect cost; such as cost of maintenance,<br />

testing, and retraining, will also be lower.<br />

Set Up a Team<br />

To trans<str<strong>on</strong>g>for</str<strong>on</strong>g>m overall business and design goals in<strong>to</strong> a clear visi<strong>on</strong> <str<strong>on</strong>g>for</str<strong>on</strong>g> the project, an<br />

organizati<strong>on</strong> needs <strong>to</strong> assemble a multidisciplinary team, based <strong>on</strong> MSF roles, and with<br />

defined skill sets appropriate <strong>to</strong> the project. These roles are Product Management,<br />

Program Management, Development, Test, User Experience, and Release Management.<br />

Once assembled, this team defines the visi<strong>on</strong> and scope that <strong>to</strong>gether provide a clear<br />

directi<strong>on</strong> <str<strong>on</strong>g>for</str<strong>on</strong>g> the project and set expectati<strong>on</strong>s within the organizati<strong>on</strong>. During the<br />

Envisi<strong>on</strong>ing Phase, it is likely that <strong>on</strong>ly the lead pers<strong>on</strong> or pers<strong>on</strong>s <str<strong>on</strong>g>for</str<strong>on</strong>g> each team role will<br />

be determined. During the Planning Phase, the entire team should be assembled if it is<br />

necessary <str<strong>on</strong>g>for</str<strong>on</strong>g> your organizati<strong>on</strong> <strong>to</strong> staff each role with more than <strong>on</strong>e pers<strong>on</strong>. More<br />

in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> about the MSF Team Model is available in the UMPG.<br />

Table 2.6 lists each role with its goal and identifies its key functi<strong>on</strong>al areas and project<br />

resp<strong>on</strong>sibilities <str<strong>on</strong>g>for</str<strong>on</strong>g> an <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows migrati<strong>on</strong> project.<br />

Table 2.6: Project Requirements and Resp<strong>on</strong>sibilities by Task<br />

Role Project resp<strong>on</strong>sibilities and tasks Knowledge and skill<br />

requirements<br />

Product<br />

Management<br />

Role<br />

* Ensure that the team addresses<br />

business goals and cus<strong>to</strong>mer<br />

requirements<br />

* Manage communicati<strong>on</strong>s, launch<br />

planning, and feedback with cus<strong>to</strong>mers<br />

(both internal and external)<br />

Understanding of the<br />

organizati<strong>on</strong>'s business<br />

priorities and goals<br />

Program * Drive soluti<strong>on</strong> design * Project management skills


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 31<br />

Role Project resp<strong>on</strong>sibilities and tasks Knowledge and skill<br />

requirements<br />

Management<br />

Role<br />

Development<br />

Role<br />

Development<br />

Functi<strong>on</strong>al<br />

Team #1<br />

(Database)<br />

* Manage projects <strong>to</strong> meet budget and<br />

schedule<br />

* Manage scope and track progress<br />

* Provide process leadership<br />

It is recommended that two teams be<br />

created <str<strong>on</strong>g>for</str<strong>on</strong>g> the Development Role. One<br />

development team should focus <strong>on</strong><br />

migrating the database, providing<br />

database administrati<strong>on</strong> and support.<br />

The sec<strong>on</strong>d development team should<br />

focus <strong>on</strong> migrating the applicati<strong>on</strong>.<br />

* Ensure that requirements of the<br />

Windows envir<strong>on</strong>ment are met <str<strong>on</strong>g>for</str<strong>on</strong>g> the<br />

migrated database (<str<strong>on</strong>g>for</str<strong>on</strong>g> example, OS<br />

support <str<strong>on</strong>g>for</str<strong>on</strong>g> amount of memory<br />

required).<br />

* Identify and provide access <strong>to</strong> shell<br />

and other scripts that are used <strong>to</strong><br />

support the database being migrated.<br />

* Migrate user accounts and verifiy that<br />

they have been migrated correctly.<br />

* Install DBMS software and database<br />

applicati<strong>on</strong>s <strong>on</strong> servers.<br />

* Create database in <strong>SQL</strong> <strong>Server</strong> and<br />

migrate data from <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>.<br />

* Identify the time and order in which<br />

the shell scripts are invoked.<br />

* Design and implement the appropriate<br />

security model <str<strong>on</strong>g>for</str<strong>on</strong>g> migrated databases,<br />

based <strong>on</strong> analysis of applicati<strong>on</strong> and<br />

database.<br />

* Identify and resolve issues associated<br />

with Windows security and c<strong>on</strong>nectivity.<br />

* Validate that the chosen security<br />

c<strong>on</strong>figurati<strong>on</strong> provides at least the same<br />

security levels as the existing<br />

c<strong>on</strong>figurati<strong>on</strong>.<br />

* Apply appropriate permissi<strong>on</strong>s at the<br />

database object level.<br />

* Work with test groups <strong>to</strong> build test<br />

envir<strong>on</strong>ment.<br />

* Work with client development<br />

functi<strong>on</strong>al team <strong>on</strong> issues related <strong>to</strong><br />

c<strong>on</strong>nectivity between database and<br />

applicati<strong>on</strong><br />

* Communicati<strong>on</strong> skills<br />

* Adequate knowledge of <strong>UNIX</strong><br />

and Windows envir<strong>on</strong>ments<br />

and of <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong><br />

databases <strong>to</strong> drive soluti<strong>on</strong><br />

design<br />

* Knowledge of security<br />

c<strong>on</strong>figurati<strong>on</strong> <str<strong>on</strong>g>for</str<strong>on</strong>g> current <str<strong>on</strong>g>Oracle</str<strong>on</strong>g><br />

database and applicati<strong>on</strong>s<br />

running <strong>on</strong> <strong>UNIX</strong>.<br />

* Knowledge of shell and other<br />

scripts used <strong>to</strong> support the<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> database.<br />

* Knowledge of cr<strong>on</strong> jobs,<br />

including times and the order<br />

in which scripts are run.<br />

* Understanding of security,<br />

c<strong>on</strong>nectivity, software, and<br />

database installati<strong>on</strong> issues in<br />

the Windows envir<strong>on</strong>ment.<br />

* Understanding of both the<br />

Windows and <strong>UNIX</strong><br />

envir<strong>on</strong>ment.<br />

* Understanding of <strong>Net</strong>work<br />

Library <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>SQL</strong>*<strong>Net</strong>, <strong>Net</strong>8,<br />

and TCP/IP.<br />

* Understanding of the <str<strong>on</strong>g>Oracle</str<strong>on</strong>g><br />

schema, tables, views, s<strong>to</strong>red<br />

procedures and triggers.<br />

*Knowledge of <strong>SQL</strong> <strong>Server</strong><br />

and ability <strong>to</strong> per<str<strong>on</strong>g>for</str<strong>on</strong>g>m all these<br />

tasks in a Windows<br />

envir<strong>on</strong>ment


32<br />

Envisi<strong>on</strong>ing Phase<br />

Role Project resp<strong>on</strong>sibilities and tasks Knowledge and skill<br />

requirements<br />

Development<br />

Functi<strong>on</strong>al<br />

Team #2<br />

(Applicati<strong>on</strong>)<br />

User<br />

Experience<br />

Role<br />

Test Role<br />

* Participate in assessment activities <str<strong>on</strong>g>for</str<strong>on</strong>g><br />

client applicati<strong>on</strong>s.<br />

* Identify and articulate security<br />

requirements <str<strong>on</strong>g>for</str<strong>on</strong>g> client applicati<strong>on</strong>s.<br />

* Retarget or migrate existing client<br />

applicati<strong>on</strong>s.<br />

* Work with test team <strong>to</strong> ensure<br />

requirements are met and defects are<br />

reduced.<br />

* Work with database team <strong>on</strong> issues<br />

related <strong>to</strong> c<strong>on</strong>nectivity or other<br />

database-related problems.<br />

* Manage process of gathering,<br />

analyzing, and prioritizing user<br />

requirements.<br />

* Help develop usage scenarios and<br />

use cases.<br />

* Provide feedback <strong>on</strong> the soluti<strong>on</strong><br />

design.<br />

* Drive the creati<strong>on</strong> of user training<br />

materials.<br />

* Participate in data gathering relevant<br />

<strong>to</strong> Test during all phases of the project.<br />

* Design and develop the test<br />

envir<strong>on</strong>ment in c<strong>on</strong>juncti<strong>on</strong> with the<br />

Development functi<strong>on</strong>al teams <str<strong>on</strong>g>for</str<strong>on</strong>g><br />

database and client migrati<strong>on</strong>s.<br />

* Maintain ownership of the test<br />

envir<strong>on</strong>ment.<br />

* Design, create the specificati<strong>on</strong> <str<strong>on</strong>g>for</str<strong>on</strong>g>,<br />

and refine the test plan and the user<br />

acceptance test plan.<br />

* Implement and validate the migrati<strong>on</strong><br />

test plan.<br />

Implement test cases.<br />

* Knowledge of <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> client<br />

applicati<strong>on</strong>s and their security<br />

requirements.<br />

* Proficiency in either Perl,<br />

Pyth<strong>on</strong>, PHP, Java, Visual<br />

Basic.NET, Windows Services<br />

<str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>UNIX</strong>, or Windows.<br />

* Experience with technologies<br />

<str<strong>on</strong>g>for</str<strong>on</strong>g> applicati<strong>on</strong> interoperati<strong>on</strong><br />

with <strong>SQL</strong> <strong>Server</strong> such as<br />

FreeTDS.<br />

* Understanding of s<strong>to</strong>red<br />

procedures, database logic,<br />

and applicati<strong>on</strong> logic.<br />

* Understanding of c<strong>on</strong>nectivity<br />

issues with database.<br />

* Understanding of the<br />

applicati<strong>on</strong>s being migrated.<br />

* Experience in developing<br />

usage scenarios and use<br />

cases.<br />

* Understanding of training<br />

principles.<br />

* Understanding of the <strong>UNIX</strong><br />

and Windows operating<br />

systems (including Windows<br />

Services <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>UNIX</strong>, if<br />

appropriate).<br />

* Expertise with <str<strong>on</strong>g>Oracle</str<strong>on</strong>g><br />

databases, applicati<strong>on</strong> and<br />

client development.<br />

* Experience with<br />

interoperati<strong>on</strong> between <strong>UNIX</strong><br />

and Windows.<br />

* Understanding of tiered<br />

database systems in<br />

homogeneous and<br />

heterogeneous envir<strong>on</strong>ments.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 33<br />

Role Project resp<strong>on</strong>sibilities and tasks Knowledge and skill<br />

requirements<br />

Release<br />

Management<br />

* Act as primary advocate between<br />

project development and operati<strong>on</strong>s<br />

groups.<br />

* Manage <strong>to</strong>ol selecti<strong>on</strong> <str<strong>on</strong>g>for</str<strong>on</strong>g> release<br />

activities and drive optimizing<br />

au<strong>to</strong>mati<strong>on</strong>.<br />

* Set operati<strong>on</strong>s criteria <str<strong>on</strong>g>for</str<strong>on</strong>g> release <strong>to</strong><br />

producti<strong>on</strong>.<br />

* Participate in design, focusing <strong>on</strong><br />

manageability, supportability, and in<br />

deployment.<br />

* Drive training <str<strong>on</strong>g>for</str<strong>on</strong>g> operati<strong>on</strong>s.<br />

* Drive and set up <str<strong>on</strong>g>for</str<strong>on</strong>g> pilot deployments.<br />

* Plan and manage soluti<strong>on</strong> deployment<br />

in<strong>to</strong> producti<strong>on</strong>.<br />

* Ensure that stabilizati<strong>on</strong><br />

measurements meet acceptance<br />

criteria.<br />

* Understanding of standard<br />

operati<strong>on</strong>al procedures in the<br />

Windows envir<strong>on</strong>ment.<br />

* Understanding of<br />

applicati<strong>on</strong>s being migrated.<br />

* Management and<br />

communicati<strong>on</strong> skills.<br />

Special C<strong>on</strong>siderati<strong>on</strong>s <str<strong>on</strong>g>for</str<strong>on</strong>g> Setting Up Your Migrati<strong>on</strong> Team<br />

An <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows migrati<strong>on</strong> project can present some<br />

unique issues <str<strong>on</strong>g>for</str<strong>on</strong>g> staffing your project team. Keep the following c<strong>on</strong>siderati<strong>on</strong>s in mind<br />

when staffing your project team:<br />

● It is relatively easy <strong>to</strong> find technical staff with a deep knowledge of <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and<br />

<strong>UNIX</strong> or <strong>SQL</strong> and Windows, but it is not easy <strong>to</strong> find technical staff that has a deep<br />

understanding of all of these areas. Migrati<strong>on</strong> involves creating a metaphorical<br />

bridge between the two envir<strong>on</strong>ments. Make sure you have a senior architect <strong>on</strong><br />

the team who understands both worlds deeply enough <strong>to</strong> engineer the bridge's<br />

creati<strong>on</strong>. If the skill is not available in-house, c<strong>on</strong>sider finding a c<strong>on</strong>sultant or a<br />

c<strong>on</strong>sulting organizati<strong>on</strong> with experience in this <str<strong>on</strong>g>for</str<strong>on</strong>g>m of migrati<strong>on</strong>. The c<strong>on</strong>sulting<br />

organizati<strong>on</strong>s often offer services <strong>to</strong> complete these migrati<strong>on</strong> projects end-<strong>to</strong>-end.<br />

It may be possible <str<strong>on</strong>g>for</str<strong>on</strong>g> you <strong>to</strong> successfully implement the migrati<strong>on</strong> with lowered<br />

risk and reduced cost by engaging a c<strong>on</strong>sulting organizati<strong>on</strong>. For more in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong><br />

about Microsoft partners that offer <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> migrati<strong>on</strong> services, refer<br />

<strong>to</strong> http://www.microsoft.com/sql/partners/migrati<strong>on</strong>.asp<br />

● Ensure that the hardware and infrastructure experts from the Development Role<br />

and Test Role are actively engaged during the Envisi<strong>on</strong>ing Phase. The hardware<br />

<strong>on</strong> which databases and applicati<strong>on</strong>s are run is comm<strong>on</strong>ly overlooked until later in<br />

the project life cycle than it should be. Involving the experts early in the project will<br />

help in<str<strong>on</strong>g>for</str<strong>on</strong>g>m more accurate estimates regarding budget, time, and resources.<br />

● The Test Role should include, if possible, team members who have worked with<br />

the applicati<strong>on</strong> being migrated. Their experience will help them write better test<br />

cases.<br />

● The User Experience Role should include, if possible, team members who have<br />

worked with the applicati<strong>on</strong> in the <strong>UNIX</strong> envir<strong>on</strong>ment. They should have a good<br />

understanding of the applicati<strong>on</strong>'s user interface so that they will be able <strong>to</strong> define<br />

and provide the training required <str<strong>on</strong>g>for</str<strong>on</strong>g> end users after the applicati<strong>on</strong> migrati<strong>on</strong>.


34<br />

Envisi<strong>on</strong>ing Phase<br />

●<br />

●<br />

●<br />

●<br />

●<br />

C<strong>on</strong>sider including in the Test Role team members who have the expertise <strong>to</strong> test<br />

the security of the migrated envir<strong>on</strong>ment. The security of the migrated applicati<strong>on</strong><br />

is often overlooked in migrati<strong>on</strong> projects.<br />

Migrati<strong>on</strong> projects are often undertaken using existing technical staff who have<br />

day-<strong>to</strong>-day resp<strong>on</strong>sibilities which impact their availability. Resources should be<br />

properly planned and allocated <strong>to</strong> the project <strong>to</strong> avoid such impact.<br />

Technical staff that has experience with the current applicati<strong>on</strong> and database<br />

should be involved in the project from design <strong>to</strong> deployment. Any required training<br />

should be provided <strong>to</strong> improve their utility in the migrati<strong>on</strong>.<br />

Security, hardware, and infrastructure experts from Operati<strong>on</strong>s should also be<br />

involved in the Envisi<strong>on</strong>ing Phase because they can provide valuable advice about<br />

the technical availability, costs, and the capabilities of the organizati<strong>on</strong>.<br />

Because moving from <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows is a major<br />

paradigm shift, it could impact the employment and careers of existing pers<strong>on</strong>nel.<br />

This issue should be c<strong>on</strong>sidered when <str<strong>on</strong>g>for</str<strong>on</strong>g>ming the team and carrying out the<br />

migrati<strong>on</strong>. Change is often inevitable and should be perceived as a way <strong>to</strong> expand<br />

and develop skills.<br />

Define the Project Structure<br />

The project structure defines how the team manages and supports the project and<br />

describes the administrative structure <str<strong>on</strong>g>for</str<strong>on</strong>g> the project team going in<strong>to</strong> the subsequent<br />

project phases.<br />

The main functi<strong>on</strong> of the project structure is <strong>to</strong> define standards the team will use during<br />

the project. These include communicati<strong>on</strong> standards, documentati<strong>on</strong> standards, and<br />

change c<strong>on</strong>trol procedure standards. Program Management takes the lead in defining the<br />

project structure.<br />

Refer <strong>to</strong> the <strong>UNIX</strong> Migrati<strong>on</strong> Project <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> detailed in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> about project structure.<br />

Use the Project Structure document template <strong>to</strong> assist you in defining and recording the<br />

project structure and pro<strong>to</strong>cols <str<strong>on</strong>g>for</str<strong>on</strong>g> the project team. This template is available in theTools<br />

and Templates folder in the zip file download of this guidance at<br />

http://go.microsoft.com/fwlink/?LinkId=45289.<br />

Define Project Communicati<strong>on</strong>s<br />

Program Management should use the project structure <strong>to</strong> define standards <str<strong>on</strong>g>for</str<strong>on</strong>g> team<br />

members <strong>to</strong> communicate with <strong>on</strong>e another. Am<strong>on</strong>g these standards can be a definiti<strong>on</strong><br />

of the reporting structure under which team members operate, procedures <strong>to</strong> elevate<br />

project issues, regular mandated status meetings, and any other project-specific<br />

communicati<strong>on</strong> standards that need <strong>to</strong> be defined during the Envisi<strong>on</strong>ing Phase.<br />

The document may also include e-mail names, aliases, teleph<strong>on</strong>e lists, mail addresses,<br />

server share names, direc<strong>to</strong>ry structures, and other in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> critical <strong>to</strong> team<br />

organizati<strong>on</strong>. C<strong>on</strong>sider establishing a team collaborati<strong>on</strong> envir<strong>on</strong>ment where<br />

communicati<strong>on</strong> can occur and progress be m<strong>on</strong>i<strong>to</strong>red and updated as necessary. The<br />

following list of fac<strong>to</strong>rs needs <strong>to</strong> be c<strong>on</strong>sidered <str<strong>on</strong>g>for</str<strong>on</strong>g> most <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong><br />

<strong>on</strong> Windows migrati<strong>on</strong> projects.<br />

● The project team will likely include members from the <strong>UNIX</strong> domain of the IT<br />

department as well as the Windows domain. There are often work-based cultural<br />

differences between members of these two domains. The Program Management<br />

role should ensure that this potential difference is identified and extra attenti<strong>on</strong> is<br />

paid <strong>to</strong> ensure clear communicati<strong>on</strong> between the members of the two domains.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 35<br />

●<br />

●<br />

Similarly, the communicati<strong>on</strong> <strong>to</strong>ols used by the <strong>UNIX</strong> and Windows users are often<br />

very different. For example, Windows users use the calendaring features of<br />

Outlook extensively <str<strong>on</strong>g>for</str<strong>on</strong>g> team communicati<strong>on</strong>. The <strong>UNIX</strong> users may be accus<strong>to</strong>med<br />

<strong>to</strong> a different set of <strong>to</strong>ols or clients.<br />

Different geographical locati<strong>on</strong>s and different cultural backgrounds of team<br />

members involved in the migrati<strong>on</strong> ef<str<strong>on</strong>g>for</str<strong>on</strong>g>t can cause communicati<strong>on</strong> issues. Extra<br />

attenti<strong>on</strong> is required <strong>to</strong> make sure that there is clear communicati<strong>on</strong> between all<br />

team members.<br />

Determine secure methods <strong>to</strong> share in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> about the project am<strong>on</strong>g the team<br />

members. If your team comprises c<strong>on</strong>sultants and in-house employees, there may<br />

be corporate policies about what in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> can be shared with outside<br />

c<strong>on</strong>sultants.<br />

Define Change C<strong>on</strong>trol<br />

Change c<strong>on</strong>trol standards and <strong>to</strong>ols help <strong>to</strong> manage both project documents and<br />

comp<strong>on</strong>ents of the soluti<strong>on</strong> that are subject <strong>to</strong> revisi<strong>on</strong> or iterati<strong>on</strong>. The requirements<br />

should be clearly defined in the project structure. General in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> about change<br />

c<strong>on</strong>trol is available in the UMPG.<br />

Migrati<strong>on</strong> projects have an additi<strong>on</strong>al source of change that is not obvious but must be<br />

managed: the initial state of the technology being migrated. This could be source code <str<strong>on</strong>g>for</str<strong>on</strong>g><br />

applicati<strong>on</strong>s, hardware and software c<strong>on</strong>figurati<strong>on</strong>, and versi<strong>on</strong>s of applicati<strong>on</strong> software.<br />

Although the initial state can be baselined when the migrati<strong>on</strong> project is started,<br />

operati<strong>on</strong>al needs may require changes <strong>to</strong> that c<strong>on</strong>figurati<strong>on</strong> while the migrati<strong>on</strong> is under<br />

way. These operati<strong>on</strong>al changes are typically subject <strong>to</strong> C<strong>on</strong>figurati<strong>on</strong> Management<br />

standards imposed by an operati<strong>on</strong>s team.<br />

The Program Manager Role and Release Manager Role should work with operati<strong>on</strong>s<br />

pers<strong>on</strong>nel resp<strong>on</strong>sible <str<strong>on</strong>g>for</str<strong>on</strong>g> the existing technology <strong>to</strong> minimize and accommodate these<br />

changes. L<strong>on</strong>g-lived migrati<strong>on</strong> projects may require a <str<strong>on</strong>g>for</str<strong>on</strong>g>mal process <strong>to</strong> c<strong>on</strong>nect<br />

operati<strong>on</strong>al C<strong>on</strong>figurati<strong>on</strong> Management <strong>to</strong> project change c<strong>on</strong>trol. Here are some<br />

additi<strong>on</strong>al points <strong>to</strong> remember:<br />

● The major difference between a migrati<strong>on</strong> project and a new development project<br />

is that the initial work has already been per<str<strong>on</strong>g>for</str<strong>on</strong>g>med <strong>to</strong> create the existing soluti<strong>on</strong>.<br />

The existing soluti<strong>on</strong> provides a working example of the goals which the soluti<strong>on</strong><br />

must meet.<br />

● Depending <strong>on</strong> the l<strong>on</strong>g term objectives of the project, an existing change c<strong>on</strong>trol<br />

<strong>to</strong>ol and reposi<strong>to</strong>ry <strong>on</strong> the <strong>UNIX</strong> plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m may be migrated <strong>to</strong> <strong>to</strong>ols in the Windows<br />

plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m.<br />

● As migrati<strong>on</strong> involves making modificati<strong>on</strong>s <strong>to</strong> objects currently in producti<strong>on</strong>, care<br />

has <strong>to</strong> be taken in how these objects are shared with the new development ef<str<strong>on</strong>g>for</str<strong>on</strong>g>t.<br />

As changes are discovered, there is the danger of modifying an object in the<br />

producti<strong>on</strong> thread. Creati<strong>on</strong> of a separate project is recommended. In this situati<strong>on</strong>,<br />

any changes made <strong>to</strong> the producti<strong>on</strong> thread should also be applied <strong>to</strong> the<br />

development (migrati<strong>on</strong>) thread. Appropriate c<strong>on</strong>trols have <strong>to</strong> put in place <strong>to</strong> handle<br />

this.


36<br />

Envisi<strong>on</strong>ing Phase<br />

C<strong>on</strong>figurati<strong>on</strong> Management<br />

A major task in any database migrati<strong>on</strong> is the trans<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> of database objects, such as<br />

sequences and code within the database, including s<strong>to</strong>red procedures. These<br />

trans<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong>s inherently change the source code. To maintain a known state as work<br />

progresses <strong>to</strong>wards migrati<strong>on</strong>, two aspects of C<strong>on</strong>figurati<strong>on</strong> Management have <strong>to</strong> be<br />

addressed:<br />

● As discussed earlier, any change <strong>to</strong> the original envir<strong>on</strong>ment after the baseline is<br />

created needs <strong>to</strong> be communicated <strong>to</strong> the project team and accounted <str<strong>on</strong>g>for</str<strong>on</strong>g>. Change<br />

management in the area of c<strong>on</strong>figurati<strong>on</strong> becomes critical if problems are<br />

encountered during the migrati<strong>on</strong> and you are <str<strong>on</strong>g>for</str<strong>on</strong>g>ced <strong>to</strong> return producti<strong>on</strong> <strong>to</strong> the<br />

pre-migrati<strong>on</strong> envir<strong>on</strong>ment.<br />

● Any changes <strong>to</strong> the soluti<strong>on</strong> that occur during the Developing Phase and<br />

Stabilizing Phase need <strong>to</strong> be documented and communicated <strong>to</strong> the entire project<br />

team.<br />

During the Stabilizing Phase, knowledge of and c<strong>on</strong>trol over the test envir<strong>on</strong>ment<br />

c<strong>on</strong>figurati<strong>on</strong> is critical <strong>to</strong> understanding the results that are received. If documentati<strong>on</strong><br />

exists identifying the aspects that have changed, the results of a given test can be<br />

validated against both current and future results.<br />

Some points <strong>to</strong> remember include:<br />

● Every c<strong>on</strong>figurati<strong>on</strong> change should have a fallback or rollback path.<br />

● C<strong>on</strong>figurati<strong>on</strong> management <strong>to</strong>ols, such as bug tracking software, should be able <strong>to</strong><br />

operate within the Windows envir<strong>on</strong>ment.<br />

Assess Risk<br />

MSF stresses assessing project risk c<strong>on</strong>tinuously throughout a project and makes this<br />

the resp<strong>on</strong>sibility of every team member. Risk is defined as the possibility of suffering a<br />

loss or, more specifically, the possibility of a negative outcome that can put the project in<br />

peril. The team comes up with an initial set of risks in the Envisi<strong>on</strong>ing Phase. This list is<br />

c<strong>on</strong>stantly updated in later phases of the project as new risks begin <strong>to</strong> appear and old<br />

<strong>on</strong>es start <strong>to</strong> lose relevance. It is important <strong>to</strong> understand that in a migrati<strong>on</strong> project<br />

issues are sometimes hidden, <str<strong>on</strong>g>for</str<strong>on</strong>g> example, in the design or implementati<strong>on</strong> of a piece of<br />

code, which will appear <strong>on</strong>ly as the soluti<strong>on</strong> is being trans<str<strong>on</strong>g>for</str<strong>on</strong>g>med. Here are some<br />

questi<strong>on</strong>s that you need <strong>to</strong> ask <strong>to</strong> understand the potential high level risks at the start of<br />

the project. These questi<strong>on</strong>s can help you generate the risk assessment list that can<br />

serve as the basis <str<strong>on</strong>g>for</str<strong>on</strong>g> your <strong>on</strong>going risk assessment and management <str<strong>on</strong>g>for</str<strong>on</strong>g> the project.<br />

● Are the project sp<strong>on</strong>sors and stakeholders committed <strong>to</strong> support the project?<br />

● Does the migrati<strong>on</strong> team have the aggregate skill set <strong>to</strong> per<str<strong>on</strong>g>for</str<strong>on</strong>g>m the migrati<strong>on</strong>?<br />

● Are the project team members adequately motivated <strong>to</strong> per<str<strong>on</strong>g>for</str<strong>on</strong>g>m their role in the<br />

project?<br />

● What will the impact <strong>on</strong> the business be if there is a delay in the project<br />

completi<strong>on</strong>?<br />

● Do you understand the real problems of the business and users that the project is<br />

meant <strong>to</strong> address?<br />

● Have you accounted any possible temporary decrease in productivity due <strong>to</strong><br />

distracti<strong>on</strong>s <str<strong>on</strong>g>for</str<strong>on</strong>g> the project staff from their daily duties <strong>to</strong> support the migrati<strong>on</strong><br />

project or while the cus<strong>to</strong>mers learn <strong>to</strong> use the new applicati<strong>on</strong>?


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 37<br />

●<br />

●<br />

●<br />

●<br />

●<br />

●<br />

●<br />

●<br />

For the applicati<strong>on</strong> suite <strong>to</strong> be migrated, do the vendors of any third-party<br />

applicati<strong>on</strong>s provide technical support in the new envir<strong>on</strong>ment?<br />

Is the applicati<strong>on</strong> dependent <strong>on</strong> third-party software that is not compatible with<br />

Windows?<br />

Does the existing <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> database c<strong>on</strong>tain technologies that <strong>SQL</strong> <strong>Server</strong> cannot<br />

directly implement?<br />

Have you fully c<strong>on</strong>sidered the impact of the migrati<strong>on</strong> <strong>on</strong> other systems or<br />

applicati<strong>on</strong>s that currently rely <strong>on</strong> or interact with the existing soluti<strong>on</strong>?<br />

Does documentati<strong>on</strong> exist <str<strong>on</strong>g>for</str<strong>on</strong>g> all the applicati<strong>on</strong>s and databases, such as<br />

requirements, models (logical, physical), and source code?<br />

How will you handle possibly unproductive situati<strong>on</strong>s from staff members (technical<br />

and operati<strong>on</strong>al) who could be displaced by the migrati<strong>on</strong>?<br />

How will you handle possible scope creep in the migrati<strong>on</strong> project?<br />

Have you c<strong>on</strong>sidered the impact of the migrated applicati<strong>on</strong> failing <strong>to</strong> meet <strong>on</strong>e or<br />

more functi<strong>on</strong>al requirements?<br />

Manage Risks<br />

A good way <strong>to</strong> manage risks is <strong>to</strong> identify or anticipate potential risks be<str<strong>on</strong>g>for</str<strong>on</strong>g>ehand and<br />

come up with a good mitigati<strong>on</strong> and preventi<strong>on</strong> strategy <strong>to</strong> deal with them in case they<br />

occur. The list of potential risks <str<strong>on</strong>g>for</str<strong>on</strong>g> a project is likely <strong>to</strong> be l<strong>on</strong>g, and not all potential risks<br />

can be given the same amount of attenti<strong>on</strong> over the course of the project. It is there<str<strong>on</strong>g>for</str<strong>on</strong>g>e<br />

imperative <strong>to</strong> prioritize all the risks. This allows the team <strong>to</strong> focus more <strong>on</strong> the high priority<br />

risks, come up with suitable mitigati<strong>on</strong> plans <strong>to</strong> prevent them from happening, and create<br />

c<strong>on</strong>tingency plans <strong>to</strong> deal with them effectively if they materialize.<br />

This soluti<strong>on</strong> guide provides a risk assessment spreadsheet <str<strong>on</strong>g>for</str<strong>on</strong>g> you <strong>to</strong> m<strong>on</strong>i<strong>to</strong>r your<br />

project risks based <strong>on</strong> this methodology.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 39<br />

3<br />

Planning Phase<br />

Introducti<strong>on</strong> and Goals<br />

In the Planning Phase, the team defines the soluti<strong>on</strong> in detail — what <strong>to</strong> build, how <strong>to</strong><br />

build it, who will build it, and when it will be built. During this phase, the initial visi<strong>on</strong> and<br />

soluti<strong>on</strong> c<strong>on</strong>cept defined in the Envisi<strong>on</strong>ing Phase is translated in<strong>to</strong> practical<br />

implementati<strong>on</strong> designs and plans <str<strong>on</strong>g>for</str<strong>on</strong>g> how <strong>to</strong> achieve it. Team members draw up<strong>on</strong> their<br />

expertise <strong>to</strong> create individual plans and designs in all areas of the project, ranging from<br />

security <strong>to</strong> budget <strong>to</strong> deployment. Likewise, individual team schedules and associated<br />

dependencies are identified. These plans and schedules are rolled in<strong>to</strong> a master project<br />

plan by the Program Management Role.<br />

The phase c<strong>on</strong>cludes when the project team agrees that the plans are sufficiently welldefined<br />

<strong>to</strong> proceed with development, and the team, business sp<strong>on</strong>sor, and key<br />

stakeholders approve the functi<strong>on</strong>al specificati<strong>on</strong> and the master project plan and<br />

schedule, usually at a milest<strong>on</strong>e meeting. The <str<strong>on</strong>g>for</str<strong>on</strong>g>mal c<strong>on</strong>clusi<strong>on</strong> is marked by the sec<strong>on</strong>d<br />

major project milest<strong>on</strong>e, Project Plans Approved.<br />

The key deliverables <str<strong>on</strong>g>for</str<strong>on</strong>g> the project team <str<strong>on</strong>g>for</str<strong>on</strong>g> the Planning Phase are:<br />

● Functi<strong>on</strong>al specificati<strong>on</strong>. The functi<strong>on</strong>al specificati<strong>on</strong> is the virtual reposi<strong>to</strong>ry of<br />

project and design related artifacts that are created in the Planning Phase. The<br />

artifacts are primarily a result of design activities during the c<strong>on</strong>ceptual design,<br />

logical design, and physical design processes of the Planning Phase. The artifacts<br />

can include models such as case diagrams, usage scenarios, feature list, user<br />

interface screen shots, database design, and so <strong>on</strong>.<br />

The key goals of the functi<strong>on</strong>al specificati<strong>on</strong> are <strong>to</strong> c<strong>on</strong>solidate a comm<strong>on</strong><br />

understanding of the business, design, and user requirements; break down the<br />

problem and modularize the soluti<strong>on</strong> logically; provide a framework <strong>to</strong> plan,<br />

schedule, and build the soluti<strong>on</strong>; and <strong>to</strong> serve as a c<strong>on</strong>tract between the team and<br />

the cus<strong>to</strong>mer and stakeholders.<br />

● Master project plan. The master project plan is a collecti<strong>on</strong> of individual plans that<br />

address tasks per<str<strong>on</strong>g>for</str<strong>on</strong>g>med by each of the six team roles <strong>to</strong> achieve the functi<strong>on</strong>ality<br />

defined in the functi<strong>on</strong>al specificati<strong>on</strong>. The master project plan documents the<br />

strategies the team roles will use <strong>to</strong> complete their work. The soluti<strong>on</strong> c<strong>on</strong>cept that<br />

the team developed in the Envisi<strong>on</strong>ing Phase provides high-level approaches that<br />

are developed in<strong>to</strong> detailed plans in the Planning Phase. See Chapter 2,<br />

"Envisi<strong>on</strong>ing Phase," <str<strong>on</strong>g>for</str<strong>on</strong>g> the discussi<strong>on</strong> of team roles.<br />

● Master project schedule. The individual team schedules apply a time frame <strong>to</strong> the<br />

master plan. The master project schedule synchr<strong>on</strong>izes project schedules across


40<br />

Planning Phase<br />

●<br />

the teams. Aggregating the individual schedules gives the team an overall view of<br />

the project schedule and is the first step <strong>to</strong>ward determining a fixed ship date.<br />

Updated master risk assessment document. The master risk assessment<br />

document that was developed during the Envisi<strong>on</strong>ing Phase is reviewed and<br />

updated regularly during the Planning Phase.<br />

All of these deliverables are living documents, evolving as the project progresses.<br />

Though these documents can be modified, modificati<strong>on</strong>s must follow the change<br />

management policies set up <str<strong>on</strong>g>for</str<strong>on</strong>g> the project during the Envisi<strong>on</strong>ing Phase.<br />

Table 3.1 lists the key activities that the team undertakes in the Planning Phase. The<br />

results of these activities are documented in this phase's deliverables.<br />

Table 3.1: Major Tasks, Deliverables, Owners, and Job Aids<br />

Tasks<br />

Deliverable<br />

where results<br />

are documented<br />

Primary owner<br />

Job Aids<br />

provided in this<br />

soluti<strong>on</strong><br />

Complete detailed<br />

assessment of the<br />

current envir<strong>on</strong>ment<br />

Functi<strong>on</strong>al<br />

specificati<strong>on</strong><br />

Program<br />

Management<br />

Assessing the<br />

Envir<strong>on</strong>ment<br />

Questi<strong>on</strong>naire<br />

Develop the<br />

soluti<strong>on</strong> design and<br />

architecture<br />

Functi<strong>on</strong>al<br />

specificati<strong>on</strong><br />

Program<br />

Management<br />

Validate the<br />

technology<br />

Develop the project<br />

plans<br />

Functi<strong>on</strong>al<br />

specificati<strong>on</strong><br />

Master project plan<br />

Development<br />

Team leads <str<strong>on</strong>g>for</str<strong>on</strong>g> all<br />

roles; plans<br />

c<strong>on</strong>solidated by<br />

Program Manager<br />

* Development Plan<br />

* Test Plan<br />

* Deployment Plan<br />

* Pilot Plan<br />

Create the project<br />

schedules<br />

Set up the<br />

development and<br />

test envir<strong>on</strong>ments<br />

Reassess current<br />

project risks<br />

Master project<br />

schedule<br />

Risk assessment<br />

document<br />

Team leads <str<strong>on</strong>g>for</str<strong>on</strong>g> all<br />

roles<br />

Development and<br />

Test<br />

Program<br />

Management<br />

Migrati<strong>on</strong> Risk<br />

Exposure Rating<br />

Form<br />

Complete a Detailed Assessment of the Existing<br />

Envir<strong>on</strong>ment<br />

To begin the migrati<strong>on</strong> process, an accurate and detailed assessment of the existing<br />

envir<strong>on</strong>ment of your organizati<strong>on</strong> is essential. A high level assessment is carried out in<br />

the Envisi<strong>on</strong>ing Phase. The detailed assessment in the Planning Phase is a follow up<br />

activity.<br />

The in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> collected by this assessment should be comprehensive enough <strong>to</strong> plan<br />

the specific details of the soluti<strong>on</strong> migrati<strong>on</strong>. For instance, a detailed assessment of the<br />

applicati<strong>on</strong> will provide definitive in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <strong>on</strong> whether existing test plans can be reused


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 41<br />

<strong>to</strong> test the soluti<strong>on</strong>. Without this detailed in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> about the existing envir<strong>on</strong>ment,<br />

there is no way <strong>to</strong> accurately estimate the development, test, or deployment plans.<br />

The key elements of the envir<strong>on</strong>ment that need <strong>to</strong> be assessed in detail include:<br />

●<br />

●<br />

●<br />

Applicati<strong>on</strong><br />

Database<br />

Applicati<strong>on</strong> infrastructure<br />

Refer <strong>to</strong> the Assessing the Envir<strong>on</strong>ment Questi<strong>on</strong>naire job aid <strong>to</strong> help you assess the<br />

main areas of the envir<strong>on</strong>ment.<br />

Applicati<strong>on</strong><br />

A detailed assessment should be per<str<strong>on</strong>g>for</str<strong>on</strong>g>med <str<strong>on</strong>g>for</str<strong>on</strong>g> any applicati<strong>on</strong> that is affected by the<br />

migrati<strong>on</strong>. A database applicati<strong>on</strong> migrati<strong>on</strong> project assessment should not be limited <strong>to</strong><br />

assessing the applicati<strong>on</strong> al<strong>on</strong>e; it should also include database c<strong>on</strong>nectivity.<br />

Assessment activities related <strong>to</strong> the database should include the following:<br />

● Note all database interfaces used by the applicati<strong>on</strong>s and their types (OCI, ODBC,<br />

and so <strong>on</strong>).<br />

● Note the relati<strong>on</strong>ship between applicati<strong>on</strong>s and databases. For example, note if a<br />

database supports multiple applicati<strong>on</strong>s, or an applicati<strong>on</strong> c<strong>on</strong>nects <strong>to</strong> multiple<br />

databases.<br />

● Identify all the database, schemas, and schema objects that the applicati<strong>on</strong><br />

interacts with.<br />

● Note the pro<strong>to</strong>col that is used by the applicati<strong>on</strong> <strong>to</strong> communicate with the<br />

database. <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> supports TCP/IP, TCP/IP with SSL, and named pipes.<br />

● Identify all encrypti<strong>on</strong> methods employed by the applicati<strong>on</strong>s with the databases.<br />

● Identify the security features of the database used by the applicati<strong>on</strong>s, such as<br />

authenticati<strong>on</strong>, password features, single sign <strong>on</strong>, and so <strong>on</strong>.<br />

● Determine if there are any other network-related security authenticati<strong>on</strong> methods<br />

used with the current applicati<strong>on</strong>. Comm<strong>on</strong> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> authenticati<strong>on</strong> methods include<br />

Kerberos, Radius, DES Algorithm, RSA, and Cybersafe.<br />

● Note the data sources in use, such as ODBC, OLE DB, and ADO.<br />

In additi<strong>on</strong> <strong>to</strong> questi<strong>on</strong>s related <strong>to</strong> database c<strong>on</strong>nectivity, here are some general<br />

applicati<strong>on</strong> assessment questi<strong>on</strong>s that you may need <strong>to</strong> ask.<br />

● Identify the programming language used <str<strong>on</strong>g>for</str<strong>on</strong>g> the main applicati<strong>on</strong> as well as any<br />

supplementary programs.<br />

● Identify the plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m support (hardware and operating system), architecture, and<br />

comp<strong>on</strong>ent interfaces of the existing applicati<strong>on</strong>.<br />

● Locate any existing in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> about the applicati<strong>on</strong>. Is the source code<br />

available? Other items that may help plan <str<strong>on</strong>g>for</str<strong>on</strong>g> migrati<strong>on</strong> include test scripts,<br />

documentati<strong>on</strong>, process flow charts, and use cases.<br />

● Record any dependencies and characteristics, such as third-party libraries, <strong>UNIX</strong><br />

utilities, or path names. Also, determine if the <strong>UNIX</strong> applicati<strong>on</strong> uses X Windows,<br />

Motif, or xrt libraries.<br />

● Determine the security architecture of the applicati<strong>on</strong>. This in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> is important<br />

because features and implementati<strong>on</strong>s are different between Microsoft Windows®<br />

and <strong>UNIX</strong> plat<str<strong>on</strong>g>for</str<strong>on</strong>g>ms.<br />

● Record any encrypti<strong>on</strong> pro<strong>to</strong>cols currently being used. SSL and PGP are two<br />

comm<strong>on</strong> encrypti<strong>on</strong> methods.


42<br />

Planning Phase<br />

●<br />

●<br />

Verify if the applicati<strong>on</strong> uses daem<strong>on</strong> processes. This in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> is required<br />

because <strong>UNIX</strong> applicati<strong>on</strong>s can be started in the background and will c<strong>on</strong>tinue <strong>to</strong><br />

run even after a user logs off the system. Using applicati<strong>on</strong> services in Windows<br />

2003 provides similar functi<strong>on</strong>ality.<br />

Check <str<strong>on</strong>g>for</str<strong>on</strong>g> any file system dependencies. This in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> is required because<br />

<strong>UNIX</strong> and Windows use different file access methods.<br />

For more in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <strong>on</strong> assessing the applicati<strong>on</strong> be<str<strong>on</strong>g>for</str<strong>on</strong>g>e migrating from <strong>UNIX</strong> <strong>to</strong><br />

Windows, refer <strong>to</strong> the <strong>UNIX</strong> Applicati<strong>on</strong> Migrati<strong>on</strong> <str<strong>on</strong>g>Guide</str<strong>on</strong>g>, available at<br />

http://go.microsoft.com/fwlink/?LinkId=30832.<br />

Database<br />

To migrate an <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> database <strong>to</strong> Microsoft <strong>SQL</strong> <strong>Server</strong> successfully, the project team<br />

must assess the technical details of the current system.<br />

The following assessment activities should be per<str<strong>on</strong>g>for</str<strong>on</strong>g>med <strong>on</strong> the existing <str<strong>on</strong>g>Oracle</str<strong>on</strong>g><br />

database:<br />

● Identify and record the database name and all c<strong>on</strong>figurati<strong>on</strong> in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong>.<br />

● Determine the type of database being used. Comm<strong>on</strong> database types include<br />

Decisi<strong>on</strong> Support System (DSS), Online Transacti<strong>on</strong> Processing (OLTP), or a<br />

combinati<strong>on</strong> of the two.<br />

● Locate any existing design documents, such as data models, database creati<strong>on</strong><br />

scripts, or data definiti<strong>on</strong> language (DDL) specificati<strong>on</strong>s.<br />

● Record detailed in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <strong>on</strong> existing database structures, including tables,<br />

views, s<strong>to</strong>red procedures, indexes, users, and roles.<br />

● Identify and record the current locati<strong>on</strong> of database files, such as S<strong>to</strong>rage Area<br />

<strong>Net</strong>work (SAN), <strong>Net</strong>work Attached S<strong>to</strong>rage (NAS), or local attached s<strong>to</strong>rage.<br />

● Identify and record the disk space c<strong>on</strong>sumed by the existing database files. Also,<br />

obtain estimates of growth rate of the database files.<br />

● Evaluate the existing backup soluti<strong>on</strong>, including the frequency and type of backup<br />

(full, archive log, and so <strong>on</strong>).<br />

● Assess the database c<strong>on</strong>figurati<strong>on</strong> in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong>, including the sort order and<br />

character set.<br />

● Examine the frequency of data dumps and log dumps.<br />

● Determine the dependencies of the database <strong>on</strong> other databases or plat<str<strong>on</strong>g>for</str<strong>on</strong>g>ms.<br />

Comm<strong>on</strong> examples include distributed databases, replicati<strong>on</strong>, data marts, and data<br />

warehouses.<br />

● Identify and analyze the server side scripts in use <str<strong>on</strong>g>for</str<strong>on</strong>g> activities such as data loads,<br />

batch processing, reporting, and administrati<strong>on</strong>.<br />

The Migrati<strong>on</strong> Analyzer <strong>to</strong>ol, which is a part of the <strong>SQL</strong> <strong>Server</strong> Migrati<strong>on</strong> Assistant<br />

(SSMA), analyzes the source <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> databases and produces vital statistics <strong>on</strong> the size<br />

and complexity of the migrati<strong>on</strong>. This <strong>to</strong>ol can be downloaded from<br />

http://www.microsoft.com/sql/migrati<strong>on</strong>. The beta versi<strong>on</strong> of this <strong>to</strong>ol is available as of the<br />

date of publishing this soluti<strong>on</strong>. Versi<strong>on</strong> 1.0 of the <strong>to</strong>ol is slated <strong>to</strong> be available in June<br />

2005<br />

Applicati<strong>on</strong> Infrastructure<br />

The applicati<strong>on</strong> infrastructure can be broadly classified as server-related and networkrelated.<br />

<strong>Server</strong>-related infrastructure relates directly <strong>to</strong> the hardware and software <strong>on</strong> the<br />

server. <strong>Server</strong>-related items include operating systems, processors, memory, s<strong>to</strong>rage,


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 43<br />

tape drives, and file systems. Examples of network-related infrastructure include routers,<br />

firewalls, switches, domain name servers (DNS), and virtual private networks (VPN).<br />

Security infrastructure is classified under both server-related and network-related<br />

infrastructure. Comm<strong>on</strong> items within the server security infrastructure are <strong>Net</strong>work<br />

In<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> Services (NIS and NIS+) and Lightweight Direc<strong>to</strong>ry Access Pro<strong>to</strong>col (LDAP).<br />

The following assessment activities should be per<str<strong>on</strong>g>for</str<strong>on</strong>g>med <str<strong>on</strong>g>for</str<strong>on</strong>g> server-related infrastructure:<br />

●<br />

●<br />

●<br />

●<br />

Check the capacity and per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance of the servers and server clusters of the<br />

existing envir<strong>on</strong>ment. Also verify if the clusters are situated in single or multiple<br />

locati<strong>on</strong>s.<br />

The hardware c<strong>on</strong>figurati<strong>on</strong> details need <strong>to</strong> be gathered <str<strong>on</strong>g>for</str<strong>on</strong>g> any dependencies that<br />

might affect the migrati<strong>on</strong>, including architecture (32-bit versus 64-bit, hyperthreading,<br />

hybrid), processor speed, number of CPUs, and the number of available<br />

sockets <str<strong>on</strong>g>for</str<strong>on</strong>g> upgrades.<br />

Record any pertinent in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> about the RAM installed in the server, including<br />

size, c<strong>on</strong>figurati<strong>on</strong>, and number of open slots available <str<strong>on</strong>g>for</str<strong>on</strong>g> upgrades.<br />

Verify disk s<strong>to</strong>rage needs <str<strong>on</strong>g>for</str<strong>on</strong>g> database files and the disk space c<strong>on</strong>sumed <str<strong>on</strong>g>for</str<strong>on</strong>g> the<br />

existing database files. Identify the s<strong>to</strong>rage requirements, such as:<br />

● Amount of space needed <str<strong>on</strong>g>for</str<strong>on</strong>g> current and growth fac<strong>to</strong>rs<br />

● Spindle RPM (disks: 15000 RPM versus 10000 RPM; SAN: 1 gbps versus 2<br />

gbps)<br />

● Throughput (theoretical I/O, current I/O, anticipated I/O) <str<strong>on</strong>g>for</str<strong>on</strong>g> each element of<br />

the s<strong>to</strong>rage system<br />

● Disk size(s)<br />

● RAID levels<br />

● S<strong>to</strong>rage Architecture (SAN, NAS, external s<strong>to</strong>rage, internal s<strong>to</strong>rage)<br />

The following assessment activities should be per<str<strong>on</strong>g>for</str<strong>on</strong>g>med <str<strong>on</strong>g>for</str<strong>on</strong>g> network-related<br />

infrastructure:<br />

● Identify the existing network pro<strong>to</strong>cols and network bandwidth.<br />

● Examine the routers, switches, and firewalls <str<strong>on</strong>g>for</str<strong>on</strong>g> the existing soluti<strong>on</strong>. Verify the<br />

c<strong>on</strong>figurati<strong>on</strong> and locati<strong>on</strong> of firewalls and proxies.<br />

● Assess the network <strong>to</strong>pology that exists in the organizati<strong>on</strong>.<br />

● In<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> about the network infrastructure needs <strong>to</strong> be identified, including the<br />

logical organizati<strong>on</strong> of the network, name and address resoluti<strong>on</strong> methods, and<br />

network naming c<strong>on</strong>venti<strong>on</strong>s.<br />

● Analyze the network sites and the bandwidth between the sites. This in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong><br />

can be used <strong>to</strong> plan optimum strategies and schedules <str<strong>on</strong>g>for</str<strong>on</strong>g> installati<strong>on</strong> and<br />

deployment.<br />

● Assess the trust relati<strong>on</strong>ships and policy restricti<strong>on</strong>s of the existing soluti<strong>on</strong>.<br />

Develop the <str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> Design and Architecture<br />

The Planning Phase of the MSF Process Model includes three design processes:<br />

c<strong>on</strong>ceptual, logical, and physical. These three processes are not per<str<strong>on</strong>g>for</str<strong>on</strong>g>med in parallel.<br />

Instead, their starting and ending points are staggered. These processes are dependent<br />

<strong>on</strong> each other. The logical design is dependent <strong>on</strong> the c<strong>on</strong>ceptual design, and the<br />

physical design is dependent <strong>on</strong> the logical design. Table 3.2 compares the three design<br />

processes.


44<br />

Planning Phase<br />

Table 3.2: Comparing C<strong>on</strong>ceptual, Logical, and Physical Design<br />

Type of Design Perspective Purpose<br />

C<strong>on</strong>ceptual Design<br />

Logical Design<br />

Physical Design<br />

Views the problem from the<br />

perspective of the user and<br />

business<br />

Views the soluti<strong>on</strong> from the<br />

perspective of the<br />

design/architecture team<br />

Views the soluti<strong>on</strong> from the<br />

perspective of the<br />

developers<br />

Defines the problem and<br />

soluti<strong>on</strong> in terms of usage<br />

scenarios and refined<br />

requirements<br />

Defines the soluti<strong>on</strong> as a<br />

logical set of co-operating<br />

objects and services<br />

Defines the soluti<strong>on</strong><br />

comp<strong>on</strong>ents and<br />

technologies<br />

In a migrati<strong>on</strong> project it is quite likely that you already have detailed design documents <str<strong>on</strong>g>for</str<strong>on</strong>g><br />

the existing system. These documents can provide an excellent starting point <str<strong>on</strong>g>for</str<strong>on</strong>g> your<br />

design process. Enhancements can be made <strong>to</strong> account <str<strong>on</strong>g>for</str<strong>on</strong>g> the additi<strong>on</strong>al requirements<br />

and functi<strong>on</strong>ality <str<strong>on</strong>g>for</str<strong>on</strong>g> the new system.<br />

Build the C<strong>on</strong>ceptual Design<br />

The first design process in the Planning Phase is c<strong>on</strong>ceptual design. Once completed,<br />

the c<strong>on</strong>ceptual design is used in the creati<strong>on</strong> of the logical and physical design<br />

processes.<br />

C<strong>on</strong>ceptual design is the process of gathering, analyzing, and prioritizing business and<br />

user perspectives of the problem and the soluti<strong>on</strong>, and then creating a high level<br />

representati<strong>on</strong> of the soluti<strong>on</strong> in the <str<strong>on</strong>g>for</str<strong>on</strong>g>m of detailed requirements. The team gathers high<br />

level requirements during the Envisi<strong>on</strong>ing Phase and documents them in the <str<strong>on</strong>g>for</str<strong>on</strong>g>m of use<br />

cases and usage scenarios. While producing the c<strong>on</strong>ceptual design, the team refines<br />

these requirements.<br />

Develop Detailed Requirements<br />

A c<strong>on</strong>ceptual design records the system requirements in terms of the following<br />

requirements:<br />

● Business requirements<br />

● User requirements<br />

● System requirements<br />

● Operati<strong>on</strong>al requirements<br />

Each of these is described under the following headings<br />

Business Requirements<br />

Business requirements describe the organizati<strong>on</strong>'s needs and expectati<strong>on</strong>s <str<strong>on</strong>g>for</str<strong>on</strong>g> the<br />

soluti<strong>on</strong>. These requirements exist at the managerial decisi<strong>on</strong>-making level and provide<br />

the c<strong>on</strong>text in which the soluti<strong>on</strong> will operate.<br />

Some example business requirements include:<br />

● The database migrati<strong>on</strong> from <strong>UNIX</strong> <strong>to</strong> Windows should be completed in the given<br />

time frame.<br />

● The existing business rules and policies should be maintained <strong>on</strong> the new system.<br />

● Ef<str<strong>on</strong>g>for</str<strong>on</strong>g>t required <str<strong>on</strong>g>for</str<strong>on</strong>g> migrati<strong>on</strong> should justify the cost incurred.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 45<br />

●<br />

The existing level of per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance and functi<strong>on</strong>ality should be maintained after the<br />

migrati<strong>on</strong>, including disaster recovery, availability, and scalability.<br />

User Requirements<br />

User requirements define the n<strong>on</strong>functi<strong>on</strong>al aspect of the user's interacti<strong>on</strong> with the<br />

soluti<strong>on</strong>. They help you <strong>to</strong> determine the user interface and per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance expectati<strong>on</strong>s of<br />

the soluti<strong>on</strong> in terms of its reliability, availability, and accessibility. In additi<strong>on</strong>, the user<br />

requirements help you identify the training that the users will need <strong>to</strong> effectively use the<br />

soluti<strong>on</strong>.<br />

Some example user requirements include:<br />

●<br />

●<br />

●<br />

The user should be able <strong>to</strong> use the same or similar interface as the applicati<strong>on</strong><br />

running <strong>on</strong> the <strong>UNIX</strong> system <strong>to</strong> minimize user retraining.<br />

The time taken <strong>to</strong> retrieve in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> from the system should not increase.<br />

There should be comprehensive user manuals <str<strong>on</strong>g>for</str<strong>on</strong>g> the new system. Training<br />

manuals should also be c<strong>on</strong>sidered <str<strong>on</strong>g>for</str<strong>on</strong>g> new users.<br />

System Requirements<br />

System requirements specify the detailed transacti<strong>on</strong>s and their sequence in the system.<br />

The requirements help the project team define how the new soluti<strong>on</strong> will interact with the<br />

existing systems. Some example system requirements include:<br />

●<br />

●<br />

●<br />

After the migrati<strong>on</strong>, the new system should c<strong>on</strong>tinue <strong>to</strong> interoperate with<br />

applicati<strong>on</strong>s as it did <strong>on</strong> the <strong>UNIX</strong> plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m.<br />

The system should not require a user credential other than the credentials passed<br />

from logging <strong>on</strong><strong>to</strong> the corporate network (single sign <strong>on</strong>).<br />

The system should support internal and remote users.<br />

Operati<strong>on</strong>al Requirements<br />

Operati<strong>on</strong>al requirements describe what the soluti<strong>on</strong> must deliver <strong>to</strong> maximize operability<br />

and improve service delivery with reduced downtime and risks. Some example<br />

operati<strong>on</strong>al requirements include:<br />

●<br />

●<br />

●<br />

●<br />

●<br />

The system should allow administra<strong>to</strong>rs <strong>to</strong> per<str<strong>on</strong>g>for</str<strong>on</strong>g>m their tasks both <strong>on</strong>-site and<br />

remotely.<br />

The system should be able <strong>to</strong> recover from critical failure without major impact and<br />

within service levels.<br />

The system should include a process <str<strong>on</strong>g>for</str<strong>on</strong>g> managing the <strong>to</strong>tal throughput and<br />

resp<strong>on</strong>se time within the stated service levels.<br />

The system should be able <strong>to</strong> handle varying levels of user load and transacti<strong>on</strong>s.<br />

In additi<strong>on</strong>, the site should be designed so that it can be modified and upgraded<br />

without affecting availability and per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance.<br />

Large clients should be separated with respect <strong>to</strong> database infrastructure <strong>to</strong><br />

minimize the impact <strong>on</strong> maintenance and availability.<br />

Build the Logical Design<br />

The logical design is the sec<strong>on</strong>d step in creating the soluti<strong>on</strong> design. After identifying the<br />

business and user needs in the c<strong>on</strong>ceptual design, the logical design defines how the<br />

different parts of the soluti<strong>on</strong> will coordinate and work <strong>to</strong>gether. The logical design<br />

defines the parts of the system, provides a framework <strong>to</strong> hold all the parts of the system<br />

<strong>to</strong>gether, and illustrates how the system interacts with the users and other systems.


46<br />

Planning Phase<br />

While creating the logical design, the team takes in<strong>to</strong> account all the business, user,<br />

operati<strong>on</strong>al and system requirements that state the need <str<strong>on</strong>g>for</str<strong>on</strong>g> security, auditing, logging,<br />

scalability, state management, error handling, licensing, globalizati<strong>on</strong>, applicati<strong>on</strong><br />

architecture, integrati<strong>on</strong> with other systems, and so <strong>on</strong>.<br />

There are several ways <strong>to</strong> represent the logical design of a system. A comm<strong>on</strong>ly used<br />

visual modeling language is Unified Modeling Language (UML). A detailed discussi<strong>on</strong> of<br />

UML is out of the scope of this soluti<strong>on</strong>. For more in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <strong>on</strong> UML, refer <strong>to</strong> The<br />

Unified Modeling Language User <str<strong>on</strong>g>Guide</str<strong>on</strong>g> (Booch, Jacobs<strong>on</strong>, and Rumbaugh 1999) and<br />

Use Case Driven Object Modeling with UML: A Practical Approach (Rosenberg and Scott<br />

1999).<br />

Figure 3.1 shows a sample logical design <str<strong>on</strong>g>for</str<strong>on</strong>g> a system using the Logical Object Model, as<br />

defined by UML. The sample design represents the system in terms of:<br />

● Objects. These are people or things in the system. "Order" is an example of an<br />

object in Figure 3.1.<br />

● Services. These are the behavior or functi<strong>on</strong>ality associated with any object. For<br />

example, "Track Status()" is a service provided by the "Order" object in Figure 3.1.<br />

● Attributes. These are characteristics or properties of the objects. For example,<br />

"Order ID" and "Ship Date" are attributes of the "Order" object in Figure 3.1<br />

● Relati<strong>on</strong>ships. These represent ways in which objects are linked with each other.<br />

For example, the object Order and the object Order line item are shown <strong>to</strong> have an<br />

associative relati<strong>on</strong>ship in Figure 3.1 by a thick line. This shows that they are<br />

related and a change <strong>to</strong> <strong>on</strong>e affects the other.<br />

The objects, services, attributes and relati<strong>on</strong>ships can be obtained from the detailed<br />

usage scenarios that were developed in the c<strong>on</strong>ceptual design phase.<br />

The logical design represents a logical view of the complete system. Individual teams,<br />

such as those <str<strong>on</strong>g>for</str<strong>on</strong>g> User Interface (UI) development, the database development, and the<br />

applicati<strong>on</strong> development can take this representati<strong>on</strong> and start <strong>to</strong> build the detailed<br />

designs <str<strong>on</strong>g>for</str<strong>on</strong>g> their domain when making the physical design.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 47<br />

Figure 3.1<br />

Creating a logical design <str<strong>on</strong>g>for</str<strong>on</strong>g> the applicati<strong>on</strong><br />

Logical Design C<strong>on</strong>siderati<strong>on</strong>s<br />

The logical design <str<strong>on</strong>g>for</str<strong>on</strong>g> an <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> database migrati<strong>on</strong> project must take in<strong>to</strong> account the<br />

changes that will occur as a result of migrati<strong>on</strong> from <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong>. The following<br />

items should be c<strong>on</strong>sidered:<br />

● Are there any dependencies between client applicati<strong>on</strong>s and database<br />

c<strong>on</strong>nectivity?<br />

● Do <strong>UNIX</strong> scripts support the client applicati<strong>on</strong>s?<br />

● How are communicati<strong>on</strong>s between the applicati<strong>on</strong> and database secured internally<br />

and over the internet?<br />

● How is data distributed across multiple databases and multiple servers?


48<br />

Planning Phase<br />

Examining the c<strong>on</strong>ceptual design of the client applicati<strong>on</strong> will provide an understanding of<br />

how it operates and is structured. This in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> is used <strong>to</strong> create the physical design<br />

of the soluti<strong>on</strong>. Two additi<strong>on</strong>al design studies that may assist in creating the physical<br />

design are discussed in the following secti<strong>on</strong>.<br />

High Level User Interface and Database Design<br />

Using the objects, services, attributes, and relati<strong>on</strong>ships identified in the logical design of<br />

the system, the team might decide <strong>to</strong> create a high-level user interface and database<br />

design.<br />

The list of objects and services gives the team an idea about the kind of functi<strong>on</strong>ality<br />

expected by the users. The team can use this in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <strong>to</strong> design user interface<br />

elements such as butt<strong>on</strong>s, text fields, and menu items.<br />

Similarly, the object and attribute in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> of the logical design can be used <strong>to</strong> develop<br />

an initial database design equivalent <strong>to</strong> the <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> database being migrated.<br />

Build the Physical Design<br />

Physical design is the process of describing the comp<strong>on</strong>ents, services, and technologies<br />

of the soluti<strong>on</strong> from the perspective of the development team. The goal of the design is <strong>to</strong><br />

provide clarity and detail <str<strong>on</strong>g>for</str<strong>on</strong>g> each of the development teams <strong>to</strong> develop their comp<strong>on</strong>ents,<br />

be it the user interface, business logic, database, or infrastructure.<br />

The physical design should include:<br />

● Class definiti<strong>on</strong> of applicati<strong>on</strong>s.<br />

● Database schema <str<strong>on</strong>g>for</str<strong>on</strong>g> the soluti<strong>on</strong>.<br />

● Baseline deployment model that provides:<br />

● The network <strong>to</strong>pology, showing hardware locati<strong>on</strong>s and interc<strong>on</strong>necti<strong>on</strong>s.<br />

● The data and comp<strong>on</strong>ent technology, which indicates the locati<strong>on</strong>s of the<br />

soluti<strong>on</strong> comp<strong>on</strong>ents, services, and data s<strong>to</strong>rage in relati<strong>on</strong> <strong>to</strong> the network<br />

<strong>to</strong>pology.<br />

●<br />

●<br />

Comp<strong>on</strong>ent specificati<strong>on</strong>s that include internal structure of comp<strong>on</strong>ents and<br />

comp<strong>on</strong>ent interfaces.<br />

Programming models that identify implementati<strong>on</strong> guidelines <str<strong>on</strong>g>for</str<strong>on</strong>g> threading, error<br />

handling, security, and code documentati<strong>on</strong>.<br />

A detailed discussi<strong>on</strong> of physical design is out of scope of this soluti<strong>on</strong>. For detailed<br />

guidance <strong>on</strong> designing the data layer, designing the presentati<strong>on</strong> layer, and designing the<br />

security specificati<strong>on</strong>s, refer <strong>to</strong> chapters 7 through 9 of Analyzing Requirements and<br />

Defining Microsoft .NET <str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> Architectures (Microsoft Press 2003).<br />

The physical design diagram allows you <strong>to</strong> see how all the comp<strong>on</strong>ents c<strong>on</strong>nect <strong>to</strong>gether.<br />

For completeness, it may include infrastructure elements outside of the scope of the<br />

project such as firewalls or network c<strong>on</strong>necti<strong>on</strong>s that are not directly related <strong>to</strong> the<br />

soluti<strong>on</strong>. It will help prove the security of the system, and may show potential throughput<br />

bottlenecks, or highlight single points of failure.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 49<br />

Figure 3.2 shows a sample physical design diagram. Your design c<strong>on</strong>siderati<strong>on</strong>s will<br />

require you <strong>to</strong> modify this example.<br />

Figure 3.2<br />

Creating a physical design <str<strong>on</strong>g>for</str<strong>on</strong>g> the applicati<strong>on</strong> and database.<br />

The following secti<strong>on</strong>s will help you plan <str<strong>on</strong>g>for</str<strong>on</strong>g> a migrati<strong>on</strong> by identifying the various<br />

comp<strong>on</strong>ents of the physical design and outlining the typical design c<strong>on</strong>siderati<strong>on</strong>s that<br />

are part of a typical migrati<strong>on</strong>.


50<br />

Planning Phase<br />

Incorporate Design C<strong>on</strong>siderati<strong>on</strong>s<br />

While migrating, you may want <strong>to</strong> utilize some of the advanced functi<strong>on</strong>s that are<br />

incorporated in<strong>to</strong> <strong>SQL</strong> <strong>Server</strong> and Windows <strong>Server</strong> 2003. Some references may exist<br />

<str<strong>on</strong>g>for</str<strong>on</strong>g> Windows® 2000 but the in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> also applies <strong>to</strong> Windows <strong>Server</strong> 2003. For more<br />

in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong>, refer <strong>to</strong> the following resources:<br />

● Designing <str<strong>on</strong>g>for</str<strong>on</strong>g> scalability<br />

http://msdn.microsoft.com/library/default.asp?url=/library/enus/architec/8_ar_sa2_8rnd.asp<br />

● Designing <str<strong>on</strong>g>for</str<strong>on</strong>g> availability<br />

http://www.microsoft.com/technet/prodtechnol/sql/2000/plan/ssmsam.mspx<br />

● Designing <str<strong>on</strong>g>for</str<strong>on</strong>g> reliability<br />

http://www.microsoft.com/mscorp/twc/reliability/default.mspx<br />

● Designing <str<strong>on</strong>g>for</str<strong>on</strong>g> per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance<br />

http://www.microsoft.com/sql/evaluati<strong>on</strong>/compare/benchmarks.asp<br />

http://www.microsoft.com/technet/prodtechnol/sql/2000/maintain/ansvcspg.mspx<br />

● Designing <str<strong>on</strong>g>for</str<strong>on</strong>g> interoperability<br />

http://www.microsoft.com/technet/prodtechnol/sql/2000/deploy/sqlorcle.mspx<br />

Hardware Design C<strong>on</strong>siderati<strong>on</strong>s<br />

In additi<strong>on</strong> <strong>to</strong> the advanced features available in <strong>SQL</strong> <strong>Server</strong>, there are many software<br />

<strong>to</strong>ols available <strong>to</strong> assist in ensuring that the correct hardware is acquired. Some of these<br />

<strong>to</strong>ols are listed here:<br />

● Microsoft Datasizer Tool. This spreadsheet helps estimate table sizes. For more<br />

in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong>, refer <strong>to</strong><br />

http://www.microsoft.com/downloads/details.aspx?FamilyId=564C5704-D4F5-<br />

4EE8-9F3C-CB429499D075&displaylang=en.<br />

● Dell Powermatch sizing <strong>to</strong>ols. These <strong>to</strong>ols are available <strong>to</strong> assist in selecting Dell<br />

hardware <str<strong>on</strong>g>for</str<strong>on</strong>g> use with <strong>SQL</strong> <strong>Server</strong>. For more in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong>, refer <strong>to</strong><br />

http://www1.us.dell.com/c<strong>on</strong>tent/<strong>to</strong>pics/global.aspx/alliances/en/sizing?c=us&cs=5<br />

55&l=en&s=biz.<br />

● HP sizing <strong>to</strong>ols. These <strong>to</strong>ols are available <strong>to</strong> assist in selecting HP servers <str<strong>on</strong>g>for</str<strong>on</strong>g> use<br />

with <strong>SQL</strong> <strong>Server</strong>. For more in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong>, refer <strong>to</strong><br />

http://h71019.www7.hp.com/ActiveAnswers/cache/70729-0-0-0-121.aspx.<br />

● Unisys System Sizing Tools <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>SQL</strong> <strong>Server</strong>. These <strong>to</strong>ols are available <strong>to</strong> assist<br />

in c<strong>on</strong>figuring Unisys servers <str<strong>on</strong>g>for</str<strong>on</strong>g> use with <strong>SQL</strong> <strong>Server</strong>. For more in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong>, refer<br />

<strong>to</strong><br />

http://unisys.com/products/es7000__servers/business__soluti<strong>on</strong>s/oltp__database_<br />

_server/sql__server__resources.htm.<br />

Validate the Technology<br />

Parallel <strong>to</strong> the design process, the team will often validate the technologies being used in<br />

the soluti<strong>on</strong>. During technology validati<strong>on</strong>, the team evaluates the products or<br />

technologies <strong>to</strong> ensure that they work according <strong>to</strong> specificati<strong>on</strong>s provided by their vendor<br />

and that they will meet the business needs <str<strong>on</strong>g>for</str<strong>on</strong>g> the specific soluti<strong>on</strong> scenario.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 51<br />

<strong>SQL</strong> <strong>Server</strong> Editi<strong>on</strong>s and Features<br />

While <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> is available in Pers<strong>on</strong>al, Standard, and Enterprise Editi<strong>on</strong>s,<br />

<strong>SQL</strong> <strong>Server</strong> 2000 is available in the following editi<strong>on</strong>s:<br />

● <strong>SQL</strong> <strong>Server</strong> 2000 Enterprise Editi<strong>on</strong> (64-bit)<br />

● <strong>SQL</strong> <strong>Server</strong> 2000 Enterprise Editi<strong>on</strong><br />

● <strong>SQL</strong> <strong>Server</strong> 2000 Standard Editi<strong>on</strong><br />

● <strong>SQL</strong> <strong>Server</strong> 2000 Developer Editi<strong>on</strong><br />

All editi<strong>on</strong>s of Windows® XP and Windows <strong>Server</strong> 2003 include support <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>SQL</strong> <strong>Server</strong>.<br />

Support exists <str<strong>on</strong>g>for</str<strong>on</strong>g> many earlier versi<strong>on</strong>s of Windows, as well.<br />

As with <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>, each editi<strong>on</strong> is distinguished primarily by the availability of certain<br />

features, progressing from Pers<strong>on</strong>al Editi<strong>on</strong> <strong>to</strong> Enterprise Editi<strong>on</strong>. <strong>SQL</strong> <strong>Server</strong> also offers<br />

several different editi<strong>on</strong>s. Each editi<strong>on</strong> provides functi<strong>on</strong>ality based <strong>on</strong> scale as shown in<br />

Table 3.3.<br />

Table 3.3: <strong>SQL</strong> <strong>Server</strong> 2000 Editi<strong>on</strong>s Compared<br />

OS<br />

Requirements<br />

and Scalability<br />

Operating System<br />

Enterprise (64-<br />

bit) Editi<strong>on</strong><br />

* Windows <strong>Server</strong><br />

2003 Enterprise<br />

Editi<strong>on</strong><br />

* Windows <strong>Server</strong><br />

2003 Datacenter<br />

Editi<strong>on</strong><br />

Scalability * Up <strong>to</strong> 64<br />

processors<br />

* Up <strong>to</strong> 512 GB of<br />

memory<br />

* Maximum<br />

database size of<br />

1,048,516 TB<br />

Enterprise<br />

Editi<strong>on</strong><br />

* Windows <strong>Server</strong><br />

2003 Standard<br />

Editi<strong>on</strong><br />

* Windows <strong>Server</strong><br />

2003 Enterprise<br />

Editi<strong>on</strong><br />

* Windows <strong>Server</strong><br />

2003 Datacenter<br />

Editi<strong>on</strong><br />

* Up <strong>to</strong> 32<br />

processors<br />

* Up <strong>to</strong> 64 GB of<br />

memory<br />

* Maximum<br />

database size of<br />

1,048,516 TB<br />

Standard Editi<strong>on</strong><br />

* Windows <strong>Server</strong><br />

2003 Standard<br />

Editi<strong>on</strong><br />

* Windows <strong>Server</strong><br />

2003 Enterprise<br />

Editi<strong>on</strong><br />

* Windows <strong>Server</strong><br />

2003 Datacenter<br />

Editi<strong>on</strong><br />

* Up <strong>to</strong> 4<br />

processors<br />

* Up <strong>to</strong> 2 GB of<br />

memory<br />

* Maximum<br />

database size of<br />

1,048,516 TB<br />

For a detailed preview of all the <strong>SQL</strong> <strong>Server</strong> features and supporting <strong>to</strong>ols, refer <strong>to</strong><br />

http://www.microsoft.com/sql/evaluati<strong>on</strong>/features/byfuncti<strong>on</strong>/default.asp.<br />

For in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <strong>on</strong> features by editi<strong>on</strong>, refer <strong>to</strong><br />

http://www.microsoft.com/sql/evaluati<strong>on</strong>/features/choosing.asp.<br />

While migrating <strong>to</strong> <strong>SQL</strong> <strong>Server</strong>, the choice of editi<strong>on</strong> of <strong>SQL</strong> <strong>Server</strong> that is required <strong>to</strong><br />

support the demands <strong>on</strong> the database has <strong>to</strong> be validated. Refer <strong>to</strong> the following<br />

resource <str<strong>on</strong>g>for</str<strong>on</strong>g> a whitepaper that can aid in choosing the appropriate editi<strong>on</strong> of <strong>SQL</strong> <strong>Server</strong>:<br />

http://www.microsoft.com/sql/techinfo/planning/<strong>SQL</strong>ReskChooseEd.asp.


52<br />

Planning Phase<br />

Windows <strong>Server</strong> 2003<br />

Windows <strong>Server</strong> 2003 is available in the following editi<strong>on</strong>s:<br />

●<br />

●<br />

●<br />

●<br />

Windows <strong>Server</strong> 2003, Standard Editi<strong>on</strong>. For departmental and standard corporate<br />

workloads.<br />

Windows <strong>Server</strong> 2003, Enterprise Editi<strong>on</strong>. For critical or heavy server workloads.<br />

Windows <strong>Server</strong> 2003, Datacenter Editi<strong>on</strong>. For high levels of scalability and<br />

reliability.<br />

Windows <strong>Server</strong> 2003, Web Editi<strong>on</strong>. For Web serving and hosting.<br />

The goals of the Windows <strong>Server</strong> System are <strong>to</strong> promote operati<strong>on</strong>al efficiencies through<br />

simplified deployment, management, and security; <strong>to</strong> ensure high levels of dependability,<br />

per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance, and productivity <str<strong>on</strong>g>for</str<strong>on</strong>g> applicati<strong>on</strong> development; and <strong>to</strong> seamlessly c<strong>on</strong>nect<br />

in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong>, people, and systems.<br />

For more in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <strong>on</strong> the different editi<strong>on</strong>s of Windows <strong>Server</strong> 2003, refer <strong>to</strong><br />

http://www.microsoft.com/windowsserver2003/evaluati<strong>on</strong>/features/compareediti<strong>on</strong>s.mspx.<br />

Technical Proof of C<strong>on</strong>cept<br />

After validating the technologies, the team creates a pro<strong>to</strong>type project using a small<br />

database that c<strong>on</strong>tains a representative sample of the data, tables, and other objects<br />

found in the producti<strong>on</strong> databases. This process will validate the approach <str<strong>on</strong>g>for</str<strong>on</strong>g> the<br />

migrati<strong>on</strong> and provide useful experience when using the various <strong>to</strong>ols that have been<br />

selected.<br />

This pro<strong>to</strong>type can also be used as a basis <str<strong>on</strong>g>for</str<strong>on</strong>g> a proof of c<strong>on</strong>cept, and ultimately the<br />

development of the soluti<strong>on</strong> itself. This initial proof-of-c<strong>on</strong>cept model often produces both<br />

answers and additi<strong>on</strong>al questi<strong>on</strong>s <str<strong>on</strong>g>for</str<strong>on</strong>g> the team. This in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> helps in the risk<br />

management process and identifies changes needed <strong>to</strong> the overall design that must be<br />

incorporated in<strong>to</strong> the specificati<strong>on</strong>s.<br />

Here are some candidates <str<strong>on</strong>g>for</str<strong>on</strong>g> the proof of c<strong>on</strong>cept that are typically part of this type of<br />

migrati<strong>on</strong>:<br />

● Per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance of binary large objects (BLOB) in s<strong>to</strong>ring, accessing, and updating<br />

based <strong>on</strong> differences in their s<strong>to</strong>rage architecture between <strong>SQL</strong> <strong>Server</strong> and <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>.<br />

● Migrati<strong>on</strong> of sequences. Sequences are not supported by <strong>SQL</strong> <strong>Server</strong>, but the<br />

functi<strong>on</strong>ality can be duplicated.<br />

● Replacing reverse key indexes in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> with regular indexes in <strong>SQL</strong> <strong>Server</strong>.<br />

● C<strong>on</strong>verting <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> packages <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> s<strong>to</strong>red procedures.<br />

● Recreating <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>'s profiles (resource and password) functi<strong>on</strong>ality using Windows<br />

security.<br />

● Developing Windows auditing functi<strong>on</strong>s <strong>to</strong> replace specific <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> functi<strong>on</strong>ality<br />

(sessi<strong>on</strong>, privilege, and object auditing).


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 53<br />

Develop the Project Plans<br />

The soluti<strong>on</strong> design that was created in the Envisi<strong>on</strong>ing Phase is used as the baseline<br />

while creating the project plan. The project plan also needs <strong>to</strong> c<strong>on</strong>sider the key success<br />

criteria identified in Chapter 2, "Envisi<strong>on</strong>ing Phase." The project plans include:<br />

● Development plan<br />

● Stabilizati<strong>on</strong> plan (includes test plan and pilot plan)<br />

● Deployment plan<br />

● Operati<strong>on</strong>s plan<br />

● Budget plan<br />

● Training plan<br />

In additi<strong>on</strong> <strong>to</strong> the above plans, a training checklist needs <strong>to</strong> be created that will identify<br />

the existing and required skills. This will help you <strong>to</strong> plan the training that needs <strong>to</strong> be<br />

provided when you do the work described in Chapter 20, "Operati<strong>on</strong>s."<br />

The development plan, test plan, and deployment plan are covered in detail under the<br />

following headings.<br />

Development Plan<br />

The development plan describes different aspects of the development endeavor, such as<br />

<strong>to</strong>ols required, methodologies and practices <strong>to</strong> be followed, schedule of events, and<br />

resources. The primary tasks of the development plan include:<br />

● Defining team roles<br />

● Identifying team, hardware, and software resources<br />

● Providing training <strong>to</strong> the team members<br />

Refer <strong>to</strong> the development plan template provided with this soluti<strong>on</strong> <strong>to</strong> assist in creating<br />

your development plan.<br />

In general, it is recommended that the elements described in the following secti<strong>on</strong>s be<br />

included in a development plan.<br />

Development Objectives<br />

These define the primary drivers that were used <strong>to</strong> create the development approach and<br />

the key objectives of that approach. The development objectives <str<strong>on</strong>g>for</str<strong>on</strong>g> a migrati<strong>on</strong> project<br />

differ from that of a new development. Most comm<strong>on</strong>ly, the key objectives are <strong>to</strong>:<br />

● Migrate the applicati<strong>on</strong> with the least amount of change.<br />

● Create a <strong>SQL</strong> <strong>Server</strong> database which is almost identical in design and<br />

implementati<strong>on</strong> <strong>to</strong> the source <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> database.<br />

● Migrate the entire soluti<strong>on</strong> <strong>to</strong> a Windows and <strong>SQL</strong> <strong>Server</strong> envir<strong>on</strong>ment with the<br />

least amount of change.<br />

Migrati<strong>on</strong> List<br />

This provides a detailed listing of the applicati<strong>on</strong>s and databases that need <strong>to</strong> be<br />

migrated as part of the current project.


54<br />

Planning Phase<br />

Overall Delivery Strategy<br />

This describes the overall approach <strong>to</strong> delivering the soluti<strong>on</strong>. Examples of delivery<br />

strategy include staged delivery, depth-first, breadth-first, and features-then-per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance.<br />

In migrati<strong>on</strong>s, the soluti<strong>on</strong> already exists and the delivery strategy c<strong>on</strong>sists of deploying<br />

the replacement soluti<strong>on</strong>.<br />

Tradeoff Approach<br />

This defines the approach <str<strong>on</strong>g>for</str<strong>on</strong>g> making design and implementati<strong>on</strong> tradeoff decisi<strong>on</strong>s. For<br />

example, you might agree <strong>to</strong> trade features <str<strong>on</strong>g>for</str<strong>on</strong>g> schedule improvements, or <strong>to</strong> trade<br />

features <str<strong>on</strong>g>for</str<strong>on</strong>g> per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance.<br />

Key Design Goals<br />

These identify the key design goals and the priority of each goal. Examples of design<br />

goals in a migrati<strong>on</strong> include interoperability between a <strong>UNIX</strong> applicati<strong>on</strong> and the<br />

<strong>SQL</strong> <strong>Server</strong> database or rewriting the applicati<strong>on</strong> using the .NET framework.<br />

Development and Build Envir<strong>on</strong>ment<br />

This describes the development and build envir<strong>on</strong>ment and how it will be managed.<br />

Include in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <strong>on</strong> items such as source code c<strong>on</strong>trol <strong>to</strong>ols, design <strong>to</strong>ol requirements,<br />

operating systems, or other software installed. If a development envir<strong>on</strong>ment <str<strong>on</strong>g>for</str<strong>on</strong>g> the<br />

existing applicati<strong>on</strong> does not exist, it will need <strong>to</strong> be created. This situati<strong>on</strong> is comm<strong>on</strong><br />

when the development of the applicati<strong>on</strong>s <strong>to</strong> be migrated was originally outsourced.<br />

Development Tools<br />

These <strong>to</strong>ols are used <strong>to</strong> assist in the development and test envir<strong>on</strong>ments. For a detailed<br />

discussi<strong>on</strong> of <strong>to</strong>ols, see the "Set Up the Development and Test Envir<strong>on</strong>ment" secti<strong>on</strong><br />

later in this chapter.<br />

<str<strong>on</strong>g>Guide</str<strong>on</strong>g>lines and Standards<br />

These list and provide references <strong>to</strong> all standards and guidelines <strong>to</strong> be used <str<strong>on</strong>g>for</str<strong>on</strong>g> the<br />

project. Standards and best practices could differ substantially from the current<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g>/<strong>UNIX</strong> envir<strong>on</strong>ment. However, applying new standards will require a tremendous<br />

rewrite, which could greatly affect the migrati<strong>on</strong> timeline. It is recommended that such<br />

standards be applied <strong>on</strong>ly <strong>to</strong> the comp<strong>on</strong>ents that are being rewritten or modified.<br />

Versi<strong>on</strong>ing and Source C<strong>on</strong>trol<br />

This describes how versi<strong>on</strong>ing and source c<strong>on</strong>trol will be managed. This secti<strong>on</strong> includes<br />

identificati<strong>on</strong> of the specific <strong>to</strong>ols that will be used and how developers are expected <strong>to</strong><br />

use them. Most source c<strong>on</strong>trol <strong>to</strong>ols work with code irrespective of plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m. Due <strong>to</strong> the<br />

change in operating systems, new software may need <strong>to</strong> be acquired. For instance, if<br />

CVS or any other source c<strong>on</strong>trol software is currently used in the <strong>UNIX</strong> envir<strong>on</strong>ment,<br />

c<strong>on</strong>siderati<strong>on</strong> should be given <strong>to</strong> migrating these functi<strong>on</strong>s <strong>to</strong> a Windows-based<br />

alternative, such as Visual Source Safe.<br />

Build Process<br />

This describes the incremental and iterative approach <str<strong>on</strong>g>for</str<strong>on</strong>g> developing code and <str<strong>on</strong>g>for</str<strong>on</strong>g> builds<br />

of hardware and software comp<strong>on</strong>ents. It also describes how the build process will be<br />

implemented and how often it will be implemented.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 55<br />

Comp<strong>on</strong>ents<br />

This provides a high-level descripti<strong>on</strong> of the set of soluti<strong>on</strong> comp<strong>on</strong>ents and how they will<br />

be migrated. In a migrati<strong>on</strong> project, most of the soluti<strong>on</strong> comp<strong>on</strong>ents should already exist.<br />

C<strong>on</strong>figurati<strong>on</strong> and Development Management Tools<br />

This identifies all the development <strong>to</strong>ols the team will use during the project. This includes<br />

<strong>to</strong>ols <str<strong>on</strong>g>for</str<strong>on</strong>g> all steps in the project: development, testing, documentati<strong>on</strong>, support,<br />

operati<strong>on</strong>s, and deployment.<br />

Design Patterns<br />

This identifies the design patterns or templates that the team will use <str<strong>on</strong>g>for</str<strong>on</strong>g> this project and<br />

their sources. The team can acquire design patterns from both external and internal<br />

sources or create new design patterns. This in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> will <strong>on</strong>ly be necessary in<br />

development plans that involve rewriting the applicati<strong>on</strong>.<br />

Development Team Training<br />

This identifies the training necessary <strong>to</strong> ensure that the development team will<br />

successfully develop the soluti<strong>on</strong>. This is a critical necessity in migrati<strong>on</strong>s because it is<br />

not comm<strong>on</strong> <strong>to</strong> already have pers<strong>on</strong>nel in place that can adequately support both <str<strong>on</strong>g>Oracle</str<strong>on</strong>g><br />

and <strong>SQL</strong> <strong>Server</strong> envir<strong>on</strong>ments.<br />

Development Team Support<br />

This identifies the various types of support the development team will require, the<br />

sources of that support, the amount of support of each type that the team will require, and<br />

the estimated schedule <str<strong>on</strong>g>for</str<strong>on</strong>g> support. Support may not exist <str<strong>on</strong>g>for</str<strong>on</strong>g> the target Windows<br />

envir<strong>on</strong>ment, and may need <strong>to</strong> be developed.<br />

Stabilizing Phase Plans<br />

During the Stabilizing Phase, the testing team c<strong>on</strong>ducts tests <strong>on</strong> a soluti<strong>on</strong> whose<br />

features are complete. Testing during this phase emphasizes usage and operati<strong>on</strong> under<br />

realistic envir<strong>on</strong>mental c<strong>on</strong>diti<strong>on</strong>s. The team focuses <strong>on</strong> resolving and prioritizing bugs<br />

and preparing the soluti<strong>on</strong> <str<strong>on</strong>g>for</str<strong>on</strong>g> release.<br />

During the Planning Phase, the team typically creates the following plans that will be<br />

used during the Stabilizing Phase:<br />

● The test plan<br />

● The pilot plan<br />

Test Plan<br />

The test plan describes the strategy and approach used <strong>to</strong> plan, organize, and manage<br />

the project’s testing activities. It identifies testing objectives, methodologies and <strong>to</strong>ols,<br />

expected results, resp<strong>on</strong>sibilities, and resource requirements. This document is the<br />

primary plan <str<strong>on</strong>g>for</str<strong>on</strong>g> the testing team. A test plan ensures that the testing process will be<br />

c<strong>on</strong>ducted in a thorough and organized manner and will enable the team <strong>to</strong> determine the<br />

stability of the soluti<strong>on</strong>. A c<strong>on</strong>tinuous understanding of the soluti<strong>on</strong>’s status builds<br />

c<strong>on</strong>fidence in team members and stakeholders as the soluti<strong>on</strong> is developed and<br />

stabilized.<br />

The Test Role in the MSF Team Model is resp<strong>on</strong>sible <str<strong>on</strong>g>for</str<strong>on</strong>g> creating the test plan. This team<br />

is also resp<strong>on</strong>sible <str<strong>on</strong>g>for</str<strong>on</strong>g> setting the quality expectati<strong>on</strong>s and incorporating them in<strong>to</strong> the


56<br />

Planning Phase<br />

testing plan. This template is available in the Tools and Templates folder in the zip file<br />

download of this guidance at http://go.microsoft.com/fwlink/?LinkId=45289.<br />

The key secti<strong>on</strong>s of a test plan include:<br />

Forms of Testing <strong>to</strong> Be Per<str<strong>on</strong>g>for</str<strong>on</strong>g>med<br />

These include:<br />

● Code comp<strong>on</strong>ent testing<br />

In a migrati<strong>on</strong>, the scope of changes made <strong>to</strong> the existing applicati<strong>on</strong> varies from<br />

minor c<strong>on</strong>necti<strong>on</strong> string changes <strong>to</strong> a complete applicati<strong>on</strong> rewrite. The goal of<br />

testing is <strong>to</strong> ensure that any comp<strong>on</strong>ent modified matches the original features and<br />

functi<strong>on</strong>ality. Instead of basing the test results <strong>on</strong> a series of requirements, the<br />

existing applicati<strong>on</strong> can be used as a basis <str<strong>on</strong>g>for</str<strong>on</strong>g> comparis<strong>on</strong>.<br />

● Database testing<br />

This includes:<br />

● Physical architecture of database. Have the data files, transacti<strong>on</strong> logs, and<br />

other comp<strong>on</strong>ents that comprise the database been created correctly?<br />

● Logical architecture of the database. Have the tables, views, s<strong>to</strong>red<br />

procedures, triggers, and other database objects been created successfully?<br />

● Data. Have the c<strong>on</strong>tents of the tables been transferred correctly? Do tables<br />

c<strong>on</strong>tain the correct number of rows? Is the data valid?<br />

● Functi<strong>on</strong>ality. Do the s<strong>to</strong>red procedures, triggers, views, and other items<br />

comprising T-<strong>SQL</strong> code operate in the same manner as the original <str<strong>on</strong>g>Oracle</str<strong>on</strong>g><br />

objects?<br />

● Per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance. Do the resp<strong>on</strong>se times and throughput meet requirements and<br />

match user expectati<strong>on</strong>s?<br />

●<br />

●<br />

●<br />

●<br />

●<br />

Infrastructure testing<br />

Infrastructure testing ncludes the development and producti<strong>on</strong> envir<strong>on</strong>ments, as<br />

well as hardware, software, m<strong>on</strong>i<strong>to</strong>ring software, network, backup strategies, and<br />

disaster recovery plans.<br />

Security testing<br />

There are two levels of security testing, network level and applicati<strong>on</strong> level, that<br />

should be tested:<br />

● <strong>Net</strong>work level. Test access and privileges<br />

● Applicati<strong>on</strong> level. Ensure that the correct users and permissi<strong>on</strong> levels exist in<br />

the applicati<strong>on</strong> and database.<br />

Integrati<strong>on</strong> testing<br />

If the soluti<strong>on</strong> is deployed in phases, then test the integrati<strong>on</strong> of each phase. Each<br />

incarnati<strong>on</strong> needs <strong>to</strong> be tested <str<strong>on</strong>g>for</str<strong>on</strong>g> acceptable integrati<strong>on</strong> with other comp<strong>on</strong>ents.<br />

User acceptance and usability testing<br />

These tests can often be recreated from the original design soluti<strong>on</strong>. The migrati<strong>on</strong><br />

should meet the same goals as the existing soluti<strong>on</strong>. Any new or modified<br />

functi<strong>on</strong>ality should also be tested.<br />

Stress, capacity, and per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance testing<br />

These tests are important because the migrated soluti<strong>on</strong> will reside in a new<br />

envir<strong>on</strong>ment. The hardware, operating systems, and software will be very different<br />

than the existing soluti<strong>on</strong>. Complete testing should be per<str<strong>on</strong>g>for</str<strong>on</strong>g>med <strong>on</strong> the soluti<strong>on</strong>.<br />

Stress testing can also be used <strong>to</strong> check database coexistence issues that may<br />

occur when there is a heavy load <strong>on</strong> the system.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 57<br />

●<br />

Regressi<strong>on</strong> testing<br />

To ensure that the soluti<strong>on</strong> functi<strong>on</strong>s correctly while bugs are being corrected, a<br />

set of test cases should be available that can be executed as a regressi<strong>on</strong> test.<br />

Each time the test is run, the results should be logged and compared with the<br />

expected results. Testing per<str<strong>on</strong>g>for</str<strong>on</strong>g>med <strong>on</strong> the original soluti<strong>on</strong> can be reused in most<br />

scenarios. Using the same data, test cases should per<str<strong>on</strong>g>for</str<strong>on</strong>g>m identically between the<br />

existing soluti<strong>on</strong> and the new soluti<strong>on</strong> being tested.<br />

Test Approach and Assumpti<strong>on</strong>s<br />

Describe at a high level the approach, activities, and techniques <strong>to</strong> be followed in testing<br />

the soluti<strong>on</strong>. If different approaches are required <str<strong>on</strong>g>for</str<strong>on</strong>g> the soluti<strong>on</strong>’s various comp<strong>on</strong>ents,<br />

you need <strong>to</strong> specify which comp<strong>on</strong>ents will be tested by which approach. This approach<br />

is relevant <strong>to</strong> migrati<strong>on</strong>s, as not all comp<strong>on</strong>ents will have the same amount of change or<br />

trans<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong>. The test approach should be tempered based <strong>on</strong> the amount of change.<br />

Major Test Resp<strong>on</strong>sibilities<br />

Identify the teams and individuals who will manage and implement the testing process.<br />

Features and Functi<strong>on</strong>ality <strong>to</strong> Test<br />

Identify at a high level all features and functi<strong>on</strong>ality that will be tested. Per<str<strong>on</strong>g>for</str<strong>on</strong>g>m the<br />

following tasks <strong>on</strong> the most comm<strong>on</strong> problem areas in an <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>to</strong> <strong>SQL</strong> migrati<strong>on</strong><br />

project:<br />

● Ensure that the <strong>SQL</strong> <strong>Server</strong> editi<strong>on</strong> acquired meets applicati<strong>on</strong> requirements. For<br />

more in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong>, see the "Validate the Technology" secti<strong>on</strong> in this chapter.<br />

● Verify that the database architecture follows best practices and will meet<br />

per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance goals.<br />

● Ensure functi<strong>on</strong>s that have moved from the database in<strong>to</strong> the applicati<strong>on</strong> (and vice<br />

versa) during the migrati<strong>on</strong> are properly documented and tested.<br />

● Check any table design changes due <strong>to</strong> restricti<strong>on</strong>s <strong>on</strong> <strong>SQL</strong> <strong>Server</strong> row size.<br />

● Test triggers that have been c<strong>on</strong>verted from <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong>.<br />

Items <strong>to</strong> include when testing applicati<strong>on</strong> migrati<strong>on</strong> include:<br />

● Code changes<br />

● Security requirements<br />

● User c<strong>on</strong>nectivity and remote access<br />

● C<strong>on</strong>necti<strong>on</strong> string changes<br />

● Functi<strong>on</strong>ality changes. C<strong>on</strong>sider both applicati<strong>on</strong> and database <str<strong>on</strong>g>for</str<strong>on</strong>g> specific items.<br />

Some database items will affect the applicati<strong>on</strong>.<br />

Type of Required Hardware<br />

The type of hardware <str<strong>on</strong>g>for</str<strong>on</strong>g> the test setup should closely resemble the architecture that is<br />

proposed <str<strong>on</strong>g>for</str<strong>on</strong>g> the producti<strong>on</strong> envir<strong>on</strong>ment. The availability of hardware may depend <strong>on</strong> its<br />

type, its cost, and any other envir<strong>on</strong>mental fac<strong>to</strong>rs that need <strong>to</strong> be c<strong>on</strong>sidered at the<br />

locati<strong>on</strong> of the test setup. In situati<strong>on</strong>s where data does not exist <strong>to</strong> make a decisi<strong>on</strong> <strong>on</strong><br />

the producti<strong>on</strong> data, the test envir<strong>on</strong>ment has <strong>to</strong> be planned <strong>to</strong> capture such in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong>.<br />

In some situati<strong>on</strong>s, using virtual machine software (such as Microsoft Virtual <strong>Server</strong><br />

2003) <strong>to</strong> recreate test envir<strong>on</strong>ments and per<str<strong>on</strong>g>for</str<strong>on</strong>g>m software testing is cost-effective.


58<br />

Planning Phase<br />

Locati<strong>on</strong> of Test Setup<br />

Decide <strong>on</strong> the locati<strong>on</strong> of the test setup. If development, testing, and producti<strong>on</strong> are in<br />

physically distant (possibly offshore) locati<strong>on</strong>s, then decisi<strong>on</strong>s have <strong>to</strong> be made <strong>on</strong> how <strong>to</strong><br />

set up the envir<strong>on</strong>ments <str<strong>on</strong>g>for</str<strong>on</strong>g> optimal per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance <str<strong>on</strong>g>for</str<strong>on</strong>g> each group. For example, if the test<br />

and producti<strong>on</strong> locati<strong>on</strong>s are far apart, creating copies of a large producti<strong>on</strong> database<br />

across a WAN can be an issue. Also, the test envir<strong>on</strong>ment should be isolated and should<br />

not interfere with any producti<strong>on</strong> activity.<br />

Resources Required<br />

Provide <str<strong>on</strong>g>for</str<strong>on</strong>g> the different equipment required <str<strong>on</strong>g>for</str<strong>on</strong>g> the setup, such as power points; racks or<br />

stands; s<strong>to</strong>rage media, such as disks; and a backup system. Software, services, and<br />

<strong>to</strong>ols <str<strong>on</strong>g>for</str<strong>on</strong>g> the test envir<strong>on</strong>ment have <strong>to</strong> be procured and set up as per the instructi<strong>on</strong>s<br />

provided by the test team.<br />

Expected Results of Tests<br />

Describe the results that should be dem<strong>on</strong>strated by the tests. This in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> includes<br />

expectati<strong>on</strong>s of both the soluti<strong>on</strong> team and the testers. This secti<strong>on</strong> also defines whether<br />

the results must be exactly as anticipated or whether a range of results is acceptable.<br />

The expected results originate from the existing soluti<strong>on</strong>. The migrated soluti<strong>on</strong> should<br />

per<str<strong>on</strong>g>for</str<strong>on</strong>g>m the same or better than the original system.<br />

Deliverables<br />

Describe the materials that must be made available or created <strong>to</strong> aid in c<strong>on</strong>ducting the<br />

tests and <str<strong>on</strong>g>for</str<strong>on</strong>g> presenting test results. In many migrati<strong>on</strong> situati<strong>on</strong>s, existing test scripts can<br />

be reused.<br />

Testing procedures and walk-through<br />

Describe the steps the testing team will per<str<strong>on</strong>g>for</str<strong>on</strong>g>m <strong>to</strong> ensure quality tests.<br />

Tracking and Reporting Status<br />

Define the in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> that test team members will communicate during the testing<br />

process. This secti<strong>on</strong> defines the specific test status in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> that will be created and<br />

distributed. This in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> normally includes status in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <str<strong>on</strong>g>for</str<strong>on</strong>g> each test case and<br />

the probability of completing the test cycle <strong>on</strong> schedule.<br />

Bug Reporting Tools and Methods<br />

Describe the overall bug reporting strategy and methodology. This secti<strong>on</strong> also defines<br />

what will qualify as a bug in the code, product features, and documentati<strong>on</strong>.<br />

Schedules<br />

Identify the major test cycles, tasks, milest<strong>on</strong>es, and deliverables. This secti<strong>on</strong> also<br />

describes who is resp<strong>on</strong>sible <str<strong>on</strong>g>for</str<strong>on</strong>g> each test cycle and its tasks. In additi<strong>on</strong>, it identifies the<br />

expected start and completi<strong>on</strong> date <str<strong>on</strong>g>for</str<strong>on</strong>g> each test cycle and the tasks within that cycle.<br />

When planning <str<strong>on</strong>g>for</str<strong>on</strong>g> test cases, identify the secti<strong>on</strong>s of code that have changed during<br />

migrati<strong>on</strong> and identify the functi<strong>on</strong>ality provided.<br />

Create test cases based <strong>on</strong> these functi<strong>on</strong>ality changes. When changes are minimal,<br />

such as a Java applicati<strong>on</strong> that <strong>on</strong>ly requires the database c<strong>on</strong>necti<strong>on</strong> string <strong>to</strong> be<br />

modified, the test case should ensure that the applicati<strong>on</strong> is c<strong>on</strong>necting properly <strong>to</strong> the


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 59<br />

<strong>SQL</strong> <strong>Server</strong> database. In most migrati<strong>on</strong>s, updates <strong>to</strong> c<strong>on</strong>nectivity and APIs represent a<br />

majority of the changes.<br />

In situati<strong>on</strong>s where the APIs have been changed, test cases should be created <strong>to</strong> test this<br />

comp<strong>on</strong>ent change. These cases should test database queries and updates per<str<strong>on</strong>g>for</str<strong>on</strong>g>med<br />

by the applicati<strong>on</strong> <strong>to</strong> ensure that results are as expected. Gather various scenarios of<br />

usability and user interacti<strong>on</strong> and repeat <str<strong>on</strong>g>for</str<strong>on</strong>g> each comp<strong>on</strong>ent. Query results and<br />

database updates can be checked against the same functi<strong>on</strong>ality in the existing soluti<strong>on</strong>.<br />

Refer <strong>to</strong> the test plan template <strong>to</strong> assist in creating your test plan. This template is<br />

available in the Tools and Templates folder in the zip file download of this guidance at<br />

http://go.microsoft.com/fwlink/?LinkId=45289.<br />

Pilot Plan<br />

The pilot plan describes how the team will move the candidate release versi<strong>on</strong> of the<br />

soluti<strong>on</strong> <strong>to</strong> a staging area and test it. The goal of the pilot is <strong>to</strong> simulate the equipment,<br />

software, and comp<strong>on</strong>ents that the soluti<strong>on</strong> will use when it is active. This plan also<br />

identifies how issues discovered during the pilot will be solved. The pilot plan includes<br />

details about how <strong>to</strong> evaluate the pilot; the results of the evaluati<strong>on</strong> will facilitate a<br />

decisi<strong>on</strong> whether <strong>to</strong> move the soluti<strong>on</strong> <strong>to</strong> producti<strong>on</strong>.<br />

Project teams often c<strong>on</strong>duct <strong>on</strong>e or more pilots <strong>to</strong> prove the feasibility of soluti<strong>on</strong><br />

approaches, <strong>to</strong> experiment with different soluti<strong>on</strong>s, and <strong>to</strong> obtain user feedback and<br />

acceptance of proposed soluti<strong>on</strong>s. Pilot soluti<strong>on</strong>s implement <strong>on</strong>ly those subsets or<br />

segments of requirements of the functi<strong>on</strong>al specificati<strong>on</strong> that are necessary <strong>to</strong> validate<br />

the soluti<strong>on</strong>.<br />

Note Some projects may not require c<strong>on</strong>ducting a pilot. For example, if there are few<br />

changes <strong>to</strong> an applicati<strong>on</strong>, the c<strong>on</strong>sensus may be not <strong>to</strong> per<str<strong>on</strong>g>for</str<strong>on</strong>g>m a pilot program.<br />

However, even in situati<strong>on</strong>s where an applicati<strong>on</strong> is ported, it is important <strong>to</strong> remember<br />

that the soluti<strong>on</strong> include the applicati<strong>on</strong> and the new <strong>SQL</strong> <strong>Server</strong> database back end.<br />

Because the back end database, envir<strong>on</strong>ment, and plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m will change in the new<br />

soluti<strong>on</strong>, a pilot is recommended <str<strong>on</strong>g>for</str<strong>on</strong>g> highly critical applicati<strong>on</strong>s. Pilots are also<br />

recommended <str<strong>on</strong>g>for</str<strong>on</strong>g> applicati<strong>on</strong>s where specific per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance criteria, such as resp<strong>on</strong>se<br />

times or throughput, must be met. Pilot programs can also be useful in situati<strong>on</strong>s where<br />

there is a redesign in the migrati<strong>on</strong> and the comp<strong>on</strong>ents work differently <strong>on</strong> the new<br />

plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m.<br />

In additi<strong>on</strong>, piloting can provide operati<strong>on</strong>al and deployment pers<strong>on</strong>nel practical<br />

experience with new technologies and can benefit the actual deployment schedule and<br />

operati<strong>on</strong>al transiti<strong>on</strong> schedules.<br />

The pilot plan provides the means <strong>to</strong> validate the business requirements and the<br />

technical specificati<strong>on</strong> prior <strong>to</strong> deploying the soluti<strong>on</strong> in<strong>to</strong> producti<strong>on</strong>. Planning the details<br />

of the pilot ensures that the participating project teams identify their roles, resp<strong>on</strong>sibilities,<br />

and resource requirements specific <strong>to</strong> pilot development, testing, and deployment<br />

activities.<br />

Refer <strong>to</strong> the pilot plan template <str<strong>on</strong>g>for</str<strong>on</strong>g> assistance in creating your pilot plan. This template is<br />

available in the Tools and Templates folder in the zip file download of this guidance at<br />

http://go.microsoft.com/fwlink/?LinkId=45289.


60<br />

Planning Phase<br />

Deployment Plan<br />

During the Deploying Phase, the team deploys the soluti<strong>on</strong> technology and comp<strong>on</strong>ents,<br />

stabilizes the deployment, transiti<strong>on</strong>s the project <strong>to</strong> operati<strong>on</strong>s and support, and obtains<br />

final cus<strong>to</strong>mer approval of the project. Planning <str<strong>on</strong>g>for</str<strong>on</strong>g> deployment starts in the Planning<br />

Phase by developing a detailed deployment plan. This plan should be developed by the<br />

Release Management Role with assistance from the rest of the team. See the<br />

deployment plan template in the Tools and Templates folder in the zip file download of<br />

this guidance at http://go.microsoft.com/fwlink/?LinkId=45289.<br />

Key elements of the deployment plan are described in the following secti<strong>on</strong>s.<br />

Deployment Scope<br />

This secti<strong>on</strong> describes the soluti<strong>on</strong> architecture and scale of deployment. The<br />

deployment team needs <strong>to</strong> c<strong>on</strong>sider deployment of the database, server, and the client<br />

applicati<strong>on</strong>s. Each has its own challenges that require a different process and set of<br />

<strong>to</strong>ols.<br />

● Seats. This describes the magnitude of the deployment in terms of sites, number<br />

of workstati<strong>on</strong>s, countries and regi<strong>on</strong>s, and other relevant size fac<strong>to</strong>rs.<br />

● Comp<strong>on</strong>ents. This lists and describes the comp<strong>on</strong>ents <strong>to</strong> be deployed and any<br />

critical dependencies am<strong>on</strong>g them.<br />

● Architecture. This describes the soluti<strong>on</strong>’s architecture and how it might affect<br />

deployment.<br />

Deployment Tools<br />

The database and server deployment will often be <strong>on</strong> <strong>on</strong>e or a few machines. They can<br />

be deployed manually. However, the clients may have <strong>to</strong> be deployed over hundreds of<br />

computers across the corporate network. This may require the need <str<strong>on</strong>g>for</str<strong>on</strong>g> software<br />

distributi<strong>on</strong> and deployment <strong>to</strong>ols. These <strong>to</strong>ols are discussed in the "Deploying the Client<br />

Applicati<strong>on</strong>" secti<strong>on</strong> in Chapter 19, "Deploying Phase."<br />

Backups<br />

Backing up of the soluti<strong>on</strong> and the source c<strong>on</strong>trol of scripts must be carried out. The<br />

items that need <strong>to</strong> be backed up <str<strong>on</strong>g>for</str<strong>on</strong>g> which you need <strong>to</strong> plan include a snapshot of the<br />

source code of the existing soluti<strong>on</strong> and the migrated soluti<strong>on</strong>. Include the versi<strong>on</strong><br />

in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> and build in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong>.<br />

This ensures that the envir<strong>on</strong>ment can be recreated later, if required. It also aids during<br />

problems, especially when a fallback is implemented. In a phased migrati<strong>on</strong>, backups of<br />

the source should be per<str<strong>on</strong>g>for</str<strong>on</strong>g>med between phases, as well as any other critical junctures,<br />

as deemed necessary. If a partial rollback is needed, backups can save time.<br />

Deployment Schedule<br />

This identifies the critical dates and anticipated schedule <str<strong>on</strong>g>for</str<strong>on</strong>g> the Deploying Phase.<br />

Deployment Resources<br />

This identifies the work<str<strong>on</strong>g>for</str<strong>on</strong>g>ce that will be needed <strong>to</strong> complete the deployment and the<br />

sources of the pers<strong>on</strong>nel.<br />

<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> Support<br />

This describes how the users will be supported during the deployment.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 61<br />

●<br />

●<br />

●<br />

●<br />

Help desk. This describes the support provided <strong>to</strong> users and applicati<strong>on</strong>s by the<br />

help desk team, including support <str<strong>on</strong>g>for</str<strong>on</strong>g> direct user questi<strong>on</strong>s and applicati<strong>on</strong> issues,<br />

and also in-depth support <str<strong>on</strong>g>for</str<strong>on</strong>g> new or difficult issues.<br />

Desk<strong>to</strong>p. This describes any changes in current workstati<strong>on</strong> applicati<strong>on</strong> support<br />

that might be required during deployment.<br />

<strong>Server</strong>s. This describes any changes in current server support that might be<br />

required during deployment.<br />

Telecommunicati<strong>on</strong>s. This describes any changes in current telecommunicati<strong>on</strong><br />

support that might be required during deployment.<br />

Coordinati<strong>on</strong> of Training<br />

This describes how end-user and support staff training is coordinated with the<br />

deployment schedule.<br />

Communicati<strong>on</strong><br />

The necessary in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong>, such as the dates <str<strong>on</strong>g>for</str<strong>on</strong>g> deploying and completing the migrati<strong>on</strong><br />

must be communicated <strong>to</strong> the cus<strong>to</strong>mers and all those who may directly or indirectly be<br />

affected by the migrati<strong>on</strong>. The deployment plan should be made available <strong>to</strong> the entire<br />

team so that each pers<strong>on</strong> is well in<str<strong>on</strong>g>for</str<strong>on</strong>g>med of what acti<strong>on</strong>s they are resp<strong>on</strong>sible <str<strong>on</strong>g>for</str<strong>on</strong>g> and<br />

when it should occur. This is especially critical in large migrati<strong>on</strong>s that have <strong>to</strong> be<br />

undertaken over a grueling schedule, such as a weekend.<br />

Work Schedules<br />

To prevent the business operati<strong>on</strong>s from being affected by the deployment, work<br />

schedules should be set accordingly. The work schedules should c<strong>on</strong>sider training the<br />

operati<strong>on</strong>s pers<strong>on</strong>nel and end users.<br />

Resource Availability<br />

The resources in the producti<strong>on</strong> envir<strong>on</strong>ment should be prepared <str<strong>on</strong>g>for</str<strong>on</strong>g> the soluti<strong>on</strong><br />

deployment. The infrastructure, servers, and workstati<strong>on</strong>s should be prepared <str<strong>on</strong>g>for</str<strong>on</strong>g> the<br />

deployment. The necessary installati<strong>on</strong> files should be ready <strong>to</strong> c<strong>on</strong>duct a smooth and<br />

timely deployment. Spare disk drives, cables, network cards, power points, stands, and<br />

backup power supply should be made available in case of failure in hardware during the<br />

deployment. In many instances, such precauti<strong>on</strong>s are not taken until a soluti<strong>on</strong> is already<br />

deployed. Hence it is important <strong>to</strong> produce a plan <strong>to</strong> capture all these tasks.<br />

● Assembling the team. The rollout team should be assembled and the training <strong>to</strong><br />

per<str<strong>on</strong>g>for</str<strong>on</strong>g>m the deployment should be provided. The rollout team members could be<br />

from the project team, but the team should also include members from the<br />

operati<strong>on</strong>s staff because they need <strong>to</strong> develop a thorough knowledge of the<br />

functi<strong>on</strong>ing of the soluti<strong>on</strong>. Alternate team members should also be selected <strong>to</strong><br />

prepare <str<strong>on</strong>g>for</str<strong>on</strong>g> c<strong>on</strong>tingencies.<br />

● Training the team. The deployment team should be given the necessary training<br />

and privileges <strong>to</strong> overcome the difficulties that could arise during the rollout. The<br />

different installati<strong>on</strong> manuals and documentati<strong>on</strong> should be provided <strong>to</strong> the rollout<br />

team. A special help desk should be set up <str<strong>on</strong>g>for</str<strong>on</strong>g> the users and the rollout team <strong>to</strong><br />

revert <strong>to</strong> while deploying the soluti<strong>on</strong>.<br />

● Documenting unplanned procedures. During the rollout, some procedures may<br />

have been implemented which were a part of the rollout plan. The deployment<br />

team may need these procedures <strong>to</strong> stabilize the deployment or correct<br />

un<str<strong>on</strong>g>for</str<strong>on</strong>g>eseen situati<strong>on</strong>s created due <strong>to</strong> the executi<strong>on</strong> of unplanned procedures.


62<br />

Planning Phase<br />

These emergency procedures should be documented and include the cause and<br />

effect of the procedure adopted.<br />

Because there are risks involved, the risk management plan has <strong>to</strong> be reviewed<br />

and updated. The risk management template is available in the Tools and<br />

Templates folder in the zip file download of this guidance at<br />

http://go.microsoft.com/fwlink/?LinkId=45289.<br />

Deployment Strategies<br />

The main strategies that need <strong>to</strong> be c<strong>on</strong>sidered <str<strong>on</strong>g>for</str<strong>on</strong>g> deployment include:<br />

● Cu<strong>to</strong>ver strategy. The critical area in a migrati<strong>on</strong> project where the existing<br />

system is shut down and the new system is ready <strong>to</strong> be implemented in the<br />

producti<strong>on</strong> envir<strong>on</strong>ment. The cu<strong>to</strong>ver strategy focuses <strong>on</strong> the tasks, activities, and<br />

time required during the final days of the project. The cu<strong>to</strong>ver strategies available<br />

are:<br />

● Straight cu<strong>to</strong>ver. This strategy enables migrati<strong>on</strong> of the database from <strong>on</strong>e<br />

envir<strong>on</strong>ment <strong>to</strong> another without taking any intermediary steps. This opti<strong>on</strong> is<br />

used when downtime does not limit the migrati<strong>on</strong>, and the migrated database<br />

does not c<strong>on</strong>tain critical in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong>.<br />

● Parallel cu<strong>to</strong>ver. Replicati<strong>on</strong> is a strategy that is used by organizati<strong>on</strong>s that do<br />

not have the adequate downtime required <strong>to</strong> build and migrate a database. A<br />

database is created in the new envir<strong>on</strong>ment and data is migrated <strong>on</strong> a<br />

c<strong>on</strong>tinual basis. A process is put in place <strong>to</strong> replicate the current database<br />

changes in<strong>to</strong> the new database synchr<strong>on</strong>ously or asynchr<strong>on</strong>ously.<br />

● Serial cu<strong>to</strong>ver. This opti<strong>on</strong> enables the database <strong>to</strong> be migrated in phases.<br />

This approach is usually implemented when multiple databases need <strong>to</strong> be<br />

migrated or data within the database is porti<strong>on</strong>ed based <strong>on</strong> business functi<strong>on</strong>s.<br />

The serial cu<strong>to</strong>ver strategy is difficult <strong>to</strong> implement when the database is<br />

complex and interdependent with other infrastructure elements.<br />

●<br />

●<br />

Phase-out strategies. In large, complex migrati<strong>on</strong>s, the soluti<strong>on</strong> is rolled out in<br />

phases. This enables the team <strong>to</strong> assess and reduce the business risks. Phasing<br />

out enables the deployment <strong>to</strong> take place in small and manageable parts. There<br />

are two types of phase-outs:<br />

● Vertical phase-out. In vertical phase-out, modules are rolled out <strong>on</strong>e at a<br />

time. This implies that both the source soluti<strong>on</strong> and the target soluti<strong>on</strong><br />

interoperate. The advantage is that the soluti<strong>on</strong> is rolled out in manageable<br />

parts. The disadvantage is that data bridge programs between the two<br />

soluti<strong>on</strong>s have <strong>to</strong> be deployed at each phase-out.<br />

● Horiz<strong>on</strong>tal phase-out. The horiz<strong>on</strong>tal phase-out covers the rolling out of the<br />

soluti<strong>on</strong> in phases over the different geographical areas. While implementing a<br />

horiz<strong>on</strong>tal phase-out, the differences in the envir<strong>on</strong>ment c<strong>on</strong>diti<strong>on</strong>s of the<br />

business and applicati<strong>on</strong>s should be taken care of.<br />

Fallback strategies. A fallback is necessary if the migrati<strong>on</strong> encounters difficulties<br />

or delays that impacts business. This could result due <strong>to</strong> the following reas<strong>on</strong>s:<br />

● Unfeasible migrati<strong>on</strong> strategy<br />

● Undocumented requirements or procedures<br />

● Insufficient testing<br />

● Disasters<br />

● Un<str<strong>on</strong>g>for</str<strong>on</strong>g>eseen situati<strong>on</strong>s


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 63<br />

Each phase and each acti<strong>on</strong> in the rollout has <strong>to</strong> be associated with an impact <strong>to</strong><br />

determine if a fallback is required whenever that acti<strong>on</strong> cannot be successfully<br />

completed. Dependencies <str<strong>on</strong>g>for</str<strong>on</strong>g> every acti<strong>on</strong> should also be mapped <strong>to</strong> <str<strong>on</strong>g>for</str<strong>on</strong>g>esee the<br />

impact <strong>on</strong> tasks further down the chain. Every precauti<strong>on</strong> <strong>to</strong> ensure that the<br />

fallback is successfully completed has <strong>to</strong> be undertaken. For example, in case of a<br />

fallback, the licenses of the existing soluti<strong>on</strong> need <strong>to</strong> be still valid, and the<br />

encrypti<strong>on</strong> certificates need <strong>to</strong> be valid.<br />

A fallback plan should enable the soluti<strong>on</strong> <strong>to</strong> be rolled back <strong>to</strong> a c<strong>on</strong>sistent and<br />

stable state. Workaround strategies or c<strong>on</strong>tingency plans should be tried be<str<strong>on</strong>g>for</str<strong>on</strong>g>e<br />

deciding <strong>to</strong> fallback <strong>on</strong> the original database. The fallback strategies <strong>to</strong> be<br />

implemented depend <strong>on</strong> the cu<strong>to</strong>ver strategies that are selected. The fallback<br />

strategy should accommodate <str<strong>on</strong>g>for</str<strong>on</strong>g> any transacti<strong>on</strong>s that were executed since the<br />

start of deployment. To select the optimal fallback strategy, a list of the possible<br />

failures needs <strong>to</strong> be documented. The different fallback strategies available are:<br />

● Fallback after straight cu<strong>to</strong>ver. In case of a fallback in straight cu<strong>to</strong>ver, the<br />

<strong>UNIX</strong> envir<strong>on</strong>ment needs <strong>to</strong> be frozen at the time the cu<strong>to</strong>ver started. Thus, in<br />

case of a fallback, it is possible <strong>to</strong> restart the <strong>UNIX</strong> envir<strong>on</strong>ment with minimal<br />

ef<str<strong>on</strong>g>for</str<strong>on</strong>g>t. A fallback may require re-establishment of broken sessi<strong>on</strong>s between the<br />

cus<strong>to</strong>mer computers and the database. To reduce downtime and rework,<br />

during the fallback, checkpoints have <strong>to</strong> be established be<str<strong>on</strong>g>for</str<strong>on</strong>g>e clients are<br />

migrated. Also, a subset of clients should be cut over and tested be<str<strong>on</strong>g>for</str<strong>on</strong>g>e the<br />

rest of the clients. In additi<strong>on</strong>, adequate time should be provided <str<strong>on</strong>g>for</str<strong>on</strong>g> a fallback<br />

with minimal user disturbance.<br />

● Fallback after parallel cu<strong>to</strong>ver. The fallback process involves reversing the<br />

directi<strong>on</strong> of replicati<strong>on</strong> that was used in the cu<strong>to</strong>ver, that is, <strong>SQL</strong> <strong>Server</strong> <strong>to</strong><br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> database. C<strong>on</strong>sequently, the <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> database is updated <str<strong>on</strong>g>for</str<strong>on</strong>g> the period<br />

of the cu<strong>to</strong>ver. The client side is the main technical area <strong>to</strong> be addressed<br />

during the fallback. <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> the clients in smaller batches can ease the pain<br />

of reverting <strong>to</strong> the original envir<strong>on</strong>ment.<br />

● Fallback after serial cu<strong>to</strong>ver. The fallback is similar <strong>to</strong> that in a straight<br />

cu<strong>to</strong>ver, with the entire migrati<strong>on</strong> viewed as a collecti<strong>on</strong> of smaller cu<strong>to</strong>vers.<br />

The serial or phased cu<strong>to</strong>ver enables you <strong>to</strong> fallback <strong>to</strong> a previous c<strong>on</strong>sistent<br />

state without having <strong>to</strong> undo all changes. You are also able <strong>to</strong> solve problems<br />

in small increments.<br />

For more in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> and assistance in developing your deployment plan, refer <strong>to</strong> the<br />

deployment plan template.<br />

Create the Project Schedules<br />

Based <strong>on</strong> the functi<strong>on</strong>al specificati<strong>on</strong> and the project plan, the team creates a project<br />

schedule that defines the release date of the soluti<strong>on</strong>. The team may choose <strong>to</strong> divide the<br />

schedule functi<strong>on</strong>ally. For example, different sub test teams will work <strong>on</strong> testing different<br />

features of the soluti<strong>on</strong>. Each subteam will create its own schedule.<br />

A release date is decided after integrating the master project schedule with the schedules<br />

from each team lead. A release date enables the team members <strong>to</strong> prioritize functi<strong>on</strong>s,<br />

assess risk, and plan effectively.<br />

Estimating the Ef<str<strong>on</strong>g>for</str<strong>on</strong>g>t<br />

According <strong>to</strong> the various functi<strong>on</strong>al comp<strong>on</strong>ents, each task is allotted <strong>to</strong> a team that is<br />

developing the comp<strong>on</strong>ent. Each team prepares plans based <strong>on</strong> their role and


64<br />

Planning Phase<br />

deliverables. Finally, all the plans are reviewed and dependencies between the plans are<br />

outlined. These various plans are then merged in<strong>to</strong> a master project plan.<br />

Estimating the teams' ef<str<strong>on</strong>g>for</str<strong>on</strong>g>t can be accomplished as follows:<br />

● Each team leader prioritizes the functi<strong>on</strong>s, roles, and resp<strong>on</strong>sibilities <str<strong>on</strong>g>for</str<strong>on</strong>g> the entire<br />

team.<br />

● The team members are required <strong>to</strong> estimate their per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance <str<strong>on</strong>g>for</str<strong>on</strong>g> each task<br />

assigned. The time given <strong>to</strong> per<str<strong>on</strong>g>for</str<strong>on</strong>g>m an individual task should vary from <strong>on</strong>e half<br />

day <strong>to</strong> <strong>on</strong>e week. If the time durati<strong>on</strong> estimated is short, then the overhead in<br />

managing the task may be <strong>to</strong>o high. If the time estimated is <strong>to</strong>o l<strong>on</strong>g, then<br />

managing the scope of work becomes <strong>to</strong>o difficult.<br />

● Per<str<strong>on</strong>g>for</str<strong>on</strong>g>m bot<strong>to</strong>m-up estimating <strong>to</strong> create accurate schedules. This method enables<br />

the individual per<str<strong>on</strong>g>for</str<strong>on</strong>g>ming the task <strong>to</strong> estimate the time taken <strong>to</strong> complete it. The<br />

estimate is usually based <strong>on</strong> the individual's experience of per<str<strong>on</strong>g>for</str<strong>on</strong>g>ming a similar<br />

task. In additi<strong>on</strong>, individuals that estimate time plans <str<strong>on</strong>g>for</str<strong>on</strong>g> their work feel more<br />

accountable <str<strong>on</strong>g>for</str<strong>on</strong>g> their work schedules.<br />

● Implement risk-driven estimating, which enables the team members <strong>to</strong> per<str<strong>on</strong>g>for</str<strong>on</strong>g>m the<br />

difficult and highest risk tasks first. It permits individuals <strong>to</strong> minimize risk and<br />

provides excess time <strong>to</strong> mitigate risk.<br />

When scheduling a migrati<strong>on</strong>, there are many time-related elements <strong>to</strong> c<strong>on</strong>sider. For<br />

instance, the development and test envir<strong>on</strong>ment need <strong>to</strong> be set up be<str<strong>on</strong>g>for</str<strong>on</strong>g>e starting the<br />

Developing Phase <strong>to</strong> maximize team productivity, mitigate risks, and avoid delays. It is<br />

also recommended <strong>to</strong> migrate the database be<str<strong>on</strong>g>for</str<strong>on</strong>g>e migrating the applicati<strong>on</strong>. This is due<br />

<strong>to</strong> object-level differences between the <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong> databases that may need<br />

<strong>to</strong> be modified.<br />

Migrati<strong>on</strong> envir<strong>on</strong>ments also impact the schedule. For instance, projects that involve<br />

porting the applicati<strong>on</strong>, such as Java, can be accomplished relatively quickly. By c<strong>on</strong>trast,<br />

migrati<strong>on</strong> envir<strong>on</strong>ments that require rewriting the applicati<strong>on</strong>, such as <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms and<br />

Pro*C, will need a l<strong>on</strong>ger development schedule. Also, it is more challenging <strong>to</strong> migrate<br />

data in OLTP envir<strong>on</strong>ments than in batch processing envir<strong>on</strong>ments.<br />

Skills can also affect the scheduling. In an optimal migrati<strong>on</strong>, a database administra<strong>to</strong>r <strong>on</strong><br />

the team is skilled in both <strong>SQL</strong> <strong>Server</strong> and <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> envir<strong>on</strong>ments. If current database<br />

administra<strong>to</strong>rs are <strong>on</strong>ly familiar with the <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> envir<strong>on</strong>ment, extra time should be allowed<br />

<str<strong>on</strong>g>for</str<strong>on</strong>g> job training and skill acquisiti<strong>on</strong>. The same applies <strong>to</strong> applicati<strong>on</strong> developers. In<br />

additi<strong>on</strong>, pilot testing and migrating smaller applicati<strong>on</strong>s be<str<strong>on</strong>g>for</str<strong>on</strong>g>e the main applicati<strong>on</strong> may<br />

be beneficial <strong>to</strong> the project by providing the entire project team with experience that may<br />

prove helpful while migrating the main applicati<strong>on</strong>.<br />

After you have defined a schedule, you can allocate resources <strong>to</strong> it. You should:<br />

● Update the project plan with detailed allocati<strong>on</strong> of resources.<br />

● Check and c<strong>on</strong>figure availability of resources, identifying any possible overuse of<br />

resources.<br />

● Establish a baseline and track progress <strong>on</strong> tasks and budget.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 65<br />

Set Up the Development and Test Envir<strong>on</strong>ments<br />

The final tasks <str<strong>on</strong>g>for</str<strong>on</strong>g> the Planning Phase are setting up the development and test<br />

envir<strong>on</strong>ments. Completing these tasks allow <str<strong>on</strong>g>for</str<strong>on</strong>g> a smooth transiti<strong>on</strong> in<strong>to</strong> the Development<br />

Phase.<br />

In many ways, the development and test envir<strong>on</strong>ments are similar. Both are modeled <strong>on</strong><br />

the soluti<strong>on</strong> envir<strong>on</strong>ment, and both are used <strong>to</strong> refine the soluti<strong>on</strong>. There are also<br />

differences between the functi<strong>on</strong>s of these two envir<strong>on</strong>ments.<br />

The development envir<strong>on</strong>ment is used <strong>to</strong> develop the migrati<strong>on</strong> soluti<strong>on</strong> <str<strong>on</strong>g>for</str<strong>on</strong>g> the database,<br />

client applicati<strong>on</strong>, and server applicati<strong>on</strong>s. In additi<strong>on</strong>, the envir<strong>on</strong>ment may go through<br />

changes as the soluti<strong>on</strong> is developed.<br />

By c<strong>on</strong>trast, the test envir<strong>on</strong>ment is more strictly c<strong>on</strong>trolled <strong>to</strong> ensure that it emulates the<br />

producti<strong>on</strong> envir<strong>on</strong>ment. The test envir<strong>on</strong>ment is used <strong>to</strong> complete all necessary testing<br />

<str<strong>on</strong>g>for</str<strong>on</strong>g> the database and applicati<strong>on</strong>. The test envir<strong>on</strong>ment must be as similar as possible <strong>to</strong><br />

the producti<strong>on</strong> envir<strong>on</strong>ment so that stress and scalability tests will have a measure of<br />

accuracy.<br />

Often in migrati<strong>on</strong> projects, the development envir<strong>on</strong>ment is used <str<strong>on</strong>g>for</str<strong>on</strong>g> testing <strong>on</strong>ce the<br />

Developing Phase has ended. In most situati<strong>on</strong>s, the test envir<strong>on</strong>ment requires a higher<br />

level of per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance than the development envir<strong>on</strong>ment, and additi<strong>on</strong>al hardware will<br />

need <strong>to</strong> be added.<br />

If you are reusing equipment, it is best <strong>to</strong> reload all operating systems, applicati<strong>on</strong>s, and<br />

data. This ensures that testing results will not be skewed by a system setting or error left<br />

from the development envir<strong>on</strong>ment.<br />

The test envir<strong>on</strong>ment also has different requirements than the development envir<strong>on</strong>ment.<br />

For instance, testing <strong>to</strong>ols should be installed <str<strong>on</strong>g>for</str<strong>on</strong>g> tasks such as recording per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance<br />

fac<strong>to</strong>rs, or <strong>to</strong> increase the load during stress testing.<br />

The <strong>to</strong>ols required <str<strong>on</strong>g>for</str<strong>on</strong>g> development and testing are:<br />

● Database modeling <strong>to</strong>ols <str<strong>on</strong>g>for</str<strong>on</strong>g> reverse engineering existing databases and<br />

generating data definiti<strong>on</strong> statements <str<strong>on</strong>g>for</str<strong>on</strong>g> the new envir<strong>on</strong>ment. The more popular<br />

modeling <strong>to</strong>ols are AllFusi<strong>on</strong> ERwin from Computer Associates and ER/Studio<br />

from Embarcadero.<br />

● Software development <strong>to</strong>ols such Visual Studio .NET or Visual Basic .NET, Perl,<br />

Pyth<strong>on</strong>, PHP, and Java<br />

● Software management <strong>to</strong>ols <str<strong>on</strong>g>for</str<strong>on</strong>g> source c<strong>on</strong>trol and bug tracking — Visual Source<br />

Safe and C<strong>on</strong>current Versi<strong>on</strong> Systems (CVS) are the popular <strong>on</strong>es <str<strong>on</strong>g>for</str<strong>on</strong>g> source<br />

c<strong>on</strong>trol. PVCS from Merant and ClearQuest from Rati<strong>on</strong>al can be used <str<strong>on</strong>g>for</str<strong>on</strong>g> bug<br />

tracking.<br />

● An applicati<strong>on</strong> debugger (if <strong>on</strong>e is not bundled with the applicati<strong>on</strong> development<br />

<strong>to</strong>ol). Most applicati<strong>on</strong>s come with their own built-in debuggers.<br />

● Software <str<strong>on</strong>g>for</str<strong>on</strong>g> administering <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong>. Both <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong><br />

offer Enterprise Manager, which c<strong>on</strong>tains a comprehensive set of <strong>to</strong>ols <str<strong>on</strong>g>for</str<strong>on</strong>g> all<br />

administrative tasks. There are several third-party <strong>to</strong>ols available, such as Toad<br />

and <strong>SQL</strong> Naviga<strong>to</strong>r from Quest, PL/<strong>SQL</strong> Developer from Allround Au<strong>to</strong>mati<strong>on</strong>s,<br />

Unicenter <strong>SQL</strong>-Stati<strong>on</strong> from Computer Associates, and Rapid <strong>SQL</strong> from<br />

Embarcedero.<br />

● Database and data migrati<strong>on</strong> <strong>to</strong>ols. Tools that are aimed specifically at <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>to</strong><br />

<strong>SQL</strong> Sever migrati<strong>on</strong> are available from Microsoft.<br />

● <strong>UNIX</strong> interoperability <strong>to</strong>ols such as SFU, FreeTDS, and so <strong>on</strong>.


66<br />

Planning Phase<br />

●<br />

●<br />

●<br />

Scripting <strong>to</strong>ols <str<strong>on</strong>g>for</str<strong>on</strong>g> writing scripts <str<strong>on</strong>g>for</str<strong>on</strong>g> testing. Perl is a popular scripting language<br />

that is portable across <strong>UNIX</strong> and Windows. Windows Script is available from<br />

Microsoft.<br />

Per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance m<strong>on</strong>i<strong>to</strong>ring and analysis <strong>to</strong>ols <str<strong>on</strong>g>for</str<strong>on</strong>g> the various comp<strong>on</strong>ents of the<br />

soluti<strong>on</strong>. Perfm<strong>on</strong> is a versatile <strong>to</strong>ol <str<strong>on</strong>g>for</str<strong>on</strong>g> m<strong>on</strong>i<strong>to</strong>ring the Windows system and it can<br />

capture statistics <str<strong>on</strong>g>for</str<strong>on</strong>g> any applicati<strong>on</strong> that runs <strong>on</strong> a Windows computer. Filem<strong>on</strong><br />

and <strong>Net</strong>m<strong>on</strong> can be used specifically <str<strong>on</strong>g>for</str<strong>on</strong>g> the file system and internet traffic.<br />

Scheduling <strong>to</strong>ol <str<strong>on</strong>g>for</str<strong>on</strong>g> au<strong>to</strong>mating tests and <str<strong>on</strong>g>for</str<strong>on</strong>g> capturing statistics. Windows<br />

scheduler can be used <str<strong>on</strong>g>for</str<strong>on</strong>g> this purpose. Au<strong>to</strong>sys from Computer Associates and<br />

C<strong>on</strong>trol-M from BMC are also popular.<br />

For additi<strong>on</strong>al in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <strong>on</strong> testing, refer <strong>to</strong> Chapter 18, "Stabilizing Phase."


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 67<br />

4<br />

Developing: Databases —<br />

Introducti<strong>on</strong><br />

Introducti<strong>on</strong> and Goals<br />

For a migrati<strong>on</strong> project, the Developing Phase is the time when the team builds the<br />

soluti<strong>on</strong> comp<strong>on</strong>ents — code and infrastructure as well as documentati<strong>on</strong>. Typically, this<br />

work c<strong>on</strong>sists of modifying existing code in a way that enables it <strong>to</strong> work within the new<br />

envir<strong>on</strong>ment. When new code is written, some aspect of the original comp<strong>on</strong>ent usually<br />

remains unchanged — <str<strong>on</strong>g>for</str<strong>on</strong>g> example, exposed APIs, or specific comp<strong>on</strong>ent behaviors.<br />

Both the modificati<strong>on</strong> of existing code and development of new code in this c<strong>on</strong>text are<br />

c<strong>on</strong>sidered <strong>to</strong> be migrating activities.<br />

Although the development and migrati<strong>on</strong> work is the focus of this phase and this<br />

guidance, the entire team is active. For example, some team members are creating<br />

deliverables such as training materials, rollout and site preparati<strong>on</strong> checklists, and<br />

updated pilot and rollout plans while others are doing functi<strong>on</strong>al testing. Some<br />

development work may c<strong>on</strong>tinue in<strong>to</strong> the Stabilizing Phase in resp<strong>on</strong>se <strong>to</strong> test results.<br />

This chapter serves as an introducti<strong>on</strong> <strong>to</strong> the database development-oriented chapters.<br />

Chapters 5 through 8 describe and dem<strong>on</strong>strate how <strong>to</strong> implement a Microsoft®<br />

<strong>SQL</strong> <strong>Server</strong> database that resembles the source <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> database as closely as<br />

possible. These chapters also describe how <strong>to</strong> produce a soluti<strong>on</strong> that meets your<br />

organizati<strong>on</strong>'s requirements <str<strong>on</strong>g>for</str<strong>on</strong>g> per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance, functi<strong>on</strong>ality, availability, scalability, and<br />

recoverability. The following list provides an overview of the c<strong>on</strong>tent in each of the<br />

database development-oriented chapters:<br />

● Chapter 4: Developing: Database — Introducti<strong>on</strong>. This chapter prefaces the<br />

different tasks in migrating the <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> database <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> 2000.<br />

● Chapter 5: Developing: Database — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> the Database Architecture.<br />

This chapter describes the steps in creating an instance of <strong>SQL</strong> <strong>Server</strong> which is<br />

equivalent in architecture <strong>to</strong> the original <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> database.<br />

● Chapter 6: Developing: Database — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> Schemas. This chapter shows<br />

how <strong>to</strong> migrate a schema owner and its objects <strong>to</strong> a <strong>SQL</strong> <strong>Server</strong> database.<br />

● Chapter 7: Developing: Database — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> the Database Users. This<br />

chapter c<strong>on</strong>tains detailed steps in creating users in the <strong>SQL</strong> <strong>Server</strong> databases and<br />

granting them the same kind of privileges they had in the original <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> database.


68<br />

Developing: Databases — Introducti<strong>on</strong><br />

●<br />

●<br />

Chapter 8: Developing: Database — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> the Data. This chapter explores<br />

the different opti<strong>on</strong>s in migrating the applicati<strong>on</strong> data from <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong>. It<br />

provides details in the usage of each of the opti<strong>on</strong>s.<br />

Chapter 9: Developing: Database — Unit Testing the Migrati<strong>on</strong>. This chapter<br />

c<strong>on</strong>tains the processes <str<strong>on</strong>g>for</str<strong>on</strong>g> testing the migrated database, its objects and data.<br />

The Developing Phase <str<strong>on</strong>g>for</str<strong>on</strong>g>mally ends with the Scope Complete Milest<strong>on</strong>e. At this major<br />

milest<strong>on</strong>e, the team gains <str<strong>on</strong>g>for</str<strong>on</strong>g>mal approval from the sp<strong>on</strong>sor or key stakeholders. All<br />

soluti<strong>on</strong> elements are built and the soluti<strong>on</strong> features and functi<strong>on</strong>ality are complete<br />

according <strong>to</strong> the functi<strong>on</strong>al specificati<strong>on</strong>s agreed up<strong>on</strong> during planning. Table 4.1<br />

describes the major tasks that need <strong>to</strong> take place while migrating the database.<br />

Table 4.1: Major Tasks and Deliverables<br />

Tasks<br />

Migrate the <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> database architecture<br />

Migrate the schemas<br />

Migrate the users<br />

Migrate the data<br />

Deliverables<br />

<strong>SQL</strong> <strong>Server</strong> instance that is equivalent in<br />

structure <strong>to</strong> the source<br />

<strong>SQL</strong> <strong>Server</strong> databases housing applicati<strong>on</strong><br />

schemas<br />

<strong>SQL</strong> <strong>Server</strong> users with similar privileges as<br />

the source<br />

Complete database ready <str<strong>on</strong>g>for</str<strong>on</strong>g> use<br />

<str<strong>on</strong>g>Migrating</str<strong>on</strong>g> the Database<br />

Because they are both relati<strong>on</strong>al databases, <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong> have more<br />

similarities than differences in their features and functi<strong>on</strong>s. Both <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong><br />

provide all the core functi<strong>on</strong>ality expected of a RDBMS, including c<strong>on</strong>currency, security,<br />

backup, recovery, scalability, availability, sessi<strong>on</strong> management, transacti<strong>on</strong> management,<br />

s<strong>to</strong>rage management, resource management, and so <strong>on</strong>. Both exhibit a moderate degree<br />

of compliance <strong>to</strong> ANSI standards. Hence migrating from <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong><br />

<strong>on</strong> Windows® poses less of a challenge than would normally be expected when<br />

migrating from <strong>on</strong>e proprietary computing system <strong>to</strong> another. Because <strong>SQL</strong> <strong>Server</strong> and<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> are relati<strong>on</strong>al databases, it is not necessary <strong>to</strong> redesign the database. It is not<br />

necessary <strong>to</strong> rearchitect the applicati<strong>on</strong> <str<strong>on</strong>g>for</str<strong>on</strong>g> per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance or security because the two<br />

DBMSs are very similar in their architecture. The majority of the work involved is in<br />

accommodating the differences in the implementati<strong>on</strong> of items such as indexes, data<br />

types, and <strong>SQL</strong> and DBMS features, such as partiti<strong>on</strong>ing.<br />

To simplify the migrati<strong>on</strong> of the database, the entire process can be organized in<strong>to</strong> four<br />

major tasks:


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 69<br />

Figure 4.1<br />

Tasks in the migrati<strong>on</strong> of a database<br />

Each of the four major tasks includes a set of subtasks as follows:<br />

1. Migrate the database architecture<br />

a. Build the <strong>SQL</strong> <strong>Server</strong> instance<br />

b. C<strong>on</strong>figure the server<br />

c. Migrate the s<strong>to</strong>rage architecture<br />

2. Migrate the schemas<br />

a. Migrate the schema<br />

b. Migrate the schema objects<br />

3. Migrate the users<br />

a. Create user accounts<br />

b. Create roles and grant privileges<br />

4. Migrate the data<br />

a. Plan the data migrati<strong>on</strong><br />

b. Execute the data migrati<strong>on</strong><br />

In Chapters 5 through 8, examples are provided <str<strong>on</strong>g>for</str<strong>on</strong>g> each of the major tasks and subtasks<br />

at the end of the chapter. The discussi<strong>on</strong> of testing the migrated database is in Chapter<br />

9, "Developing: Databases — Unit Testing the Migrati<strong>on</strong>." <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> DBAs who are new <strong>to</strong><br />

<strong>SQL</strong> <strong>Server</strong> should also read Appendix A, "<strong>SQL</strong> <strong>Server</strong> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Professi<strong>on</strong>als," which<br />

provides a c<strong>on</strong>densed guide <str<strong>on</strong>g>for</str<strong>on</strong>g> educating <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> DBAs about the internal architecture of<br />

<strong>SQL</strong> <strong>Server</strong> by leveraging existing knowledge of <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>. The appendix also provides<br />

in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> about how <strong>to</strong> per<str<strong>on</strong>g>for</str<strong>on</strong>g>m some of the comm<strong>on</strong> administrative functi<strong>on</strong>s in<br />

<strong>SQL</strong> <strong>Server</strong>.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 71<br />

5<br />

Developing: Databases —<br />

<str<strong>on</strong>g>Migrating</str<strong>on</strong>g> the Database<br />

Architecture<br />

Introducti<strong>on</strong> and Goals<br />

The first task in the migrati<strong>on</strong> of the database is <strong>to</strong> create an instance of <strong>SQL</strong> <strong>Server</strong> that<br />

will provide the c<strong>on</strong>tainer (the RDBMS) <str<strong>on</strong>g>for</str<strong>on</strong>g> creating schemas and schema objects <strong>to</strong> cater<br />

<strong>to</strong> the needs of applicati<strong>on</strong>s. Your main focus when creating the database should be <strong>on</strong><br />

its architecture: the instance architecture involving server resources, such as processor<br />

power and memory; and s<strong>to</strong>rage architecture, including file systems. Your objective <str<strong>on</strong>g>for</str<strong>on</strong>g><br />

both of these areas is <strong>to</strong> derive per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance that is equivalent <strong>to</strong> or better than the<br />

original soluti<strong>on</strong>.<br />

The two most comm<strong>on</strong> implementati<strong>on</strong>s of databases are Online Transacti<strong>on</strong> Processing<br />

(OLTP) systems and Decisi<strong>on</strong> Support Systems (DSS). OLTP systems are characterized<br />

by large numbers of short transacti<strong>on</strong>s that frequently add or modify data. DSS systems,<br />

<strong>on</strong> the other hand, c<strong>on</strong>tain large volumes of mostly static data imported in<strong>to</strong> them from<br />

OLTP databases, file systems, and other such systems <str<strong>on</strong>g>for</str<strong>on</strong>g> the purposes of analysis and<br />

reporting. There are fewer transacti<strong>on</strong>s in DSS systems, but they run much l<strong>on</strong>ger. OLTP<br />

system per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance is influenced by locking. DSS per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance is typified by large reads,<br />

sorts, computati<strong>on</strong>, and so <strong>on</strong>.<br />

The guidance provided in this soluti<strong>on</strong> is focused <strong>on</strong> OLTP systems. The types of<br />

operati<strong>on</strong>s per<str<strong>on</strong>g>for</str<strong>on</strong>g>med in OLTP and DSS systems impose different demands <strong>on</strong> the<br />

database resources. While the architecture <str<strong>on</strong>g>for</str<strong>on</strong>g> OLTP and DSS systems differs, resource<br />

c<strong>on</strong>siderati<strong>on</strong>s are similar. Though there are some objects that are specialized <str<strong>on</strong>g>for</str<strong>on</strong>g> DSS<br />

systems, most objects are comm<strong>on</strong> <strong>to</strong> both systems. As a result, the guidance provided<br />

applies <strong>to</strong> DSS systems, as well.<br />

Build the <strong>SQL</strong> <strong>Server</strong> Instance<br />

This secti<strong>on</strong> discusses the planning and preparati<strong>on</strong> <str<strong>on</strong>g>for</str<strong>on</strong>g> installing the <strong>SQL</strong> <strong>Server</strong><br />

RDBMS software. A more detailed discussi<strong>on</strong> can be found in <strong>SQL</strong> <strong>Server</strong> Books Online<br />

under the “Installing <strong>SQL</strong> <strong>Server</strong>” <strong>to</strong>pic.


72<br />

Developing: Databases — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> the Database Architecture<br />

Pre-Installati<strong>on</strong> Planning<br />

You should follow these design guidelines <str<strong>on</strong>g>for</str<strong>on</strong>g> the layout of a <strong>SQL</strong> <strong>Server</strong> software<br />

installati<strong>on</strong> and database files:<br />

● Independent subdirec<strong>to</strong>ries. Files should be separated by categories and<br />

instance <strong>to</strong> minimize effects and ease navigati<strong>on</strong>. When named instances of <strong>SQL</strong><br />

<strong>Server</strong> are created, the associated direc<strong>to</strong>ries are created with instance names <str<strong>on</strong>g>for</str<strong>on</strong>g><br />

identificati<strong>on</strong> purposes.<br />

● C<strong>on</strong>sistent naming c<strong>on</strong>venti<strong>on</strong> <str<strong>on</strong>g>for</str<strong>on</strong>g> files. Use the following file name extensi<strong>on</strong>s:<br />

.mdf <str<strong>on</strong>g>for</str<strong>on</strong>g> primary datafiles, .ndf <str<strong>on</strong>g>for</str<strong>on</strong>g> sec<strong>on</strong>dary datafiles, and .ldf <str<strong>on</strong>g>for</str<strong>on</strong>g> log files. The<br />

default file naming c<strong>on</strong>venti<strong>on</strong> is dbname_data.mdf <str<strong>on</strong>g>for</str<strong>on</strong>g> the datafile and<br />

dbname_log.ldf <str<strong>on</strong>g>for</str<strong>on</strong>g> the log file.<br />

● Integrity of home direc<strong>to</strong>ries. Keep the <strong>SQL</strong> <strong>Server</strong> software separate from the<br />

datafiles. This allows the software <strong>to</strong> be moved or deleted without affecting the<br />

applicati<strong>on</strong>.<br />

● Separati<strong>on</strong> of administrative in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <str<strong>on</strong>g>for</str<strong>on</strong>g> each database. S<strong>to</strong>re system data<br />

in the master database separate from other data.<br />

● Separati<strong>on</strong> of tablespace c<strong>on</strong>tent. Every instance of <strong>SQL</strong> <strong>Server</strong> comes with the<br />

system databases master, model, msdb, and tempdb.<br />

● Tune I/O load across all disks. <strong>SQL</strong> <strong>Server</strong> has filegroups, each with multiple<br />

files that give the same advantages as tablespaces. In additi<strong>on</strong>, s<strong>to</strong>rage allocated<br />

<strong>to</strong> an object is distributed evenly across all datafiles bel<strong>on</strong>ging <strong>to</strong> the filegroup.<br />

Installati<strong>on</strong><br />

The following important installati<strong>on</strong> opti<strong>on</strong>s have <strong>to</strong> be determined prior <strong>to</strong> installing <strong>SQL</strong><br />

<strong>Server</strong>:<br />

● Instance name. <strong>SQL</strong> <strong>Server</strong> has a provisi<strong>on</strong> <str<strong>on</strong>g>for</str<strong>on</strong>g> a default instance where the<br />

instance takes the network name of the server. Multiple instances with assigned<br />

names can also be created. <strong>SQL</strong> <strong>Server</strong> naming c<strong>on</strong>venti<strong>on</strong>s do not preclude<br />

reuse of <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> instance names.<br />

● <strong>Net</strong>work libraries. <strong>SQL</strong> <strong>Server</strong> can communicate using several network pro<strong>to</strong>cols.<br />

TCP/IP and named pipes are the most comm<strong>on</strong>. To minimize resource utilizati<strong>on</strong>,<br />

<strong>on</strong>ly c<strong>on</strong>figure those pro<strong>to</strong>cols that are required.<br />

● Service accounts. Like any other service, both <strong>SQL</strong> <strong>Server</strong> and <strong>SQL</strong> <strong>Server</strong><br />

Agent (the <strong>SQL</strong> <strong>Server</strong> scheduling service) require a Microsoft Windows® account.<br />

You should run <strong>SQL</strong> <strong>Server</strong> under a domain account. It does not have <strong>to</strong> be a local<br />

administra<strong>to</strong>r or a domain account that has local administrative privileges.<br />

● Authenticati<strong>on</strong> mode. Opti<strong>on</strong>s available in <strong>SQL</strong> <strong>Server</strong> are Windows<br />

Authenticati<strong>on</strong> or Mixed mode. Mixed mode allows login access <strong>to</strong> <strong>SQL</strong> <strong>Server</strong><br />

either by a valid Windows account or a valid <strong>SQL</strong> <strong>Server</strong> login. The authenticati<strong>on</strong><br />

mode can be changed any time in the future. Changing the authenticati<strong>on</strong> mode<br />

requires that the database be restarted <strong>to</strong> take effect.<br />

● Licensing mode. Indicate whether this <strong>SQL</strong> <strong>Server</strong> is licensed by processor or per<br />

seat (Client Access License) and the number <str<strong>on</strong>g>for</str<strong>on</strong>g> the given mode.<br />

● Locati<strong>on</strong> of files. With <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>, even though the installer provides the opti<strong>on</strong> of<br />

creating a starter database, installing the software and creati<strong>on</strong> of databases are<br />

two independent events. Installing the <strong>SQL</strong> <strong>Server</strong> software also creates a<br />

"database system" with databases such as master, model, msdb, northwind,<br />

pubs, and tempdb created by default. The destinati<strong>on</strong> locati<strong>on</strong> of <strong>SQL</strong> <strong>Server</strong>


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 73<br />

applicati<strong>on</strong> files and the datafiles <str<strong>on</strong>g>for</str<strong>on</strong>g> the default databases can be specified at<br />

installati<strong>on</strong>.<br />

C<strong>on</strong>figure the <strong>Server</strong><br />

A <strong>SQL</strong> <strong>Server</strong> instance can be c<strong>on</strong>figured similar <strong>to</strong> an <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> instance. The areas that<br />

are covered here include memory, CPU, and listener.<br />

Architecturally, both <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong> can be divided in<strong>to</strong> instance and database.<br />

The instance is made up of memory areas and database processes. In <strong>SQL</strong> <strong>Server</strong>, the<br />

divisi<strong>on</strong> of memory pool in<strong>to</strong> sub-caches (buffer cache, procedure cache, log cache,<br />

c<strong>on</strong>necti<strong>on</strong> c<strong>on</strong>text, and system data structures) based <strong>on</strong> functi<strong>on</strong> closely resembles the<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> SGA and its comp<strong>on</strong>ents. <strong>SQL</strong> <strong>Server</strong> has threads that per<str<strong>on</strong>g>for</str<strong>on</strong>g>m similar work <strong>to</strong> the<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g>eground and background processes.<br />

In <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>, the characteristics and behavior of the database and the instance are<br />

determined by a large set of parameters s<strong>to</strong>red in the initializati<strong>on</strong> file (init.ora) or server<br />

parameter file (spfile). These parameters cover a diverse set of resources, such as<br />

memory, processes, network, disk, I/O, c<strong>on</strong>necti<strong>on</strong>s, files, character set, and so <strong>on</strong>.<br />

The n<strong>on</strong>-default values of the <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> initializati<strong>on</strong> parameters can be obtained from the<br />

parameter file if <strong>on</strong>e is in use. If a server parameter file is in use, the parameter values<br />

can be obtained using <strong>on</strong>e of the following opti<strong>on</strong>s:<br />

● C<strong>on</strong>vert the server parameter file (spfile) <strong>to</strong> an initializati<strong>on</strong> parameter file by<br />

executing the following statement:<br />

CREATE pfile FROM spfile<br />

● Query the database by executing the following statement:<br />

SELECT name, value<br />

FROM sys.v$spparameter<br />

WHERE isspecified = 'TRUE'<br />

<strong>SQL</strong> <strong>Server</strong> does not have an equivalent <str<strong>on</strong>g>for</str<strong>on</strong>g> every initializati<strong>on</strong> parameter. The<br />

c<strong>on</strong>figurati<strong>on</strong> opti<strong>on</strong>s in <strong>SQL</strong> <strong>Server</strong> can be specified using <strong>SQL</strong> <strong>Server</strong> Enterprise<br />

Manager or using the sp_c<strong>on</strong>figure system s<strong>to</strong>red procedure. Syntax <str<strong>on</strong>g>for</str<strong>on</strong>g> use is shown in<br />

the following statement.<br />

sp_c<strong>on</strong>figure [opti<strong>on</strong>, [value]]<br />

A discussi<strong>on</strong> of every <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> initializati<strong>on</strong> parameter is bey<strong>on</strong>d the scope of this guide.<br />

The c<strong>on</strong>figurati<strong>on</strong> opti<strong>on</strong>s available in <strong>SQL</strong> <strong>Server</strong> can be categorized in<strong>to</strong> userc<strong>on</strong>figurable<br />

and advanced. The advanced opti<strong>on</strong>s, which are similar <strong>to</strong> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>’s “hidden”<br />

parameters, are either self-c<strong>on</strong>figuring or should be manipulated <strong>on</strong>ly with the advice of a<br />

certified <strong>SQL</strong> <strong>Server</strong> technician.<br />

Examples of <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> parameters that have an equivalent c<strong>on</strong>figurable parameter in<br />

<strong>SQL</strong> <strong>Server</strong> are provided in Table 5.1:<br />

Table 5.1: Examples of <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Initializati<strong>on</strong> Parameters with Equivalent in<br />

<strong>SQL</strong> <strong>Server</strong><br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g><br />

Processes<br />

fast_start_mttr_target<br />

Sessi<strong>on</strong>s<br />

dml_locks<br />

<strong>SQL</strong> <strong>Server</strong><br />

max worker thread opti<strong>on</strong>s<br />

recovery interval<br />

User c<strong>on</strong>necti<strong>on</strong>s<br />

Locks


74<br />

Developing: Databases — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> the Database Architecture<br />

Sometimes a c<strong>on</strong>figurati<strong>on</strong> opti<strong>on</strong> can be set at <strong>on</strong>e of several different places. For<br />

example, the <strong>SQL</strong> <strong>Server</strong> max degree of parallelism parameter can be set using the<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> DEGREE clause at the object or query level.<br />

Certain opti<strong>on</strong>s which are c<strong>on</strong>figurable in <strong>on</strong>e database may have a fixed implementati<strong>on</strong><br />

in the other. For example, the <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> LOG_CHECKPOINT_INTERVAL and<br />

LOG_CHECKPOINT_TIMEOUT parameters used <strong>to</strong> tune checkpoints do not have<br />

equivalents in <strong>SQL</strong> <strong>Server</strong>. In <strong>SQL</strong> <strong>Server</strong>, checkpoints occur au<strong>to</strong>matically based <strong>on</strong> the<br />

number of redo records in the log. Similarly, UNDO_MANAGEMENT,<br />

UNDO_TABLESPACE, and ROLLBACK_SEGMENTS that define the s<strong>to</strong>rage <str<strong>on</strong>g>for</str<strong>on</strong>g><br />

transacti<strong>on</strong> rollback or undo data are implemented in <strong>SQL</strong> <strong>Server</strong> as part of the<br />

transacti<strong>on</strong> logs of each database.<br />

C<strong>on</strong>figure Memory<br />

<strong>SQL</strong> <strong>Server</strong> has far fewer c<strong>on</strong>figurati<strong>on</strong> parameters than <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>. In <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>, there are<br />

several parameters that are used <strong>to</strong> c<strong>on</strong>trol memory allocati<strong>on</strong> <strong>to</strong> the instance and its<br />

sub-comp<strong>on</strong>ents. Some of these parameters are<br />

● SGA_MAX_SIZE<br />

● DB_CACHE_SIZE<br />

● SHARED_POOL_SIZE<br />

● LARGE_POOL_SIZE<br />

● JAVA_POOL_SIZE<br />

● LOG_BUFFER<br />

● SORT_AREA_SIZE<br />

<strong>SQL</strong> <strong>Server</strong> offers the parameters min server memory and max server memory, which<br />

can be used <strong>to</strong> limit the amount of server memory that can be utilized by the database<br />

system. <strong>SQL</strong> <strong>Server</strong> cooperates with the operating system <strong>to</strong> dynamically adjust the<br />

amount of memory used based <strong>on</strong> the demands <strong>on</strong> the server from other applicati<strong>on</strong>s.<br />

However, this behavior puts the burden <strong>on</strong> the dimensi<strong>on</strong>ing of the system so it is<br />

capable of running the database with known loads and peaks and avoiding competing<br />

workloads which might jeopardize the system resources available <strong>to</strong> the database. All<br />

memory areas within the memory pool are dynamically adjusted by the <strong>SQL</strong> <strong>Server</strong> code<br />

<strong>to</strong> optimize per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance and do not need any administra<strong>to</strong>r input. Hence you will find<br />

very few memory-related c<strong>on</strong>figurati<strong>on</strong> parameters in <strong>SQL</strong> <strong>Server</strong>.<br />

The amount of memory that can be utilized by <strong>SQL</strong> <strong>Server</strong> can be c<strong>on</strong>figured either using<br />

Enterprise Manager or through T-<strong>SQL</strong>. The two opti<strong>on</strong>s are provided in the following<br />

procedures:


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 75<br />

To c<strong>on</strong>figure the amount of memory available <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>SQL</strong> <strong>Server</strong> in Enterprise<br />

Manager, follow these steps:<br />

1. Expand the server group.<br />

2. Right-click <strong>Server</strong> (<strong>Server</strong> Name\Instance Name), and then click Properties.<br />

3. Select the Memory tab.<br />

4. Select Dynamically c<strong>on</strong>figure <strong>SQL</strong> <strong>Server</strong> memory <strong>to</strong> set the memory range<br />

under which <strong>SQL</strong> <strong>Server</strong> should operate. Select Use a fixed memory size (MB) <strong>to</strong><br />

allocate a fixed amount of memory. The actual values can be selected using the<br />

memory slider graphic.<br />

The code <str<strong>on</strong>g>for</str<strong>on</strong>g> setting a range of memory and a fixed amount of memory <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>SQL</strong> <strong>Server</strong> is<br />

provided in the following procedure.<br />

To c<strong>on</strong>figure a range of memory <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>SQL</strong> <strong>Server</strong> using T-<strong>SQL</strong>, enter the<br />

following commands:<br />

USE master<br />

EXEC sp_c<strong>on</strong>figure 'show advanced opti<strong>on</strong>', 1<br />

RECONFIGURE<br />

GO<br />

sp_c<strong>on</strong>figure 'min server memory', 100 -- 100MB<br />

RECONFIGURE<br />

GO<br />

sp_c<strong>on</strong>figure 'max server memory', 4000 -- 4000 MB<br />

RECONFIGURE<br />

GO<br />

To c<strong>on</strong>figure a fixed amount of memory <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>SQL</strong> <strong>Server</strong> using T-<strong>SQL</strong>, enter the<br />

following commands:<br />

USE master<br />

sp_c<strong>on</strong>figure 'show advanced opti<strong>on</strong>', 1<br />

RECONFIGURE<br />

GO<br />

sp_c<strong>on</strong>figure 'min server memory', 400<br />

RECONFIGURE<br />

GO<br />

sp_c<strong>on</strong>figure 'max server memory', 400<br />

RECONFIGURE<br />

GO<br />

Note A database restart is required <strong>to</strong> activate the new settings of all advanced opti<strong>on</strong>s.<br />

If the amount of physical memory exceeds 3 GB, then the Address Windowing<br />

Extensi<strong>on</strong>s (AWE) Windows feature has <strong>to</strong> be enabled <strong>to</strong> handle allocati<strong>on</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong><br />

using the c<strong>on</strong>figurati<strong>on</strong> parameter awe enabled. When this feature is enabled,<br />

<strong>SQL</strong> <strong>Server</strong> s<strong>to</strong>ps dynamic memory management at the server level and the max server<br />

memory parameter has <strong>to</strong> be set. If the max server memory parameter is set, cache


76<br />

Developing: Databases — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> the Database Architecture<br />

management is similar <strong>to</strong> SGA sizing in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> but without the complicati<strong>on</strong>s of tuning the<br />

individual cache comp<strong>on</strong>ents.<br />

To c<strong>on</strong>figure <strong>SQL</strong> <strong>Server</strong> <strong>to</strong> use more than 3 GB of memory using T-<strong>SQL</strong>,<br />

enter the following commands:<br />

USE master<br />

sp_c<strong>on</strong>figure 'show advanced opti<strong>on</strong>', 1<br />

RECONFIGURE<br />

GO<br />

sp_c<strong>on</strong>figure 'awe enabled', 1<br />

RECONFIGURE<br />

GO<br />

sp_c<strong>on</strong>figure 'max server memory', 6000<br />

RECONFIGURE<br />

GO<br />

Because the memory requirements of a <strong>SQL</strong> <strong>Server</strong> instance are not the same as an<br />

equivalent <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> instance, the <strong>SQL</strong> <strong>Server</strong> memory size has <strong>to</strong> be tuned during a<br />

migrati<strong>on</strong>. The following Per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance M<strong>on</strong>i<strong>to</strong>r counters can be used <strong>to</strong> check the amount<br />

of memory <strong>SQL</strong> <strong>Server</strong> is using:<br />

● <strong>SQL</strong> <strong>Server</strong>: Buffer Manager: Total Pages<br />

● <strong>SQL</strong> <strong>Server</strong>: Memory Manager: Total <strong>Server</strong> Memory (KB)<br />

● Process: Working Set<br />

The dbcc memorystatus command can be used <strong>to</strong> view in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> about memory<br />

allocati<strong>on</strong>. For more in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> about memory usage and this command, refer <strong>to</strong><br />

http://support.microsoft.com/?id=271624.<br />

The LOCK_SGA initializati<strong>on</strong> parameter can be implemented in <strong>SQL</strong> <strong>Server</strong> using set<br />

working set size. The allocated memory stays in physical memory and improves<br />

per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance because swapping is avoided. However, care should be taken that<br />

allocating a fixed amount of memory <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> does not impact the needs of other<br />

applicati<strong>on</strong>s running <strong>on</strong> the same server.<br />

Set the CPU Affinity<br />

<strong>SQL</strong> <strong>Server</strong> has the capability of defining CPU affinity where CPUs can be dedicated <strong>to</strong><br />

an instance. This can be c<strong>on</strong>trolled using the affinity mask c<strong>on</strong>figurati<strong>on</strong> setting or<br />

Enterprise Manager. The priority boost c<strong>on</strong>figurati<strong>on</strong> setting can be used <strong>to</strong> prioritize<br />

threads. <strong>SQL</strong> <strong>Server</strong> SP1 has added an IO_affinity_mask switch, which can used at<br />

instance startup <strong>to</strong> reserve CPUs <strong>to</strong> handle disk I/O associated with the instance. Use of<br />

the IO_affinity_mask c<strong>on</strong>figurati<strong>on</strong> setting is <strong>on</strong>ly recommended <str<strong>on</strong>g>for</str<strong>on</strong>g> machines with more<br />

than 16 CPUs.<br />

For more in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <strong>on</strong> setting up the I/O affinity mask, refer <strong>to</strong><br />

http://support.microsoft.com/?kbid=298402.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 77<br />

C<strong>on</strong>figure the Listener<br />

The <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> listener can operate <strong>on</strong> any available port. The well-known default selecti<strong>on</strong> is<br />

1521. A default installati<strong>on</strong> of <strong>SQL</strong> <strong>Server</strong> uses port 1433. If not c<strong>on</strong>figured manually, a<br />

named instance picks up an unused TCP port during startup. Unlike <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>, where a<br />

single listener is shared by all instances, each <strong>SQL</strong> <strong>Server</strong> instance listens <strong>on</strong> its own<br />

port. The <strong>SQL</strong> <strong>Server</strong> server name, database name, and port in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> are required by<br />

client applicati<strong>on</strong>s <strong>to</strong> c<strong>on</strong>figure the data source or the c<strong>on</strong>necti<strong>on</strong> string (in n<strong>on</strong>-DNS<br />

c<strong>on</strong>necti<strong>on</strong>s).<br />

Migrate the S<strong>to</strong>rage Architecture<br />

This secti<strong>on</strong> discusses the physical and logical s<strong>to</strong>rage structures found in <strong>SQL</strong> <strong>Server</strong>.<br />

This discussi<strong>on</strong> is useful in understanding how <strong>to</strong> c<strong>on</strong>figure s<strong>to</strong>rage in <strong>SQL</strong> <strong>Server</strong> in a<br />

manner similar <strong>to</strong> the original <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> database.<br />

Database data is physically s<strong>to</strong>red in files. However, allocati<strong>on</strong> of this space <strong>to</strong> the<br />

database objects is d<strong>on</strong>e in logical units such as blocks, extents, and segments. Figure<br />

5.1 provides a comparis<strong>on</strong> of the s<strong>to</strong>rage architecture in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong>.<br />

Figure 5.1<br />

Mapping <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> s<strong>to</strong>rage structures <strong>to</strong> <strong>SQL</strong> <strong>Server</strong><br />

The organizati<strong>on</strong> of s<strong>to</strong>rage and its allocati<strong>on</strong> has great significance <strong>on</strong> per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance and<br />

maintenance of a database. Due <strong>to</strong> the similarities in the s<strong>to</strong>rage architecture, the<br />

principles <strong>on</strong> which the source <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> database was organized can be carried over in<strong>to</strong><br />

the <strong>SQL</strong> <strong>Server</strong> database with relative ease. The following secti<strong>on</strong>s discuss each level of<br />

the s<strong>to</strong>rage hierarchy shown in Figure 5.1.<br />

Blocks<br />

In <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>, the smallest unit of s<strong>to</strong>rage is the data block. All data in the database is<br />

retrieved and manipulated in terms of blocks. The <strong>SQL</strong> <strong>Server</strong> equivalent of the data<br />

block is called the page. In <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>, the DBA chooses the default page size at database<br />

creati<strong>on</strong> <strong>to</strong> be any of 2K, 4K, 8K, 16K or 32K. In <strong>SQL</strong> <strong>Server</strong>, the page size is fixed at 8K.<br />

With <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> 9i, in additi<strong>on</strong> <strong>to</strong> the default page size, up <strong>to</strong> five n<strong>on</strong>-standard (n<strong>on</strong>-default)


78<br />

Developing: Databases — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> the Database Architecture<br />

page sizes can also be used <str<strong>on</strong>g>for</str<strong>on</strong>g> the tablespaces (and, c<strong>on</strong>sequently, the logical s<strong>to</strong>rage<br />

structures).<br />

The <strong>SQL</strong> <strong>Server</strong> page has similar compositi<strong>on</strong> as the <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> data block. The data page<br />

c<strong>on</strong>sists of page header, data rows, and row offset array (row direc<strong>to</strong>ry). The header<br />

leaves 8060 bytes of usable space <str<strong>on</strong>g>for</str<strong>on</strong>g> data rows and row offset. In <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>, a data row<br />

that is larger than the usable space is broken in<strong>to</strong> several row pieces (row chaining) and<br />

s<strong>to</strong>red in multiple blocks. <strong>SQL</strong> <strong>Server</strong> does not allow rows larger than 8060 bytes. This<br />

restricti<strong>on</strong> in <strong>SQL</strong> <strong>Server</strong>, however, does not apply <strong>to</strong> rows c<strong>on</strong>taining large data types,<br />

such as text, image, and so <strong>on</strong>, which are s<strong>to</strong>red differently.<br />

Within a <strong>SQL</strong> <strong>Server</strong> block, space is managed in a manner similar <strong>to</strong> that by <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>’s<br />

Au<strong>to</strong>matic Segment Space Management (ASSM) opti<strong>on</strong>, where used and free space is<br />

tracked using bitmaps. This has implicati<strong>on</strong>s with respect <strong>to</strong> migrating <strong>to</strong> <strong>SQL</strong> <strong>Server</strong>. In<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g>, the choice of block size is driven by the type of database — OLTP or DSS/Data<br />

Warehouse. The advantage of large block size is mainly in terms of I/O per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance<br />

because there is less overall cost <str<strong>on</strong>g>for</str<strong>on</strong>g> setting up fewer I/Os. Better I/O per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance can<br />

be achieved with smaller block sizes by using other techniques, such as multi-block read<br />

(DB_FILE_MULTIBLOCK_READ_COUNT), parallel reads and read ahead, or prefetch.<br />

The maximum I/O size, however, is dependent <strong>on</strong> the operating system. <strong>SQL</strong> <strong>Server</strong> also<br />

uses a technique called scatter I/O that enables multiple unrelated blocks <strong>to</strong> be read in a<br />

single I/O request.<br />

An advantage of larger block size is reduced amount of row chaining. This is a fac<strong>to</strong>r<br />

when tables c<strong>on</strong>tain rows with lengths larger than can be accommodated in a block.<br />

Reading of multiple blocks may be necessitated in a <strong>SQL</strong> <strong>Server</strong> database as compared<br />

<strong>to</strong> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> databases with larger block size, but the per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance can be compensated <str<strong>on</strong>g>for</str<strong>on</strong>g><br />

by better hardware and I/O techniques.<br />

Based <strong>on</strong> the envir<strong>on</strong>ment, large block sizes can impact cache per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance. With large<br />

block sizes, <str<strong>on</strong>g>for</str<strong>on</strong>g> a fixed amount of RAM, the number of blocks in physical memory<br />

reduces. For example, if 1 MB of memory can hold 500 blocks of size 2 KB, it can hold<br />

<strong>on</strong>ly 125 blocks of size 8 KB. So the cache per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance is dependent <strong>on</strong> the density of<br />

the block (number of rows per block) and the access pattern (random or sequential).<br />

Smaller blocks reduce c<strong>on</strong>tenti<strong>on</strong> while the overhead becomes a larger porti<strong>on</strong> of the<br />

block.<br />

In the migrati<strong>on</strong>, the move from differing block sizes in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>to</strong> 8 KB blocks in<br />

<strong>SQL</strong> <strong>Server</strong> does not pose any challenge. When migrating from <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> (where multiple<br />

block sizes are in use), the rows will be rearranged in<strong>to</strong> 8 KB blocks. However, soluti<strong>on</strong>s<br />

have <strong>to</strong> be created <strong>to</strong> accommodate rows with length greater than 8060 bytes. Such<br />

soluti<strong>on</strong>s are examined later in this chapter.<br />

Extents and Segments<br />

Data allocati<strong>on</strong> <strong>to</strong> schema objects (such as tables and indexes) and system data<br />

structures (temporary segment, rollback segment) in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong> is in terms<br />

of logical extents. <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> provides parameters <str<strong>on</strong>g>for</str<strong>on</strong>g> appropriate sizing of the extents.<br />

<strong>SQL</strong> <strong>Server</strong>, <strong>on</strong> the other hand, uses fixed size extents of 8 pages (64 KB). <str<strong>on</strong>g>Oracle</str<strong>on</strong>g><br />

extents — irrespective of whether they bel<strong>on</strong>g <strong>to</strong> dicti<strong>on</strong>ary or locally-managed<br />

tablespaces — are migrated <strong>to</strong> fixed 64 KB extents.<br />

Extents allocated <strong>to</strong> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> objects are dedicated <strong>to</strong> the object and do not c<strong>on</strong>tain blocks<br />

from other objects. This is not the case in <strong>SQL</strong> <strong>Server</strong>. <strong>SQL</strong> <strong>Server</strong> has two types of<br />

extents: uni<str<strong>on</strong>g>for</str<strong>on</strong>g>m and mixed. In a uni<str<strong>on</strong>g>for</str<strong>on</strong>g>m extent, all pages are allocated <strong>to</strong> a single object,<br />

while mixed extents can have pages bel<strong>on</strong>ging <strong>to</strong> multiple objects. When a table or index<br />

is created in <strong>SQL</strong> <strong>Server</strong>, initially it is allocated two pages out of mixed extent. When the


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 79<br />

table or index grows <strong>to</strong> eight pages, all future allocati<strong>on</strong>s use uni<str<strong>on</strong>g>for</str<strong>on</strong>g>m extents. As a result<br />

of fixed size extents, fragmentati<strong>on</strong> within the tablespace (filegroup in <strong>SQL</strong> <strong>Server</strong>) is<br />

eliminated.<br />

Because an extent is a c<strong>on</strong>tiguous allocati<strong>on</strong> of blocks, large extents aid in better I/O rate<br />

while reading huge amounts of data. After moving <strong>to</strong> <strong>SQL</strong> <strong>Server</strong>, physical I/O will have<br />

<strong>to</strong> be c<strong>on</strong>figured and tuned, as was the case with the change in block sizes.<br />

In <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>, all extents of an object are collectively called a segment. While the c<strong>on</strong>cept of<br />

segment existed in versi<strong>on</strong> 6.5, <strong>SQL</strong> <strong>Server</strong> does not have an equivalent <str<strong>on</strong>g>for</str<strong>on</strong>g> the segment<br />

from versi<strong>on</strong> 7.0 and later. The segment has no bearing <strong>on</strong> migrati<strong>on</strong> or per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance.<br />

Tablespaces and Datafiles<br />

Datafiles are used <strong>to</strong> s<strong>to</strong>re persistent data in the database. For ease of management, <strong>on</strong>e<br />

or more datafiles can be grouped in<strong>to</strong> logical tablespaces. The <strong>SQL</strong> <strong>Server</strong> equivalent of<br />

the tablespace is the filegroup. While filegroups are similar in functi<strong>on</strong>, their organizati<strong>on</strong><br />

differs from that of tablespaces. <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> tablespaces are at the instance level. <strong>SQL</strong> <strong>Server</strong><br />

filegroups come under and are associated with the individual databases. Figure 5.2<br />

illustrates the tablespace <strong>to</strong> datafiles hierarchy:


80<br />

Developing: Databases — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> the Database Architecture<br />

Figure 5.2<br />

Schematic mapping of <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> files and tablespaces <strong>to</strong> <strong>SQL</strong> <strong>Server</strong>


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 81<br />

Table 5.2 captures some of the relati<strong>on</strong>s between tablespaces in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and databases<br />

in <strong>SQL</strong> <strong>Server</strong> that are not obvious in Figure 5.2.<br />

Table 5.2: <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Tablespaces and <strong>SQL</strong> <strong>Server</strong> Functi<strong>on</strong>al Equivalents<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g><br />

System tablespace<br />

Temporary tablespace<br />

Undo (Rollback) tablespace<br />

Online Redo log<br />

"App Data" tablespace<br />

"App Index" tablespace<br />

N/A<br />

N/A<br />

<strong>SQL</strong> <strong>Server</strong><br />

master database<br />

tempdb database<br />

Transacti<strong>on</strong> log<br />

Transacti<strong>on</strong> log<br />

"App" database —"Data" filegroup<br />

"App" database —"Index" filegroup<br />

model database<br />

msdb database<br />

The following list describes how <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> functi<strong>on</strong>ality is implemented in <strong>SQL</strong> <strong>Server</strong>:<br />

●<br />

●<br />

●<br />

●<br />

●<br />

Each of the <strong>SQL</strong> <strong>Server</strong> databases has its own security structures, such as users,<br />

privileges (permissi<strong>on</strong>s), and roles.<br />

Each of the <strong>SQL</strong> <strong>Server</strong> databases has its own administrative roles that bes<strong>to</strong>w<br />

privileges <strong>on</strong> the database.<br />

In <strong>SQL</strong> <strong>Server</strong>, the system catalog — which is analogous <strong>to</strong> the <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> data<br />

dicti<strong>on</strong>ary — is broken up between the individual databases and the master<br />

database.<br />

In <strong>SQL</strong> <strong>Server</strong>, each of the databases has its own transacti<strong>on</strong> log files, which<br />

combine the functi<strong>on</strong>s of the <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong>line redo logs and rollback segments.<br />

The tempdb database provides temporary s<strong>to</strong>rage <str<strong>on</strong>g>for</str<strong>on</strong>g> the entire <strong>SQL</strong> <strong>Server</strong><br />

instance, and the temporary tablespace in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> is comm<strong>on</strong> <strong>to</strong> the entire <str<strong>on</strong>g>Oracle</str<strong>on</strong>g><br />

instance.<br />

Tablespaces and filegroups provide the ability <strong>to</strong> better distribute data across multiple<br />

files <str<strong>on</strong>g>for</str<strong>on</strong>g> the purposes of per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance. The grouping also helps ease administrati<strong>on</strong> of<br />

backup and recovery, maintenance, availability, and so <strong>on</strong>.<br />

Each <strong>SQL</strong> <strong>Server</strong> database is created with a primary file bel<strong>on</strong>ging <strong>to</strong> the default primary<br />

filegroup. Opti<strong>on</strong>ally, sec<strong>on</strong>dary datafiles can be added <strong>to</strong> the primary filegroup, or<br />

additi<strong>on</strong>al filegroups can be created. The locati<strong>on</strong> of the files bel<strong>on</strong>ging <strong>to</strong> a database is<br />

recorded in the master database and the primary file <str<strong>on</strong>g>for</str<strong>on</strong>g> the database. Data added <strong>to</strong><br />

objects of a filegroup are proporti<strong>on</strong>ally filled across all files bel<strong>on</strong>ging <strong>to</strong> the filegroup.<br />

A comm<strong>on</strong> c<strong>on</strong>cern am<strong>on</strong>g users when creating <strong>SQL</strong> <strong>Server</strong> databases is the lack of the<br />

multiplexing feature available in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> c<strong>on</strong>trol files and redo logs. This is not a<br />

c<strong>on</strong>cern because <strong>SQL</strong> <strong>Server</strong> recommends the use of striped and mirrored devices<br />

(RAID 0+1) <str<strong>on</strong>g>for</str<strong>on</strong>g> transacti<strong>on</strong> logs <strong>to</strong> preserve the level of protecti<strong>on</strong> against hardware<br />

failure obtained by log multiplexing. <strong>SQL</strong> <strong>Server</strong> recommends using RAID 0+1 <str<strong>on</strong>g>for</str<strong>on</strong>g> all<br />

database datafiles. If RAID 0+1 cannot be implemented, at a minimum RAID 5 should be<br />

used <strong>to</strong> provide <strong>to</strong>lerance <str<strong>on</strong>g>for</str<strong>on</strong>g> hard disk failure. Apart from file systems, <strong>SQL</strong> <strong>Server</strong> also<br />

supports the use of raw partiti<strong>on</strong>s.<br />

S<strong>to</strong>rage Definiti<strong>on</strong> <str<strong>on</strong>g>for</str<strong>on</strong>g> Tables and Indexes<br />

In <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>, the s<strong>to</strong>rage definiti<strong>on</strong> is used <strong>to</strong> specify the characteristics of tables and<br />

indexes. The following list provides in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <strong>on</strong> how these characteristics migrate <strong>to</strong><br />

<strong>SQL</strong> <strong>Server</strong>.


82<br />

Developing: Databases — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> the Database Architecture<br />

●<br />

●<br />

●<br />

Physical attributes. These include PCTUSED, PCTFREE, INITRANS, and<br />

MAXTRANS. Of these parameters, <strong>SQL</strong> <strong>Server</strong> <strong>on</strong>ly offers an equivalent <str<strong>on</strong>g>for</str<strong>on</strong>g><br />

PCTFREE through the FILLFACTOR clause. FILLFACTOR is available <str<strong>on</strong>g>for</str<strong>on</strong>g> indexes<br />

<strong>on</strong>ly. A PCTFREE of 10 would corresp<strong>on</strong>d <strong>to</strong> a FILLFACTOR of 90.<br />

Tablespace. This is used in a manner similar <strong>to</strong> tables. The <strong>SQL</strong> <strong>Server</strong> equivalent<br />

is the ON filegroup_name opti<strong>on</strong>. A default filegroup can be specified <str<strong>on</strong>g>for</str<strong>on</strong>g> each<br />

database, and the default filegroup functi<strong>on</strong>s similar <strong>to</strong> the default tablespace of an<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> user. If a filegroup is not specified during index creati<strong>on</strong>, the index is<br />

created in the default filegroup <str<strong>on</strong>g>for</str<strong>on</strong>g> the database.<br />

S<strong>to</strong>rage attributes. These override the defaults specified at the tablespace level,<br />

such as INITIAL, NEXT, MINEXTENTS, MAXEXTENTS, PCTINCREASE, and so<br />

<strong>on</strong>. Due <strong>to</strong> the fixed (64 KB) extents, these attributes have no relevance in<br />

<strong>SQL</strong> <strong>Server</strong>.<br />

Migrate System S<strong>to</strong>rage Structures<br />

As has already been presented in this chapter, an <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> database has the following<br />

system structures that have a similar role in a <strong>SQL</strong> <strong>Server</strong> database. The c<strong>on</strong>figurati<strong>on</strong> of<br />

these structures in an <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> database can be used <strong>to</strong> provide a starting point <str<strong>on</strong>g>for</str<strong>on</strong>g><br />

c<strong>on</strong>figurati<strong>on</strong> in <strong>SQL</strong> <strong>Server</strong>.<br />

● System tablespace. In <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>, the system tablespace houses the data dicti<strong>on</strong>ary<br />

and the system rollback segments. The master database in <strong>SQL</strong> <strong>Server</strong> has a<br />

similar role. The transacti<strong>on</strong> log — which also holds the rollback in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> — is in<br />

a separate file. Also, the data dicti<strong>on</strong>ary in the master database does not grow<br />

because user object in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> is s<strong>to</strong>red in the primary file of the c<strong>on</strong>tained<br />

database under the decentralized data dicti<strong>on</strong>ary model of <strong>SQL</strong> <strong>Server</strong>. The<br />

master database also has some of the in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> that is s<strong>to</strong>red in the c<strong>on</strong>trol file<br />

of an <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> database. Based <strong>on</strong> these facts, it is appropriate <strong>to</strong> use the default<br />

master database settings.<br />

● Rollback or undo. In <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>, a separate tablespace exists <str<strong>on</strong>g>for</str<strong>on</strong>g> holding rollback<br />

segments (manual and au<strong>to</strong> modes) whose size and number is dependent up<strong>on</strong><br />

the number of user c<strong>on</strong>necti<strong>on</strong>s and the amount of changes being made <strong>to</strong> the<br />

database. These fac<strong>to</strong>rs should be c<strong>on</strong>sidered in sizing the transacti<strong>on</strong> log in<br />

<strong>SQL</strong> <strong>Server</strong>.<br />

● Redo. There are several fac<strong>to</strong>rs <strong>to</strong> c<strong>on</strong>sider while choosing the size of a<br />

transacti<strong>on</strong> log. The source <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> database has more than <strong>on</strong>e schema that will<br />

be migrated in<strong>to</strong> separate <strong>SQL</strong> <strong>Server</strong> databases. For the same transacti<strong>on</strong>, the<br />

amount of redo and rollback in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> generated in <strong>SQL</strong> <strong>Server</strong> and <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> is<br />

different. The frequency of backup or truncati<strong>on</strong> of the transacti<strong>on</strong> log also<br />

influences the size. Hence pro<strong>to</strong>typing is the best way <strong>to</strong> size the <strong>SQL</strong> <strong>Server</strong><br />

transacti<strong>on</strong> log.<br />

● Temporary. The size of tempdb can be initially set <strong>to</strong> a c<strong>on</strong>servative size as<br />

compared <strong>to</strong> its <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> counterpart, the temporary tablespace. The au<strong>to</strong>-increment<br />

feature should be set <strong>to</strong> ensure that transacti<strong>on</strong>s do not fail due <strong>to</strong> lack of space.<br />

Setting very small increments will also affect per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance due <strong>to</strong> c<strong>on</strong>stant space<br />

operati<strong>on</strong>s. The temporary space needs are based <strong>on</strong> the applicati<strong>on</strong> needs, which<br />

may change a little as applicati<strong>on</strong>s are migrated <strong>to</strong> a <strong>SQL</strong> <strong>Server</strong> envir<strong>on</strong>ment.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 83<br />

6<br />

Developing: Databases —<br />

<str<strong>on</strong>g>Migrating</str<strong>on</strong>g> Schemas<br />

Introducti<strong>on</strong> and Goals<br />

The next task is <strong>to</strong> create additi<strong>on</strong>al databases <strong>to</strong> house the applicati<strong>on</strong> schema objects<br />

and the objects that are migrated.<br />

Apart from the architectural differences menti<strong>on</strong>ed in Chapter 5, there are also<br />

differences in data models between OLTP and DSS systems. OLTP systems have more<br />

complex relati<strong>on</strong>s, with c<strong>on</strong>straints used <strong>to</strong> en<str<strong>on</strong>g>for</str<strong>on</strong>g>ce business rules. DSS systems have<br />

simpler and far fewer relati<strong>on</strong>ships between tables. Despite the differences between<br />

systems and schema modeling techniques (such as normalized, star, and snowflake), the<br />

implementati<strong>on</strong> of the physical schema uses the same set of objects, such as tables,<br />

indexes, and views. As a result, migrati<strong>on</strong> of the schemas and data is the same <str<strong>on</strong>g>for</str<strong>on</strong>g> all<br />

these types. As in Chapter 5, the examples used in this chapter focus <strong>on</strong> OLTP systems,<br />

but the guidance is applicable <strong>to</strong> DSS systems, as well.<br />

A Microsoft® <strong>SQL</strong> <strong>Server</strong> database has the characteristics of an <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> schema<br />

because objects can be created inside the database. In <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>, the schema and the<br />

s<strong>to</strong>rage (tablespaces) have independent identities — objects of a schema can be created<br />

in different tablespaces, and a single tablespace can accommodate objects from multiple<br />

schemas. In this c<strong>on</strong>text, <strong>SQL</strong> <strong>Server</strong> databases are similar <strong>to</strong> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> tablespaces — an<br />

owner can create objects in different databases, and a database can c<strong>on</strong>tain objects from<br />

different owners.<br />

In spite of this fact, the database provides a higher degree of separati<strong>on</strong> of the<br />

applicati<strong>on</strong> data and security than is provided by schemas. <strong>SQL</strong> <strong>Server</strong> has been<br />

designed <str<strong>on</strong>g>for</str<strong>on</strong>g> the isolati<strong>on</strong> of administrative duties at the database level. The system<br />

(catalog and roles) has been divided, with centralized functi<strong>on</strong>s that have instance-wide<br />

authority under the master database and database-specific functi<strong>on</strong>s under the individual<br />

databases.<br />

Creating a <strong>SQL</strong> <strong>Server</strong> database <str<strong>on</strong>g>for</str<strong>on</strong>g> each <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> schema is the ideal choice <str<strong>on</strong>g>for</str<strong>on</strong>g> the<br />

logical separati<strong>on</strong> of objects based <strong>on</strong> the business functi<strong>on</strong> (applicati<strong>on</strong>) that is provided<br />

by the <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> schemas. Subsequently, the schema's objects can be created under the<br />

database.<br />

Tools are available from Microsoft that can assist in this step of the database migrati<strong>on</strong>.<br />

The Microsoft <strong>SQL</strong> <strong>Server</strong> Migrati<strong>on</strong> Assistant (SSMA) provides the Schema and Data


84<br />

Developing: Databases — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> Schemas<br />

Migra<strong>to</strong>r, which specializes in the migrati<strong>on</strong> of the <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> schema <strong>to</strong> <strong>SQL</strong> <strong>Server</strong>. The<br />

SSMA also provides the <strong>SQL</strong> C<strong>on</strong>verter <strong>to</strong>ol, which c<strong>on</strong>verts <strong>SQL</strong> code found in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g><br />

objects (such as s<strong>to</strong>red procedures) <strong>to</strong> their T-<strong>SQL</strong> equivalents. The SSMA <strong>to</strong>ol suite can<br />

be downloaded from http://www.microsoft.com/sql/migrati<strong>on</strong>. The beta versi<strong>on</strong> of SSMA<br />

is available as of the date of publishing this soluti<strong>on</strong>. Versi<strong>on</strong> 1.0 of SSMA is slated <strong>to</strong> be<br />

available in June 2005.<br />

Most <strong>to</strong>ols that are employed in the administrati<strong>on</strong> of <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> databases are capable of<br />

extracting object definiti<strong>on</strong>s. Toad and <strong>SQL</strong> Naviga<strong>to</strong>r from Quest, PL/<strong>SQL</strong> Developer<br />

from Allround Au<strong>to</strong>mati<strong>on</strong>s, Unicenter <strong>SQL</strong>-Stati<strong>on</strong> from Computer Associates, Rapid<br />

<strong>SQL</strong> from Embarcedero, and <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Enterprise Manager from <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> are examples of<br />

such <strong>to</strong>ols.<br />

Modeling <strong>to</strong>ols such as AllFusi<strong>on</strong> (Erwin) from Computer Associates and ER/Studio from<br />

Embarcadero can also be employed <strong>to</strong> reverse engineer the <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> database.<br />

The goal of this chapter is <strong>to</strong> show how an <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> schema and its objects should be<br />

migrated <strong>to</strong> <strong>SQL</strong> <strong>Server</strong>. Scripts should be used <str<strong>on</strong>g>for</str<strong>on</strong>g> per<str<strong>on</strong>g>for</str<strong>on</strong>g>ming most of the tasks in this<br />

step, because scripts make the migrati<strong>on</strong> easier <strong>to</strong> execute compared <strong>to</strong> the use of GUI<br />

<strong>to</strong>ols.<br />

Scripting Migrated Schema Objects<br />

The development process is built <strong>on</strong> the requirement that when the development is<br />

complete, the code will be in place <str<strong>on</strong>g>for</str<strong>on</strong>g> unit testing and implementati<strong>on</strong>. These scripts will<br />

allow recreati<strong>on</strong> of the objects in a reliable manner when creating the database in the<br />

Stabilizing Phase and the Deploying Phase. There are some basic rules that should be<br />

followed when scripting the database <str<strong>on</strong>g>for</str<strong>on</strong>g> promoti<strong>on</strong> <strong>to</strong> a staging envir<strong>on</strong>ment <str<strong>on</strong>g>for</str<strong>on</strong>g> unit<br />

testing:<br />

● Script everything<br />

● Provide support documentati<strong>on</strong><br />

● Protect the scripts<br />

Each of these basic rules is discussed under the following headings.<br />

Script Everything<br />

Script everything associated with the database implementati<strong>on</strong>. The Generate <strong>SQL</strong> Script<br />

feature of <strong>SQL</strong> <strong>Server</strong> Enterprise Manager can be used <strong>to</strong> script each database object in<br />

the migrated database. After the scripts are created, c<strong>on</strong>duct a validati<strong>on</strong> process <strong>to</strong><br />

verify that the number of objects scripted is the same as the number of objects that exist<br />

in the development database. This process is very important because it helps <strong>to</strong> ensure<br />

that the database being promoted <strong>to</strong> the staging envir<strong>on</strong>ment is identical <strong>to</strong> the database<br />

in the development envir<strong>on</strong>ment.<br />

Provide Support Documentati<strong>on</strong><br />

Provide support documentati<strong>on</strong> <str<strong>on</strong>g>for</str<strong>on</strong>g> each script. Comment the code <strong>to</strong> describe what is<br />

happening in the script and include any observati<strong>on</strong>s gathered when it was last executed,<br />

such as how l<strong>on</strong>g executi<strong>on</strong> <strong>to</strong>ok and how many rows were affected.<br />

Protect the Scripts<br />

Protecting the scripts is very important <str<strong>on</strong>g>for</str<strong>on</strong>g> the database implementati<strong>on</strong>. Treat the scripts<br />

like producti<strong>on</strong> objects at this point. To ensure that the appropriate scripts are used when<br />

the database is promoted between development, staging, and producti<strong>on</strong> envir<strong>on</strong>ments,


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 85<br />

keep the scripts in a secured direc<strong>to</strong>ry or under versi<strong>on</strong> c<strong>on</strong>trol. Versi<strong>on</strong>ing is very<br />

important because an <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> migrati<strong>on</strong> is not a mere mapping of objects<br />

from <strong>on</strong>e database <strong>to</strong> another. The differences between <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong> will<br />

require that some of the <strong>SQL</strong> statements be rewritten <str<strong>on</strong>g>for</str<strong>on</strong>g> the new envir<strong>on</strong>ment. These<br />

changes in <strong>SQL</strong> will also prompt changes <strong>to</strong> the database objects and their design.<br />

These changes will be driven by the applicati<strong>on</strong> development (migrati<strong>on</strong>) process and not<br />

from within the database migrati<strong>on</strong> process described here. Only the development and<br />

deployment teams should have access <strong>to</strong> the scripts.<br />

Migrate the Schema<br />

This secti<strong>on</strong> discusses the necessary steps in migrating the schema owner and setting<br />

up the s<strong>to</strong>rage in preparati<strong>on</strong> <str<strong>on</strong>g>for</str<strong>on</strong>g> migrating the schema objects and its data.<br />

The high-level steps <str<strong>on</strong>g>for</str<strong>on</strong>g> migrating the s<strong>to</strong>rage architecture of a schema are:<br />

1. Map the s<strong>to</strong>rage architecture.<br />

2. Create a database <str<strong>on</strong>g>for</str<strong>on</strong>g> the schema.<br />

3. Create filegroups <str<strong>on</strong>g>for</str<strong>on</strong>g> the tablespaces.<br />

4. Add datafiles <strong>to</strong> filegroups.<br />

Each of these four high-level steps is discussed in detail under the following<br />

subheadings.<br />

Map the S<strong>to</strong>rage Architecture<br />

The first step in migrating an <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> schema is <strong>to</strong> understand the s<strong>to</strong>rage architecture<br />

and how these architectural comp<strong>on</strong>ents will map <strong>to</strong> their equivalents in <strong>SQL</strong> <strong>Server</strong>.<br />

In<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <strong>on</strong> the various characteristics of the tablespaces and datafiles in which the<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> schema is s<strong>to</strong>red has <strong>to</strong> be gathered.<br />

There are several <strong>to</strong>ols, both from <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> as well as third parties, which are used in<br />

administering <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> databases. Any of these <strong>to</strong>ols can be employed <strong>to</strong> gather<br />

in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <strong>on</strong> the tablespaces and datafiles. In the example migrati<strong>on</strong> that is provided at<br />

the end of this secti<strong>on</strong>, methods <str<strong>on</strong>g>for</str<strong>on</strong>g> capturing the requisite data purely using <strong>SQL</strong> are<br />

provided.


86<br />

Developing: Databases — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> Schemas<br />

Figures 6.1 and 6.2 provide a view of how the s<strong>to</strong>rage objects will align in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and<br />

<strong>SQL</strong> <strong>Server</strong>.<br />

Figure 6.1<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> schema illustrated<br />

Figure 6.2<br />

<strong>SQL</strong> <strong>Server</strong> schema equivalent


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 87<br />

Start by compiling a list of tablespaces that c<strong>on</strong>tain objects bel<strong>on</strong>ging <strong>to</strong> the schema and<br />

gather the following related in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong>:<br />

● Tablespace name.<br />

● Status. The status of an <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> tablespace may be either ONLINE, OFFLINE, or<br />

READ ONLY. If a tablespace is OFFLINE, then a decisi<strong>on</strong> has <strong>to</strong> be made if it is<br />

required <strong>to</strong> be migrated. Data in an offline tablespace cannot be accessed and it<br />

has <strong>to</strong> be brought <strong>on</strong>line <str<strong>on</strong>g>for</str<strong>on</strong>g> migrati<strong>on</strong>.<br />

● Tablespace c<strong>on</strong>tents. Only tablespaces whose tablespace c<strong>on</strong>tent attribute is set<br />

<strong>to</strong> PERMANENT have <strong>to</strong> be migrated.<br />

● Logging attribute. Tablespaces may be set <strong>to</strong> LOGGING or NOLOGGING, which<br />

specifies the default characteristic <str<strong>on</strong>g>for</str<strong>on</strong>g> bulk operati<strong>on</strong>s against the objects in the<br />

tablespace.<br />

Note In <strong>SQL</strong> <strong>Server</strong>, the attributes of status, tablespace c<strong>on</strong>tents, and logging are set<br />

at the database level and not the filegroup level. If an <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> schema has tablespaces<br />

with more than <strong>on</strong>e value <str<strong>on</strong>g>for</str<strong>on</strong>g> these attributes, more than <strong>on</strong>e database will have <strong>to</strong> be<br />

created in <strong>SQL</strong> <strong>Server</strong>. For example, if a schema uses two tablespaces (<strong>on</strong>e is<br />

ONLINE and the other READ ONLY), then the two tablespaces have <strong>to</strong> be mapped <strong>to</strong><br />

two separate databases in <strong>SQL</strong> <strong>Server</strong>. The two databases can then be set <strong>to</strong> ONLINE<br />

and READ_ONLY, respectively, using the state opti<strong>on</strong>s available in <strong>SQL</strong> <strong>Server</strong>.<br />

Gather the following in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <str<strong>on</strong>g>for</str<strong>on</strong>g> each of the datafiles in the tablespaces:<br />

● File name<br />

● File size<br />

● File au<strong>to</strong>extensibility<br />

● Maximum file size<br />

● File au<strong>to</strong> extensi<strong>on</strong> increment<br />

From the in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> gathered about tablespaces and their datafiles, produce a map <str<strong>on</strong>g>for</str<strong>on</strong>g><br />

the databases, filegroups. and datafiles <strong>to</strong> be created in <strong>SQL</strong> <strong>Server</strong> as shown in Figure<br />

6.2.<br />

Create Databases <str<strong>on</strong>g>for</str<strong>on</strong>g> the Schema<br />

To migrate the schemas from <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>, databases are created in <strong>SQL</strong> <strong>Server</strong> <str<strong>on</strong>g>for</str<strong>on</strong>g> the<br />

schemas. The databases will hold the schema objects and their data. This secti<strong>on</strong><br />

provides details <strong>on</strong> how <strong>to</strong> create databases in <strong>SQL</strong> <strong>Server</strong>.<br />

To an <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> DBA, creating a database means creating an entire database system that<br />

c<strong>on</strong>tains c<strong>on</strong>trol files, redo logs, data dicti<strong>on</strong>ary and temporary tablespace. In<br />

<strong>SQL</strong> <strong>Server</strong>, these tasks are accomplished as part of the installati<strong>on</strong> process. Hence<br />

creating a database in <strong>SQL</strong> <strong>Server</strong> implies adding a user database <strong>to</strong> the already existing<br />

system databases. Members of the fixed server roles sysadmin and dbcrea<strong>to</strong>r, or any<br />

user with such privileges, can create a database. By default, the crea<strong>to</strong>r of the database<br />

becomes the owner of the database.<br />

Databases can be created either through Enterprise Manager or by using the CREATE<br />

DATABASE T-<strong>SQL</strong> command. Only members of the sysadmin and dbcrea<strong>to</strong>r fixed<br />

server roles or users who have been granted the CREATE DATABASE permissi<strong>on</strong> can<br />

create a new database.<br />

The following basic characteristics of the database have <strong>to</strong> be decided be<str<strong>on</strong>g>for</str<strong>on</strong>g>e creating a<br />

database:


88<br />

Developing: Databases — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> Schemas<br />

●<br />

●<br />

●<br />

●<br />

●<br />

●<br />

Database name. Naming is c<strong>on</strong>strained by the same rules as identifiers. A<br />

meaningful name can be used and need not be the same as the name of the<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> schema being migrated.<br />

Database owner. By default, the user who created the database becomes the<br />

database owner (dbo). The owner can be changed using sp_changedbowner. To<br />

mimic the <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> schema, a login with the same name as the schema can be<br />

made the database owner. A more detailed account of the implicati<strong>on</strong>s of database<br />

owner and database object owner is provided in the "Qualifiers and Name<br />

Resoluti<strong>on</strong>" secti<strong>on</strong> later in this chapter.<br />

Filegroups. These are the equivalents of tablespaces. A default primary filegroup<br />

is created during the database creati<strong>on</strong>.<br />

Primary file. Every database is created with a default primary file bel<strong>on</strong>ging <strong>to</strong> the<br />

default primary filegroup identifiable by the .mdf file name extensi<strong>on</strong>. The primary<br />

file c<strong>on</strong>tains startup in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <str<strong>on</strong>g>for</str<strong>on</strong>g> the database and is used <strong>to</strong> s<strong>to</strong>re user data just<br />

as any other datafile. Only the size and growth characteristics can be changed.<br />

Sec<strong>on</strong>dary files. Additi<strong>on</strong>al files can be created in a database and associated with<br />

the primary file group or any additi<strong>on</strong>al filegroup. The recommended file name<br />

extensi<strong>on</strong> <str<strong>on</strong>g>for</str<strong>on</strong>g> sec<strong>on</strong>dary files is .ndf.<br />

Transacti<strong>on</strong> log. Hold rollback and redo in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> required <strong>to</strong> recover the<br />

database. Notice that, unlike <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>, where rollback segments and redo logs are<br />

central <strong>to</strong> the instance, every database has at least <strong>on</strong>e transacti<strong>on</strong> log.<br />

Transacti<strong>on</strong> logs are not part of any filegroup.<br />

There are two ways <strong>to</strong> create a new database using Enterprise Manager: using the<br />

Database Properties dialog and by using the Create Database Wizard. An example of<br />

each of these procedures is provided here.<br />

To create a database using the Database Properties dialog, follow these<br />

steps:<br />

1. Right-click Databases, and then left-click New Database, or right-click <strong>Server</strong><br />

(<strong>Server</strong> Name\Instance Name), then right-click New, and then left-click Database.<br />

2. In the Database Properties window, enter the database name in the General<br />

pane, the datafile and filegroup c<strong>on</strong>figurati<strong>on</strong> in the Data Files pane, and the<br />

transacti<strong>on</strong> log c<strong>on</strong>figurati<strong>on</strong> in the Transacti<strong>on</strong> Log pane.<br />

To create a new database using the Create Database Wizard, follow these<br />

steps:<br />

1. Expand a server group, and then expand the server in which <strong>to</strong> create a database.<br />

2. On the Tools menu, click Wizards.<br />

3. Expand Database.<br />

4. Double-click Create Database Wizard.<br />

5. Complete the steps in the wizard.<br />

<strong>SQL</strong> <strong>Server</strong> also offers the CREATE DATABASE statement <str<strong>on</strong>g>for</str<strong>on</strong>g> creating databases.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 89<br />

To create a database using the T-<strong>SQL</strong> CREATE DATABASE statement, use the<br />

following syntax:<br />

CREATE DATABASE database_name<br />

[ ON<br />

]<br />

[ < filespec > [ ,...n ] ]<br />

[ , < filegroup > [ ,...n ] ]<br />

[ LOG ON { < filespec > [ ,...n ] } ]<br />

[ COLLATE collati<strong>on</strong>_name ]<br />

[ FOR LOAD | FOR ATTACH ]<br />

< filespec > ::=<br />

[ PRIMARY ]<br />

( [ NAME = logical_file_name , ]<br />

FILENAME = 'os_file_name'<br />

[ , SIZE = size ]<br />

[ , MAXSIZE = { max_size | UNLIMITED } ]<br />

[ , FILEGROWTH = growth_increment ] ) [ ,...n ]<br />

< filegroup > ::=<br />

FILEGROUP filegroup_name < filespec > [ ,...n ]<br />

C<strong>on</strong>figure the Databases<br />

<strong>SQL</strong> <strong>Server</strong> is very similar <strong>to</strong> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> in its architecture and can be similarly c<strong>on</strong>figured. In<br />

the discussi<strong>on</strong> of system c<strong>on</strong>figurati<strong>on</strong> opti<strong>on</strong>s, several opti<strong>on</strong>s that apply <strong>to</strong> the individual<br />

databases but are set at the instance level are discussed. These opti<strong>on</strong>s apply uni<str<strong>on</strong>g>for</str<strong>on</strong>g>mly<br />

<strong>to</strong> all databases in the instance. In c<strong>on</strong>trast, the following five different sets of opti<strong>on</strong>s are<br />

set at the database level and apply <strong>on</strong>ly <strong>to</strong> the targeted database.<br />

● Au<strong>to</strong> opti<strong>on</strong>s<br />

● Cursor opti<strong>on</strong>s<br />

● Recovery opti<strong>on</strong>s<br />

● <strong>SQL</strong> opti<strong>on</strong>s<br />

● State opti<strong>on</strong>s<br />

These opti<strong>on</strong>s are set using the ALTER DATABASE statement. A subset of the available<br />

opti<strong>on</strong>s can be set using Enterprise Manager. For a descripti<strong>on</strong> of each of these opti<strong>on</strong>s,<br />

refer <strong>to</strong> http://msdn.microsoft.com/library/default.asp?url=/library/enus/createdb/cm_8_des_03_6ohf.asp.<br />

If the source <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> database is in NOARCHIVELOG mode, then the Simple Recovery<br />

model is chosen <str<strong>on</strong>g>for</str<strong>on</strong>g> the database and the Full Recovery model is used if the <str<strong>on</strong>g>Oracle</str<strong>on</strong>g><br />

database is in ARCHIVELOG mode. If the <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> tablespace is in read-<strong>on</strong>ly mode, then<br />

the corresp<strong>on</strong>ding database created in <strong>SQL</strong> <strong>Server</strong> <str<strong>on</strong>g>for</str<strong>on</strong>g> that database has <strong>to</strong> be set <strong>to</strong><br />

read-<strong>on</strong>ly mode. Similarly, if the <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> tablespace is offline, the corresp<strong>on</strong>ding database<br />

can be taken offline after the migrati<strong>on</strong> is complete. If logging has been turned off <str<strong>on</strong>g>for</str<strong>on</strong>g> the<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> tablespace, then set the recovery model <str<strong>on</strong>g>for</str<strong>on</strong>g> the database <strong>to</strong> BULK_LOGGED.<br />

An overview of the <strong>SQL</strong> <strong>Server</strong> recovery models is available at<br />

http://msdn.microsoft.com/library/default.asp?url=/library/enus/dnsqlmag2k/html/dbRecovery.asp.


90<br />

Developing: Databases — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> Schemas<br />

Create Filegroups <str<strong>on</strong>g>for</str<strong>on</strong>g> the Tablespaces<br />

Filegroups in <strong>SQL</strong> <strong>Server</strong> are similar <strong>to</strong> tablespaces in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>. They are used <strong>to</strong> logically<br />

group s<strong>to</strong>rage. When a database is created in <strong>SQL</strong> <strong>Server</strong>, it has <strong>on</strong>e filegroup by<br />

default. Based <strong>on</strong> the number of tablespaces that the schema uses, additi<strong>on</strong>al filegroups<br />

have <strong>to</strong> be created in the newly created database.<br />

Every database is created with a default primary filegroup that cannot be renamed or<br />

dropped. As a result, <strong>on</strong>e of the tablespaces will have <strong>to</strong> map <strong>to</strong> the primary filegroup<br />

during migrati<strong>on</strong>. Additi<strong>on</strong>al sec<strong>on</strong>dary or user filegroups can be created with userspecified<br />

names.<br />

In <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>, tablespaces are created as locally managed or dicti<strong>on</strong>ary managed. The type<br />

of tablespace determines what s<strong>to</strong>rage parameters can be used. Creating filegroups is<br />

similar <strong>to</strong> creating tablespaces under <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> except that a filegroup is added <strong>to</strong> a specific<br />

<strong>SQL</strong> <strong>Server</strong> database. Filegroups added <strong>to</strong> a database are called sec<strong>on</strong>dary filegroups,<br />

and they can be added <strong>to</strong> any database. Datafiles are added separately from the<br />

definiti<strong>on</strong> of a filegroup.<br />

The following two opti<strong>on</strong>s are available <str<strong>on</strong>g>for</str<strong>on</strong>g> creating a filegroup.<br />

To create a filegroup using Enterprise Manager, follow these steps:<br />

1. Expand Databases and right-click Properties of the database <strong>to</strong> which the<br />

filegroup has <strong>to</strong> be added.<br />

2. In the Database Properties window, left-click the Filegroups pane.<br />

3. Type the filegroup name in the next available empty line that follows the filegroup<br />

listing.<br />

To add a filegroup <strong>to</strong> a database using T-<strong>SQL</strong>, execute the following<br />

statement:<br />

ALTER DATABASE database_name<br />

ADD FILEGROUP filegroup_name<br />

Add Datafiles <strong>to</strong> Filegroups<br />

S<strong>to</strong>rage has <strong>to</strong> be allocated in the <strong>SQL</strong> <strong>Server</strong> database <strong>to</strong> meet the requirements of the<br />

schema being migrated. Datafiles are added <strong>to</strong> filegroups much as datafiles are added <strong>to</strong><br />

tablespaces in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>.<br />

Adding a datafile in <strong>SQL</strong> <strong>Server</strong> is similar <strong>to</strong> the process used in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>. The<br />

characteristics that can be set are related <strong>to</strong> au<strong>to</strong>-growth and are similar in functi<strong>on</strong> <strong>to</strong><br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g>'s AUTOEXTEND feature. An additi<strong>on</strong>al characteristic that does not exist in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g><br />

is the logical file name.<br />

Datafiles can be added <strong>to</strong> the primary filegroup as well as any sec<strong>on</strong>dary filegroups either<br />

through Enterprise Manager or using T-<strong>SQL</strong>.<br />

To add a datafile by using Enterprise Manager, follow these steps:<br />

1. Expand Databases and right-click Properties of the database <strong>to</strong> which the<br />

filegroup has <strong>to</strong> be added.<br />

2. In the Database Properties window, left-click the Data Files pane.<br />

3. Add file in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> in the next available empty line in the file listing. In the filegroup<br />

column, select the filegroup name from the drop-down list. Also set the growth<br />

characteristics <str<strong>on</strong>g>for</str<strong>on</strong>g> the file.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 91<br />

To add a datafile <strong>to</strong> the primary filegroup or sec<strong>on</strong>dary filegroups using T-<br />

<strong>SQL</strong>, use the following syntax:<br />

ALTER DATABASE database<br />

{ ADD FILE < filespec > [ ,...n ] [ TO FILEGROUP filegroup_name ]<br />

where ::=<br />

( NAME = logical_file_name<br />

[ , FILENAME = 'os_file_name' ]<br />

[ , SIZE = size ]<br />

[ , MAXSIZE = { max_size | UNLIMITED } ]<br />

[ , FILEGROWTH = growth_increment ] )<br />

The TO FILEGROUP clause is not required <strong>to</strong> add datafiles <strong>to</strong> the primary filegroup.<br />

Add Transacti<strong>on</strong> Logs<br />

In <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>, in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <strong>on</strong> transacti<strong>on</strong>s and the changes they make is recorded in redo<br />

logs. The redo logs are comm<strong>on</strong> <strong>to</strong> the entire instance. In <strong>SQL</strong> <strong>Server</strong>, transacti<strong>on</strong>al<br />

changes are logged in the transacti<strong>on</strong> log <str<strong>on</strong>g>for</str<strong>on</strong>g> the database whose objects are involved in<br />

the transacti<strong>on</strong>. A database is created with a single default transacti<strong>on</strong> log. The default<br />

transacti<strong>on</strong> log has <strong>to</strong> be sized or new <strong>on</strong>es added based <strong>on</strong> the update activity against<br />

the database.<br />

Transacti<strong>on</strong> logs can be added using a process similar <strong>to</strong> that used <str<strong>on</strong>g>for</str<strong>on</strong>g> adding datafiles,<br />

as shown in the following procedure.<br />

To add a datafile by using Enterprise Manager, follow these steps:<br />

1. Expand Databases and right-click Properties of the database <strong>to</strong> which the<br />

transacti<strong>on</strong> log has <strong>to</strong> be added.<br />

2. In the Database Properties window, left-click the Transacti<strong>on</strong> Log pane.<br />

3. Add the transacti<strong>on</strong> log file in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> in the next available empty line in the file<br />

listing. Also set the growth characteristics.<br />

To add a transacti<strong>on</strong> log <strong>to</strong> a database using T-<strong>SQL</strong>, use the following syntax:<br />

ALTER DATABASE database<br />

{ ADD LOG FILE < filespec > [ ,...n ]<br />

where ::=<br />

( NAME = logical_file_name<br />

[ , FILENAME = 'os_file_name' ]<br />

[ , SIZE = size ]<br />

[ , MAXSIZE = { max_size | UNLIMITED } ]<br />

[ , FILEGROWTH = growth_increment ] )<br />

Sample Schema Migrati<strong>on</strong><br />

This secti<strong>on</strong> describes an example schema migrati<strong>on</strong> using the four steps that have been<br />

described earlier. The HR schema that is bundled with the <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> installati<strong>on</strong> software is<br />

used <strong>to</strong> illustrate the steps in migrating a schema. The s<strong>to</strong>rage characteristics of the<br />

tablespaces used by the HR schema have been modified <strong>to</strong> dem<strong>on</strong>strate some of the


92<br />

Developing: Databases — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> Schemas<br />

steps that would be comm<strong>on</strong> in migrati<strong>on</strong>s. This example is c<strong>on</strong>ducted using the features<br />

and <strong>to</strong>ols offered by <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong> and no third-party <strong>to</strong>ol is employed.<br />

1. Extract the schema s<strong>to</strong>rage requirements by following these substeps:<br />

a. Produce a listing of tablespaces in which the schema has objects by using the<br />

following statement:<br />

SELECT DISTINCT tablespace_name "TABLESPACE NAME"<br />

FROM dba_segments<br />

WHERE owner = 'HR'<br />

The owner in the statement is the name of the schema <strong>to</strong> be migrated. The<br />

output is as follows:<br />

TABLESPACE NAME<br />

____________________________________________________________<br />

EXAMPLE<br />

INDX<br />

b. Obtain the characteristics of each of the tablespaces using the following<br />

statement:<br />

SELECT tablespace_name, status, c<strong>on</strong>tents, logging<br />

FROM dba_tablespaces<br />

WHERE tablespace_name IN (SELECT DISTINCT tablespace_name<br />

FROM dba_segments<br />

WHERE owner = 'HR')<br />

The owner in the statement is the name of the schema <strong>to</strong> be migrated. The<br />

output is as follows:<br />

TABLESPACE_NAME STATUS CONTENTS LOGGING<br />

_______________________________________________________<br />

EXAMPLE ONLINE PERMANENT LOGGING<br />

INDX ONLINE PERMANENT LOGGING<br />

c. Find the datafiles associated with the tablespaces using the following<br />

statement:<br />

SELECT tablespace_name "TS NAME",<br />

file_name "FILE NAME", bytes/1024/1024 "SIZE MB",<br />

au<strong>to</strong>extensible, maxbytes/1024/1024 "MAX SIZE MB",<br />

increment_by*8192/1024/1024 "INCR SIZE MB"<br />

FROM dba_data_files<br />

WHERE tablespace_name IN (SELECT DISTINCT tablespace_name<br />

FROM dba_segments<br />

WHERE owner = 'HR')<br />

The owner in the statement is the name of the schema <strong>to</strong> be migrated. The<br />

output is as follows:<br />

TS NAME FILE NAME SIZE AUTO MAX SZ INCR<br />

________________________________________________________________________<br />

EXAMPLE /u02/oradata/oracle92/example01.dbf 1000 YES 1000 100<br />

EXAMPLE /u02/oradata/oracle92/example02.dbf 100 YES 1000 100<br />

INDX /u03/oradata/oracle92/indx01.dbf 1000 YES 1000 50<br />

INDX /u03/oradata/oracle92/indx02.dbf 50 YES 1000 50<br />

Note The output has been re<str<strong>on</strong>g>for</str<strong>on</strong>g>matted <strong>to</strong> fit the page.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 93<br />

Figures 6.1 and 6.2 provide schematics <str<strong>on</strong>g>for</str<strong>on</strong>g> the hierarchical organizati<strong>on</strong> of<br />

s<strong>to</strong>rage in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong>. Terminologies such as schema, database,<br />

tablespace, filegroup, datafile and transacti<strong>on</strong> log are used here. These figures<br />

are modified in Figure 6.3 and Figure 6.4 <strong>to</strong> show instances <str<strong>on</strong>g>for</str<strong>on</strong>g> the<br />

terminologies based <strong>on</strong> the HR schema:<br />

Figure 6.3<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> s<strong>to</strong>rage map <str<strong>on</strong>g>for</str<strong>on</strong>g> sample HR schema<br />

Figure 6.4<br />

Equivalent <strong>SQL</strong> <strong>Server</strong> s<strong>to</strong>rage map <str<strong>on</strong>g>for</str<strong>on</strong>g> sample HR schema<br />

Note Instead of putting the HR_DATA files under the required PRIMARY<br />

filegroup, a separate HR_DATA filegroup can be created. This helps make the<br />

filegroup and datafiles correlati<strong>on</strong> easier.<br />

2. Create and c<strong>on</strong>figure a new database in the <strong>SQL</strong> <strong>Server</strong> instance <strong>to</strong> hold the<br />

schema objects.<br />

a. Create the database.


94<br />

Developing: Databases — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> Schemas<br />

Create the database with s<strong>to</strong>rage attributes selected using the in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong><br />

gathered in step 1. The locati<strong>on</strong> of the files is dependent <strong>on</strong> the file system of<br />

the target Windows® server <strong>on</strong> which <strong>SQL</strong> <strong>Server</strong> is installed.<br />

Create the database using the following commands:<br />

USE master<br />

GO<br />

CREATE DATABASE HRDATA<br />

ON PRIMARY<br />

( NAME='HRDATA_01',<br />

FILENAME='E:\mssql\Mssql$corp1\data\hr_data_01.mdf',<br />

SIZE=1000MB,<br />

FILEGROWTH=0)<br />

LOG ON<br />

( NAME='HRDATA_LOG_01',<br />

FILENAME='G: \mssql\Mssql$corp1\log\hr_log_01.ldf',<br />

SIZE=10MB,<br />

MAXSIZE=100MB,<br />

FILEGROWTH=10)<br />

GO<br />

All filegroups and files (data and transacti<strong>on</strong> log) can be added at the time of<br />

creati<strong>on</strong> of the database. The following is the syntax <str<strong>on</strong>g>for</str<strong>on</strong>g> doing this:<br />

USE master<br />

GO<br />

CREATE DATABASE HRDATA<br />

ON PRIMARY<br />

( NAME='HRDATA_01',<br />

FILENAME='E:\ mssql\Mssql$corp1\data\hr_data_01.mdf',<br />

SIZE=1000MB,<br />

FILEGROWTH=0),<br />

( NAME='HRDATA_ 02',<br />

FILENAME='E:\mssql\Mssql$corp1\data\hr_data_02.ndf',<br />

SIZE=100MB,<br />

MAXSIZE=1000MB,<br />

FILEGROWTH=100MB),<br />

FILEGROUP HR_INDX<br />

( NAME='HRINDX_01',<br />

FILENAME='F:\mssql\ Mssql$corp1\data\hr_indx_01.ndf',<br />

SIZE=1000MB,<br />

FILEGROWTH=0) ,<br />

( NAME='HRINDX_02',<br />

LOG ON<br />

FILENAME='F:\mssql\Mssql$corp1\data\hr_indx_02.ndf',<br />

SIZE=100MB,<br />

MAXSIZE=1000MB,<br />

FILEGROWTH=50MB)<br />

( NAME='HRDATA_LOG_01',<br />

FILENAME='G:\mssql\Mssql$corp1\log\hr_log_01.ldf',<br />

SIZE=10MB,<br />

MAXSIZE=100MB,


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 95<br />

b.<br />

GO<br />

FILEGROWTH=10)<br />

If the database is in ARCHIVELOG mode, then set the database <strong>to</strong> Simple<br />

Recovery model; if it is in NOARCHIVELOG mode, then set <strong>to</strong> Full Recovery<br />

model. If the tablespace corresp<strong>on</strong>ding <strong>to</strong> the database is in NOLOGGING<br />

mode, set the database <strong>to</strong> Bulk-Logged Recovery model. For more in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong><br />

<strong>on</strong> the recovery models available in <strong>SQL</strong> <strong>Server</strong>, refer <strong>to</strong><br />

http://msdn.microsoft.com/library/default.asp?url=/library/en-<br />

us/adminsql/ad_bkprst_4l83.asp<br />

If the tablespace is in read <strong>on</strong>ly or offline mode, set the database <strong>to</strong> the<br />

respective mode after migrati<strong>on</strong> of the schema and data is complete.<br />

In this example, <strong>on</strong>ly the required primary filegroup with a primary file and the<br />

transacti<strong>on</strong> log are created as part of the database creati<strong>on</strong>, and additi<strong>on</strong>al<br />

filegroups and files are added in subsequent steps <strong>to</strong> enable dem<strong>on</strong>strati<strong>on</strong> of<br />

functi<strong>on</strong>s such as adding filegroups and data files.<br />

C<strong>on</strong>figure the database.<br />

The mode <str<strong>on</strong>g>for</str<strong>on</strong>g> the <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> database can be found using the following query:<br />

SELECT log_mode<br />

FROM v$database<br />

3. Add sec<strong>on</strong>dary filegroups.<br />

The HR_INDX filegroup can be added using the following commands:<br />

Use master<br />

GO<br />

ALTER DATABASE HRDATA<br />

ADD FILEGROUP HR_INDX<br />

GO<br />

4. Add sec<strong>on</strong>dary datafiles.<br />

The Filename, Current Size, Au<strong>to</strong>extensibility, Max Size, and Increment Size<br />

values retrieved from the <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> database are used in creating similar datafiles <str<strong>on</strong>g>for</str<strong>on</strong>g><br />

the HRDATA database. The primary file has already been created <strong>to</strong> match the<br />

first file in the HR_DATA tablespace.<br />

Create additi<strong>on</strong>al datafiles <str<strong>on</strong>g>for</str<strong>on</strong>g> the filegroups using the following commands:<br />

ALTER DATABASE HRDATA<br />

ADD FILE<br />

( NAME='HRDATA_02',<br />

FILENAME='E:\mssql\Mssql$corp1\data\hr_data_02.ndf',<br />

SIZE=100MB,<br />

MAXSIZE=1000MB,<br />

FILEGROWTH=100MB)<br />

GO<br />

ALTER DATABASE HRDATA<br />

ADD FILE<br />

( NAME='HRINDX_01',<br />

FILENAME='F:\mssql\Mssql$corp1\data\hr_indx_01.ndf',<br />

SIZE=1000MB,<br />

FILEGROWTH=0),<br />

( NAME='HRINDX_02',<br />

FILENAME='F:\mssql\Mssql$corp1\data\hr_indx_02.ndf',<br />

SIZE=100MB,


96<br />

Developing: Databases — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> Schemas<br />

MAXSIZE=1000MB,<br />

FILEGROWTH=50MB)<br />

TO FILEGROUP HR_INDX<br />

GO<br />

In this example, the focus was restricted <strong>to</strong> migrating a single schema. When migrating<br />

an entire database c<strong>on</strong>sisting of multiple schemas, the s<strong>to</strong>rage decisi<strong>on</strong>s will have <strong>to</strong> be<br />

made using the best practices in s<strong>to</strong>rage allocati<strong>on</strong> that were followed in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>. Place<br />

temporary files <strong>on</strong> separate devices, separate data and log files, separate data and index<br />

files, distribute I/O load across all available decisi<strong>on</strong>s, and separate tables with high<br />

activity <strong>on</strong><strong>to</strong> separate devices.<br />

For descripti<strong>on</strong>s of best practices <str<strong>on</strong>g>for</str<strong>on</strong>g> the s<strong>to</strong>rage comp<strong>on</strong>ent of <strong>SQL</strong> <strong>Server</strong>, refer <strong>to</strong> the<br />

secti<strong>on</strong> titled "Optimizing the S<strong>to</strong>rage Comp<strong>on</strong>ent" at<br />

http://www.microsoft.com/resources/documentati<strong>on</strong>/sql/2000/all/reskit/enus/part10/c3361.mspx.<br />

Multiple schemas comm<strong>on</strong>ly share tablespaces in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> databases. C<strong>on</strong>ceptually,<br />

<strong>SQL</strong> <strong>Server</strong> databases can be viewed more like <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> tablespaces, and objects from<br />

multiple schemas can be created in the same database. From this perspective,<br />

<strong>SQL</strong> <strong>Server</strong> databases functi<strong>on</strong> similarly <strong>to</strong> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> tablespaces. Figure 6.5 shows the<br />

relati<strong>on</strong> between schemas and tablespaces, where a schema's objects can be in multiple<br />

tablespaces and a tablespace can have objects from multiple schemas.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 97<br />

Figure 6.5<br />

Sharing of tablespaces/databases by multiple schemas/owners


98<br />

Developing: Databases — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> Schemas<br />

Migrate the Schema Objects<br />

In the "Migrate the Schema" secti<strong>on</strong> earlier in this chapter, the focus was limited <strong>to</strong> the<br />

schema and its s<strong>to</strong>rage structures. This focus culminated in creati<strong>on</strong> of databases with<br />

appropriate filegroups and datafiles. The database merely <str<strong>on</strong>g>for</str<strong>on</strong>g>ms the shell in which the<br />

schema objects will be enclosed. In this secti<strong>on</strong>, the following high-level steps in<br />

migrating the schema objects are taken. These steps cover tasks related <strong>to</strong> schema<br />

objects and security.<br />

1. Create the schema owner.<br />

2. Create the schema objects.<br />

These steps are discussed in detail under the following subheadings.<br />

Create the Schema Owner<br />

A schema owner in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> is a user with privileges <strong>to</strong> create objects. This is true in<br />

<strong>SQL</strong> <strong>Server</strong> as well. A user will have <strong>to</strong> be created in <strong>SQL</strong> <strong>Server</strong> in the database in<br />

which the schemas objects will be created. The user is then given privileges in the<br />

database <strong>to</strong> create objects and populate the data.<br />

Users of <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong> databases can be classified as administrative users,<br />

applicati<strong>on</strong> users, and schema owners.<br />

● Administrative users are users with special roles, such as database administra<strong>to</strong>r<br />

and security administra<strong>to</strong>r.<br />

● Applicati<strong>on</strong> users are users who manipulate data in the owning user's tables.<br />

● Schema owners are users who create and maintain objects related <strong>to</strong> an<br />

applicati<strong>on</strong>.<br />

The basics <str<strong>on</strong>g>for</str<strong>on</strong>g> the creati<strong>on</strong> of all the three types of users are the same and are discussed<br />

in detail here. This knowledge is useful in creating applicati<strong>on</strong> users and administrative<br />

users in Chapter 7, "Developing: Databases — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> the Database Users."<br />

A discussi<strong>on</strong> of user accounts <str<strong>on</strong>g>for</str<strong>on</strong>g> each of the categories of users is presented in the rest<br />

of this secti<strong>on</strong>. This discussi<strong>on</strong> covers the differences in the logins between <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and<br />

<strong>SQL</strong> <strong>Server</strong> and the associated authenticati<strong>on</strong> and password functi<strong>on</strong>ality.<br />

Accounts<br />

In terms of logins, all three types of users are created equal and are differentiated <strong>on</strong>ly by<br />

the privileges they are bes<strong>to</strong>wed. However, keeping with the practice of isolati<strong>on</strong> and<br />

aut<strong>on</strong>omy of user databases, logins are implemented a little differently in <strong>SQL</strong> <strong>Server</strong>. It<br />

is important <strong>to</strong> understand this difference be<str<strong>on</strong>g>for</str<strong>on</strong>g>e starting the migrati<strong>on</strong> of schemas and<br />

users. <strong>SQL</strong> <strong>Server</strong> has two levels (not types) of logins. In additi<strong>on</strong> <strong>to</strong> the instance login,<br />

<strong>SQL</strong> <strong>Server</strong> requires separate logins be created <str<strong>on</strong>g>for</str<strong>on</strong>g> each database that the user or<br />

schema needs <strong>to</strong> c<strong>on</strong>nect <strong>to</strong>.<br />

To avoid c<strong>on</strong>fusi<strong>on</strong> while referring <strong>to</strong> these various logins and accounts, this guide uses<br />

the following terminologies comm<strong>on</strong>ly employed <str<strong>on</strong>g>for</str<strong>on</strong>g> the various logins in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and<br />

<strong>SQL</strong> <strong>Server</strong>.<br />

● <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> — Instance Level — user or username<br />

● <strong>SQL</strong> <strong>Server</strong> — Instance Level — login (login ID)<br />

● <strong>SQL</strong> <strong>Server</strong> — Database Level — user


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 99<br />

Logins provide access <strong>to</strong> the instance of <strong>SQL</strong> <strong>Server</strong>, whereas the user account c<strong>on</strong>trols<br />

privileges <strong>to</strong> objects inside the database. Figure 6.6 illustrates these relati<strong>on</strong>ships.<br />

Figure 6.6<br />

Migrati<strong>on</strong> of schema owner security from <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong><br />

The migrati<strong>on</strong> of a schema owner from <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> requires a login be created<br />

at the instance level and a user be created at the database level. The impact of this<br />

architectural change is observed in how objects are qualified. In <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>, a schema object<br />

is identified in <strong>SQL</strong> statements using schema.object_name. While migrating <strong>to</strong><br />

<strong>SQL</strong> <strong>Server</strong> the schema object has <strong>to</strong> be fully qualified as database.owner.object_name.<br />

Even though there is no difference between the login aspects of the different types of<br />

users, <strong>on</strong>ly the schema owners and their migrati<strong>on</strong> are discussed here. A discussi<strong>on</strong> of<br />

applicati<strong>on</strong> users and administrative users is postp<strong>on</strong>ed <strong>to</strong> the next task of the database<br />

migrati<strong>on</strong>, migrating the user, which is discussed in Chapter 7, "Developing: Databases —<br />

<str<strong>on</strong>g>Migrating</str<strong>on</strong>g> the Database Users."<br />

Authenticati<strong>on</strong><br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> offers several opti<strong>on</strong>s <str<strong>on</strong>g>for</str<strong>on</strong>g> the authenticati<strong>on</strong> of users. The two popular methods in<br />

use are authenticati<strong>on</strong> by the database and authenticati<strong>on</strong> by the operating system. In<br />

<strong>SQL</strong> <strong>Server</strong>, the database mode is called <strong>SQL</strong> <strong>Server</strong> Authenticati<strong>on</strong> Mode and the<br />

operating system mode is called Windows Authenticati<strong>on</strong> Mode. The database<br />

authenticati<strong>on</strong> modes in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong> are closely compatible and use a user<br />

name and password pair. The operating system authenticati<strong>on</strong> is quite different between<br />

<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>'s operating system mode can <strong>on</strong>ly authenticate users<br />

with local accounts <strong>on</strong> <strong>UNIX</strong> servers. Windows authenticati<strong>on</strong> <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>SQL</strong> <strong>Server</strong> is actually<br />

per<str<strong>on</strong>g>for</str<strong>on</strong>g>med by the domain and not the local account <strong>on</strong> the Windows server.<br />

Password Management<br />

The <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> RDBMS also provides password management functi<strong>on</strong>s, such as account<br />

locking, password lifetime and expirati<strong>on</strong>, password his<strong>to</strong>ry, and password complexity<br />

verificati<strong>on</strong>. The <strong>SQL</strong> <strong>Server</strong> RDBMS does not provide these services, and Windows<br />

security is used <strong>to</strong> provide these features.<br />

Hence the migrati<strong>on</strong> of <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> user names <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> logins and users is dependent<br />

<strong>on</strong> the type of authenticati<strong>on</strong> in use as well as the requirements of password


100 Developing: Databases — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> Schemas<br />

management. Table 6.1 shows the migrati<strong>on</strong> opti<strong>on</strong>s <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> logins based <strong>on</strong><br />

authenticati<strong>on</strong> mode and the requirements <strong>on</strong> password management functi<strong>on</strong>ality.<br />

Table 6.1: Login Migrati<strong>on</strong> Based <strong>on</strong> Authenticati<strong>on</strong> Requirements<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Authenticati<strong>on</strong><br />

Mode<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Password<br />

Management<br />

Database N<strong>on</strong>e Database<br />

Database Required Windows<br />

Operating system N/A Windows<br />

<strong>SQL</strong> <strong>Server</strong><br />

Authenticati<strong>on</strong> Mode<br />

As a practice, the schema owner login should not be used <str<strong>on</strong>g>for</str<strong>on</strong>g> c<strong>on</strong>necti<strong>on</strong> by the<br />

applicati<strong>on</strong> instance (three-tier) or the applicati<strong>on</strong> users (two-tier and three-tier). Hence a<br />

<strong>SQL</strong> <strong>Server</strong> authenticated login would be appropriate. However, <str<strong>on</strong>g>for</str<strong>on</strong>g> clients who restrict<br />

authenticati<strong>on</strong> <strong>to</strong> Windows mode <strong>on</strong>ly because of security c<strong>on</strong>cerns, a domain login<br />

should be created <str<strong>on</strong>g>for</str<strong>on</strong>g> the schema owner.<br />

Based <strong>on</strong> the security model — either Windows users or groups — review the guidelines<br />

in th e "<strong>SQL</strong> <strong>Server</strong> 2000 SP3 Security Features and Best Practices" white paper<br />

available at<br />

http://www.microsoft.com/sql/techinfo/administrati<strong>on</strong>/2 000/security/securityWP.asp <strong>to</strong><br />

assist with implementati<strong>on</strong>.<br />

The following <strong>SQL</strong> statement can be used <strong>to</strong> extract the characteristics of the schema<br />

owner account in the <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> database:<br />

SELECT du.username,<br />

DECODE(du.password,'EXTERNAL','EXTERNAL','DB')<br />

"AUTHENTICATION MODE",<br />

du.default_tablespace, du.temporary_tablespace,<br />

dp.resource_name, dp.limit<br />

FROM dba_users du, dba_profiles dp<br />

WHERE du.profile = dp.profile<br />

AND dp.resource_type = 'PASSWORD'<br />

<strong>SQL</strong> <strong>Server</strong> does not have a CREATE USER statement. There are two system s<strong>to</strong>red<br />

procedures <strong>to</strong> add logins <str<strong>on</strong>g>for</str<strong>on</strong>g> the two modes of authenticati<strong>on</strong>, and a separate s<strong>to</strong>red<br />

procedure <strong>to</strong> add users at the database level.<br />

It is possible <strong>to</strong> add a new login <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>SQL</strong> <strong>Server</strong> using Enterprise Manager and system<br />

s<strong>to</strong>red procedures.<br />

T o add a new login <strong>to</strong> a <strong>SQL</strong> <strong>Server</strong> instance using Enterprise Manager:<br />

1. Expand the <strong>SQL</strong> <strong>Server</strong> Group and expand the <strong>Server</strong> (<strong>Server</strong> Name\Instance<br />

Name).<br />

2. Expand Security, right-click Logins, and then click New Login.<br />

3. Provide the login name and authenticati<strong>on</strong> method in the General pane. System<br />

and database level privileges can be granted through fixed roles under the <strong>Server</strong><br />

Roles pane. Object-level privileges can be granted either directly or through user<br />

roles in the Database Access pane.<br />

If the user is <strong>to</strong> be authenticated<br />

by the domain, the correct domain should be<br />

picked using the drop-down menu under Windows Authenticati<strong>on</strong> in the General<br />

pane. If domain authenticati<strong>on</strong> is used, the name of the login is in the <str<strong>on</strong>g>for</str<strong>on</strong>g>m Domain<br />

name\Domain login name. The default database that the user will c<strong>on</strong>nect <strong>to</strong> when<br />

c<strong>on</strong>necting <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> can be set under the Defaults heading in the General<br />

pane. This is different from the default tablespace setting <str<strong>on</strong>g>for</str<strong>on</strong>g> a user in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 101<br />

By checking the appropriate database, the new user can be granted privileges <strong>on</strong> specific<br />

databases in the <strong>SQL</strong> <strong>Server</strong> instance by checking the appropriate database in the<br />

Database Access pane. This acti<strong>on</strong> also creates user accounts of the same name in the<br />

respective databases. For a schema owner, the db_owner role has <strong>to</strong> be granted <str<strong>on</strong>g>for</str<strong>on</strong>g> the<br />

privilege of creating objects in the target database. The db_owner role has complete<br />

administrative authority over the database and can be c<strong>on</strong>sidered <strong>to</strong> be similar <strong>to</strong> the<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> dba role but restricted <strong>to</strong> a single <strong>SQL</strong> <strong>Server</strong> database. To give the <strong>SQL</strong> <strong>Server</strong><br />

database object owner equivalent of the resource role in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>, which grants DDL<br />

privileges, the database role db_ddladmin can be used. <strong>SQL</strong> <strong>Server</strong> also has the<br />

CREATE TABLE, CREATE TRIGGER, CREATE VIEW and CREATE PROCEDURE<br />

roles that can be used <strong>to</strong> further curtail the capabilities of the schema owner.<br />

To add a new Windows authenticated login <strong>to</strong> a <strong>SQL</strong> <strong>Server</strong> instance using T-<br />

<strong>SQL</strong>, use the following syntax:<br />

sp_grantlogin<br />

[ @loginame = ] 'login_name'<br />

where login_name is of the <str<strong>on</strong>g>for</str<strong>on</strong>g>m domain_name\domain_login_name<br />

To add a new database authenticated login <strong>to</strong> a <strong>SQL</strong> <strong>Server</strong> instance using T-<br />

<strong>SQL</strong>, use the following syntax:<br />

sp_addlogin [ @loginame = ] 'login_name'<br />

[ , [ @passwd = ] 'password' ]<br />

[ , [ @defdb = ] 'database_name' ]<br />

[ , [ @encryp<strong>to</strong>pt = ] 'encrypti<strong>on</strong>_opti<strong>on</strong>' ]<br />

where database_name specifies the database the login c<strong>on</strong>nects <strong>to</strong> after logging in<br />

(default database). While passwords are encrypted in <strong>SQL</strong> <strong>Server</strong> by default, the opti<strong>on</strong><br />

exists <strong>to</strong> skip encrypti<strong>on</strong> <strong>to</strong> allow cus<strong>to</strong>m password encrypti<strong>on</strong> by the applicati<strong>on</strong> using a<br />

different algorithm.<br />

A user account should be created separately <str<strong>on</strong>g>for</str<strong>on</strong>g> the login in the default database.<br />

To create a user account <strong>to</strong> a <strong>SQL</strong> <strong>Server</strong> database using T-<strong>SQL</strong>, use the<br />

following syntax:<br />

sp_grantdbaccess [ @loginame = ] 'login_name'<br />

[, [ @name_in_db = ] 'user_name'<br />

The name chosen <str<strong>on</strong>g>for</str<strong>on</strong>g> the user account can be different from that <str<strong>on</strong>g>for</str<strong>on</strong>g> the login account.<br />

Some of the other characteristics associated with a user or schema owner in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> that<br />

need <strong>to</strong> be addressed are:<br />

● De fault tablespace. In <strong>SQL</strong> <strong>Server</strong>, a default filegroup can be set <str<strong>on</strong>g>for</str<strong>on</strong>g> each<br />

da tabase which has the same functi<strong>on</strong> and effect as the <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> default tablespace<br />

using the following syntax.<br />

ALTER DATABASE database_name<br />

MODIFY FILEGROUP filegroup_name DEFAULT<br />

● Temporary tablespace. By default, all users of <strong>SQL</strong> <strong>Server</strong> use the tempdb<br />

database.<br />

● Tablespa ce quota. Quotas cannot be set in <strong>SQL</strong> <strong>Server</strong> at the instance,<br />

database, or filegroup<br />

level.


102 Developing: Databases — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> Schemas<br />

Create the Schema Objects<br />

This secti<strong>on</strong> discusses the migrati<strong>on</strong> of the schema objects from <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong>.<br />

The following is a complete list of objects that are classified by <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> as schema objects:<br />

●<br />

●<br />

●<br />

●<br />

●<br />

●<br />

●<br />

●<br />

●<br />

●<br />

●<br />

●<br />

●<br />

●<br />

●<br />

●<br />

Tables<br />

Clusters<br />

Object Tables<br />

Index-organized Tables<br />

C<strong>on</strong>straints<br />

Triggers<br />

Indexes<br />

Views<br />

Object Views<br />

Functi<strong>on</strong>s<br />

S<strong>to</strong>red Procedures<br />

Packages<br />

Syn<strong>on</strong>yms<br />

Sequences<br />

Database Links<br />

Object Types<br />

Table 6.2 provides a high-level view of how the <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> schema objects map <strong>to</strong><br />

<strong>SQL</strong> <strong>Server</strong>.<br />

Table 6.2: <strong>SQL</strong> <strong>Server</strong> Objects that Replace <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Schema Objects<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g><br />

Table<br />

Cluster<br />

Object Table<br />

Index-organized Table<br />

C<strong>on</strong>straints<br />

Triggers<br />

Index<br />

View<br />

Object View<br />

Syn<strong>on</strong>ym<br />

Sequence<br />

Database Link<br />

Object Types<br />

Procedure<br />

Functi<strong>on</strong><br />

Package<br />

<strong>SQL</strong> <strong>Server</strong><br />

Table<br />

Table<br />

Cluster<br />

Table (with clustered index)<br />

C<strong>on</strong>straints<br />

Triggers<br />

Index<br />

View<br />

N/A<br />

View<br />

Identity<br />

Linked <strong>Server</strong><br />

N/A<br />

S<strong>to</strong>red Procedure<br />

Functi<strong>on</strong><br />

S<strong>to</strong>red Procedure


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 103<br />

Some of these objects fall under broader classificati<strong>on</strong>s, such as tables and views. While<br />

the discussi<strong>on</strong> of some of the objects is bey<strong>on</strong>d the scope of this guide, the following are<br />

covered in this chapter:<br />

● Tables<br />

● Comments<br />

● C<strong>on</strong>straints<br />

● Triggers<br />

● Views<br />

● Indexes<br />

● S<strong>to</strong>red Programs, including functi<strong>on</strong>s, s<strong>to</strong>red procedures, and packages<br />

● Objects not found in <strong>SQL</strong> <strong>Server</strong>, including sequences, syn<strong>on</strong>yms, and database<br />

links<br />

The data definiti<strong>on</strong> language (DDL) <str<strong>on</strong>g>for</str<strong>on</strong>g> defining objects is in accord with ANSI <strong>SQL</strong><br />

standards. Because both <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong> maintain compliance with <strong>SQL</strong>-92 and<br />

<strong>SQL</strong>-99 standards, the syntax <str<strong>on</strong>g>for</str<strong>on</strong>g> defining objects is very similar.<br />

Identifiers and Naming<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> object and column names are generally not case-sensitive. However, no<br />

assumpti<strong>on</strong>s should be made because they can be <str<strong>on</strong>g>for</str<strong>on</strong>g>ced <strong>to</strong> be case sensitive by<br />

delimiting them (enclosing them) in double quotati<strong>on</strong> marks (“). For example, the name<br />

TRANSACTION_DATE can be made case sensitive by using “Transacti<strong>on</strong>_Date”. Also,<br />

quotes can be used <strong>to</strong> create irregular identifiers such as “Transacti<strong>on</strong> Date” (with a blank<br />

space). Similarly, object and column names in <strong>SQL</strong> <strong>Server</strong> are not case-sensitive by<br />

default, but this default behavior can be changed by modifying c<strong>on</strong>figurati<strong>on</strong> settings.<br />

N<strong>on</strong>standard or delimited identifiers can be created just as in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> using either<br />

quotati<strong>on</strong> marks (“) or brackets ([ ]). Read the "Using Identifiers" secti<strong>on</strong> in <strong>SQL</strong> <strong>Server</strong><br />

Books Online <str<strong>on</strong>g>for</str<strong>on</strong>g> rules about the c<strong>on</strong>structi<strong>on</strong> and use of regular and delimited identifiers.<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> table and column names are s<strong>to</strong>red in data dicti<strong>on</strong>ary tables as uppercase strings<br />

unless <str<strong>on</strong>g>for</str<strong>on</strong>g>ced <strong>to</strong> be case sensitive using delimiters. In c<strong>on</strong>trast, the default <strong>SQL</strong> <strong>Server</strong><br />

behavior is <strong>to</strong> s<strong>to</strong>re them in the case used when they were created. Because scripts <str<strong>on</strong>g>for</str<strong>on</strong>g><br />

use with <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> are written with such expectati<strong>on</strong>s, it is recommended you use<br />

uppercase identifiers while creating the objects in <strong>SQL</strong> <strong>Server</strong> (without <str<strong>on</strong>g>for</str<strong>on</strong>g>cing case by<br />

using delimiters).<br />

Qualifiers and Name Resoluti<strong>on</strong><br />

The names of objects are influenced by uniqueness requirements. <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> object names<br />

have <strong>to</strong> be unique <str<strong>on</strong>g>for</str<strong>on</strong>g> a schema. In <strong>SQL</strong> <strong>Server</strong>, the same owner can own objects of the<br />

same name in two different databases, that is, the combinati<strong>on</strong> of owner.table_name<br />

needs <strong>to</strong> be unique <strong>on</strong>ly within a database. Hence objects are qualified in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> as<br />

[schema.]object_name<br />

whereas in <strong>SQL</strong> <strong>Server</strong> the complete qualifier is<br />

[database.]owner.]object_name<br />

Rules have been established in both <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong> <str<strong>on</strong>g>for</str<strong>on</strong>g> resolving an<br />

object_name that is not qualified.<br />

In <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>, the resoluti<strong>on</strong> is governed by syn<strong>on</strong>yms and the c<strong>on</strong>cept of namespaces.<br />

Tables, views, snapshots, sequences, syn<strong>on</strong>yms, procedures, functi<strong>on</strong>s, and packages<br />

are in a single namespace. Triggers, indexes, and clusters each have their own individual


104 Developing: Databases — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> Schemas<br />

namespace. The following order is used <strong>to</strong> resolve an object that falls in the table<br />

namespace:<br />

1. Table namespace of current user's schema<br />

2. Private syn<strong>on</strong>ym in the current user's schema<br />

3. Public syn<strong>on</strong>ym<br />

The order is different in <strong>SQL</strong> <strong>Server</strong>, and resoluti<strong>on</strong> occurs as:<br />

1. Current user's schema in the current d atabase (set with USE statement)<br />

2. Database owner dbo of the current database<br />

These relati<strong>on</strong>ships h ave <strong>to</strong> be taken care of during the migrati<strong>on</strong> of the users and<br />

applicati<strong>on</strong> s. Because a user can own obj ects of the same name in multiple databases<br />

and different users can hav e objects of the same name in the same database, it is<br />

recommended that both database name and owner name be used <strong>to</strong> qualify objects in<br />

<strong>SQL</strong> <strong>Server</strong>.<br />

C hanging object identifiers <strong>to</strong> meet <strong>SQL</strong> <strong>Server</strong> standards can affect the applicati<strong>on</strong>s<br />

using them. However, changing the names of certain objects, such as indexes and<br />

c<strong>on</strong>straints, could be transparent <strong>to</strong> the business applicati<strong>on</strong>s. Given the rules <str<strong>on</strong>g>for</str<strong>on</strong>g> naming<br />

in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong>, there is no need <strong>to</strong> change the names of any of the identifiers.<br />

Note It is recommended that all objects in the migrated <strong>SQL</strong> <strong>Server</strong> database be<br />

qualified by database and owner because the rules <str<strong>on</strong>g>for</str<strong>on</strong>g> resolving names could<br />

otherwise lead <strong>to</strong> the wr<strong>on</strong>g object.<br />

Working with Data Types<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong> offer two types of data types: native data types and user defined<br />

data types. The data types that are provided by the DBMS are called native data types or<br />

system data types. There are four basic cl asses of data: character, numeric, datetime,<br />

and binary. In additi<strong>on</strong>, both <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong> have a few data types that are<br />

unique <strong>to</strong> each syste m. Tables 6.3 through 6.5 provide a complete mapping of <str<strong>on</strong>g>Oracle</str<strong>on</strong>g><br />

data types <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> data types that you should use when migrating.<br />

Care has been taken <strong>to</strong> suggest the closest possible data type both in terms of type of<br />

data being c<strong>on</strong>sidered as well as the scale or size of the data that has <strong>to</strong> be<br />

accommodated. A bad ch oice in data type can lead <strong>to</strong> a lot of problems during data<br />

m igrati<strong>on</strong>. The choice has <strong>to</strong> be driven by the definiti<strong>on</strong> in the source table and not by the<br />

data in the table. Even when data migrati<strong>on</strong> is successful, the applicati<strong>on</strong> may fail some<br />

time in the future because the table canno t handle data that it was originally designed <str<strong>on</strong>g>for</str<strong>on</strong>g>.<br />

<strong>SQL</strong> <strong>Server</strong> data types can com<str<strong>on</strong>g>for</str<strong>on</strong>g>tably provide a close equivalent of the <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> data<br />

types, and over sizing is not recommende d because it drives up the row size and the<br />

s<strong>to</strong>rage requirements and will affect per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance.<br />

Character or Alphanumeric Data<br />

Note that <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong> differ in the parameter used <strong>to</strong> define Char (Nchar),<br />

and Varchar (NVarchar) columns. For example, when CHAR(n) is used <strong>to</strong> specify a<br />

column data type in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>, n represents the number of characters, while in <strong>SQL</strong> <strong>Server</strong> it<br />

represents number of bytes.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 105<br />

Table 6.3 provides the <strong>SQL</strong> <strong>Server</strong> data types <strong>to</strong> use when migrating <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> character<br />

data.<br />

Table 6.3: <strong>SQL</strong> <strong>Server</strong> Equiv alent <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Character-based Data Types<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Data<br />

Type<br />

Max Size (Bytes)<br />

<strong>SQL</strong> <strong>Server</strong> Data<br />

Type<br />

Char 2000 Char 8000<br />

NChar 2000 NChar 4000<br />

Varchar 4000 Varchar 8000<br />

NVarchar 4000 NVarchar<br />

4000<br />

Varchar2 4000 Varchar2 8000<br />

NVarchar2 4000 NVarchar 4000<br />

LONG 2 31 Text 2 31 –1<br />

CLOB 2 32 Text 2 31 –1<br />

NCLOB 2 32 NText 2 30 –1<br />

Numeric Data<br />

Max Size (Bytes)<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> has <strong>on</strong>ly <strong>on</strong>e numeric data type, NUMBER, that can s<strong>to</strong>re zero, positive, negative,<br />

fixed, and floating point numbers, with a precisi<strong>on</strong> (p) of 38 digits and a scale (s) ranging<br />

from -84 <strong>to</strong> 127. Syn<strong>on</strong>yms, such as NUMERIC, DECIMAL, FLOAT, INTEGER, can be<br />

used. <strong>SQL</strong> <strong>Server</strong>, <strong>on</strong> the other hand, has eight distinct named numeric data types that<br />

c<strong>on</strong>strain the range of values they can hold. <strong>SQL</strong> <strong>Server</strong> also has three other data types<br />

that are of the number category: BIT, MONEY, and SMALLMONEY. Table 6.4 compares<br />

numeric data types in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong>.<br />

Table 6.4: Finding Closest <strong>SQL</strong> <strong>Server</strong> Equivalent <strong>to</strong> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Numeric Data Types<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g><br />

Number(19,0)<br />

Int or Number(10,0)<br />

SmallInt or Number(6,0)<br />

Number(3,0)<br />

Number(p,0)<br />

Float or DoublePrecisi<strong>on</strong> or Number(38)<br />

Real or Number(19) or Float(63)<br />

Number(19,4)<br />

Number(10,4)<br />

<strong>SQL</strong> <strong>Server</strong><br />

BigInt<br />

Int<br />

SmallInt<br />

TinyInt<br />

Decimal or Numeric(p,s)<br />

Float<br />

Real or Float(24)<br />

M<strong>on</strong>ey<br />

SmallM<strong>on</strong>ey<br />

Binary Data<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g>'s BLOB replaces the older RAW and LONG RAW data types. The IMAGE data<br />

type in <strong>SQL</strong> <strong>Server</strong> is the closest equivalent <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>’s BLOB data type, and it can<br />

support data up <strong>to</strong> 2 GB in size. The BINARY data type is a fixed size column while<br />

VARBINARY is its variable size counterpart. Table 6.5 provides <strong>SQL</strong> <strong>Server</strong> equivalents<br />

<str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> binary data types.


106 Developing: Databases — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> Schemas<br />

Table 6.5: <strong>SQL</strong> <strong>Server</strong> Equivalent <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Binary Data Types<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Data<br />

Type<br />

Max Size<br />

<strong>SQL</strong> <strong>Server</strong> Data<br />

Type<br />

BLOB 4 GB Image 2 GB<br />

Raw 2000 bytes Image 2 GB<br />

L<strong>on</strong>g Raw 2 GB Image 2 GB<br />

BFile 4 GB (file pointer) N/A<br />

Raw(n) 2000 bytes Binary(n) or<br />

VarBinary(n)<br />

Max Size<br />

8000 bytes<br />

For more in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> about designing <str<strong>on</strong>g>for</str<strong>on</strong>g> and implementing BLOBs in <strong>SQL</strong> <strong>Server</strong>, refer<br />

<strong>to</strong> http://www.microsoft.com/resources/documentati<strong>on</strong>/sql/2000/all/reskit/enus/part3/c1161.mspx.<br />

Date and Time<br />

His<strong>to</strong>rically, <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> has had <strong>on</strong>e data type, Date, which s<strong>to</strong>res both date and time<br />

in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong>. In <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> 9i, three new date and time data types have been added <strong>to</strong><br />

address these shortcomings. The Timestamp data type can s<strong>to</strong>re fracti<strong>on</strong>al sec<strong>on</strong>ds up<br />

<strong>to</strong> 9 digits of precisi<strong>on</strong>. Time z<strong>on</strong>e aware data types, Timestamp With Time Z<strong>on</strong>e and<br />

Timestamp with Local Time Z<strong>on</strong>e, are also available and they can handle daylight<br />

saving time.<br />

<strong>SQL</strong> <strong>Server</strong> has two data types: DateTime and SmallDateTime. DateTime can<br />

represent the date and time in the range January 1, 1753 <strong>to</strong> December 31, 9999 with a<br />

precisi<strong>on</strong> of <strong>on</strong>e-three hundredth of a sec<strong>on</strong>d. SmallDateTime can represent dates in the<br />

range January 1, 1900, through June 6, 2079 with a precisi<strong>on</strong> limited <strong>to</strong> the minute. The<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Date and Timestamp data types should be migrated <strong>to</strong> the DateTime data type.<br />

T he other two time z<strong>on</strong>e aware data types do not have an equivalent in <strong>SQL</strong> <strong>Server</strong>.<br />

User Defined Types<br />

A simple implementati<strong>on</strong> of user-defined data types is the capability <strong>to</strong> define data types<br />

as simple variati<strong>on</strong>s of the primitive data types. For example, defining a data type ZIP as<br />

a native type Char, with a length of 5, prov ides a uni<str<strong>on</strong>g>for</str<strong>on</strong>g>m definiti<strong>on</strong> that avoids any<br />

ambiguity between designers and developers.<br />

For example, the user-defined data type ZIP can be created as follows:<br />

CREATE TYPE zip_type AS OBJECT (zip char(5))<br />

/<br />

In <strong>SQL</strong> <strong>Server</strong>, the user-defined ZIP data type is:<br />

EXEC sp_addtype zip_type, 'char(5)'<br />

User-defined data types can be recursively used <strong>to</strong> define other user-defined data types.<br />

However, <strong>SQL</strong> <strong>Server</strong> does not support object types and their collecti<strong>on</strong>s.<br />

Tables<br />

The definiti<strong>on</strong> of the table data structure is the same, both in c<strong>on</strong>cept and <str<strong>on</strong>g>for</str<strong>on</strong>g>m, in both<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong>. This can be attributed <strong>to</strong> compliance with ANSI <strong>SQL</strong> standards.<br />

When designing the table data structure, data integrity is as important as data access. To<br />

serve these purposes, <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> provides several opti<strong>on</strong>s <str<strong>on</strong>g>for</str<strong>on</strong>g> how data can be organized<br />

within the table. Table 6.6 summarizes them:


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 107<br />

Table 6.6: <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong> Table Types Compared<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g><br />

Heap-Organized Table<br />

Clustered Table -<br />

Partiti<strong>on</strong>ed Table -<br />

Nested Table -<br />

Temporary Table<br />

External Table -<br />

Object Table -<br />

Index-Organized Table<br />

<strong>SQL</strong> <strong>Server</strong><br />

Heap<br />

Temporary Table<br />

Clustered Index<br />

The most comm<strong>on</strong> implementati<strong>on</strong> of the table object is, in its basic <str<strong>on</strong>g>for</str<strong>on</strong>g>m, the heap-<br />

is the focus of the remainder of this organized table, and this table object secti<strong>on</strong>.<br />

The CREATE TABLE syntax, which creates a simple heap organized table, has three<br />

major parts:<br />

● Table name<br />

● Body (enclosed in parenthesis) — column name, column properties (data type,<br />

defaults, inline column c<strong>on</strong>straints), out-of-line column c<strong>on</strong>straints, table<br />

c<strong>on</strong>straints<br />

● S<strong>to</strong>rage specificati<strong>on</strong><br />

Table 6.7 compares the structural compositi<strong>on</strong> of the CREATE TABLE syntax in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g><br />

and <strong>SQL</strong> <strong>Server</strong>.<br />

Table 6.7: High-level Comparis<strong>on</strong> of Table Definiti<strong>on</strong> Syntax<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g><br />

<strong>SQL</strong> <strong>Server</strong><br />

CREATE TABLE<br />

CREATE TABLE<br />

[schema.]table_name<br />

[[database.]owner.]table_name<br />

(<br />

column name<br />

column data type<br />

(<br />

column name<br />

column data type<br />

default expressi<strong>on</strong><br />

column c<strong>on</strong>straint, …<br />

defaults expressi<strong>on</strong><br />

column c<strong>on</strong>straint, …<br />

out of line or table c<strong>on</strong>straint<br />

out of line or table c<strong>on</strong>straint<br />

) )<br />

[s<strong>to</strong>rage_specificati<strong>on</strong>]<br />

[s<strong>to</strong>rage_specificati<strong>on</strong>]<br />

The steps <str<strong>on</strong>g>for</str<strong>on</strong>g> creating a table in <strong>SQL</strong> <strong>Server</strong> using both Enterprise Manager and T-<strong>SQL</strong><br />

are provided in the following procedures.<br />

To create a new table using Enterprise Manager, follow these steps:<br />

1. Expand <strong>Server</strong>, then Databases, and then the target database.<br />

2. Right-click Tables and select New Table. A new window appears <str<strong>on</strong>g>for</str<strong>on</strong>g> adding<br />

columns and other objects, such as indexes and c<strong>on</strong>straints related <strong>to</strong> the table.<br />

This window is called the Table Designer <strong>to</strong>ol.<br />

3. Add new columns in the <strong>to</strong>p grid (column definiti<strong>on</strong> grid) al<strong>on</strong>g with the column data<br />

type and nullability c<strong>on</strong>straint. Some of the column's properties, such as Default


108 Developing: Databases — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> Schemas<br />

Value, can be provided in the Columns pane at the bot<strong>to</strong>m. The Identity property<br />

is discussed in greater detail under the "Sequences" heading.<br />

4. Click the Table and Index Properties butt<strong>on</strong> found <strong>on</strong> the Columns window, or<br />

right-click anywhere in the column definiti<strong>on</strong> grid and select Properties <strong>to</strong> bring up<br />

the table Properties window, which can be used <strong>to</strong> specify table level properties,<br />

c<strong>on</strong>straints, and indexes.<br />

To create a new table using T-<strong>SQL</strong>, use the following syntax:<br />

CREATE TABLE<br />

[ database_name.[ owner ] . | owner. ] table_name<br />

( { < column_definiti<strong>on</strong> ><br />

| column_name AS computed_column_expressi<strong>on</strong><br />

| < table_c<strong>on</strong>straint > } [ ,...n ]<br />

)<br />

[ ON { filegroup | DEFAULT } ]<br />

[ TEXTIMAGE_ON { filegroup | DEFAULT } ]<br />

where < column_definiti<strong>on</strong> > ::= column_name data_type<br />

[ COLLATE < collati<strong>on</strong>_name > ]<br />

[ [ DEFAULT c<strong>on</strong>stant_expressi<strong>on</strong> ]<br />

The following list covers each of the comp<strong>on</strong>ents of the CREATE TABLE syntax:<br />

● Table and column name. As is the case in the "Identifiers and Naming" secti<strong>on</strong><br />

earlier in this chapter, <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> table and column names do not need any changes<br />

when migrated <strong>to</strong> <strong>SQL</strong> <strong>Server</strong>.<br />

● Column data type. The column data type <str<strong>on</strong>g>for</str<strong>on</strong>g>ms part of the table definiti<strong>on</strong> and is<br />

an integral part of creating a table. For the sake of reducing the complexity in the<br />

discussi<strong>on</strong> of tables (because there are several comp<strong>on</strong>ents <strong>to</strong> be dealt with here),<br />

the discussi<strong>on</strong> of data types has been covered in the secti<strong>on</strong> "Working with Data<br />

Types" earlier in this chapter.<br />

● Default value. The rules <str<strong>on</strong>g>for</str<strong>on</strong>g> specifying default value are very similar in both<br />

databases, and default values can be specified in most cases. One of the<br />

difficulties that may be encountered while migrating <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> is the lack of an<br />

equivalent <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> system functi<strong>on</strong> used <str<strong>on</strong>g>for</str<strong>on</strong>g> defining the default values. In<br />

<strong>SQL</strong> <strong>Server</strong>, a default value cannot be specified <str<strong>on</strong>g>for</str<strong>on</strong>g> a column of type timestamp.<br />

While <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> treats defaults as a property of the column, <strong>SQL</strong> <strong>Server</strong> defines<br />

defaults as a c<strong>on</strong>straint.<br />

● C<strong>on</strong>straints. A detailed discussi<strong>on</strong> of c<strong>on</strong>straints appears in the "C<strong>on</strong>straints"<br />

secti<strong>on</strong> later in this chapter.<br />

● S<strong>to</strong>rage properties. A detailed discussi<strong>on</strong> of the s<strong>to</strong>rage architecture appears in<br />

the "Migrate the S<strong>to</strong>rage Architecture" secti<strong>on</strong> in Chapter 5, Developing:<br />

Databases — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> the Database Architecture." The <strong>on</strong>ly s<strong>to</strong>rage property that<br />

can be specified during table creati<strong>on</strong> is the filegroup name. If a filegroup is not<br />

specified, then the table is created in the database's default filegroup.<br />

In the Tab le and Index Properties window, the Table Filegroup drop-down list<br />

can be used pick a filegroup from which the table will be allocated s<strong>to</strong>rage. The<br />

T ext Filegroup drop-down list can be used <strong>to</strong> specify the fi legroup <strong>to</strong> be used <str<strong>on</strong>g>for</str<strong>on</strong>g><br />

large objects, such as text and image<br />

columns.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 109<br />

Not e In <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong>, tables can be created based <strong>on</strong> the definiti<strong>on</strong> of other<br />

tables.<br />

In <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>, this is accomplished using the following statement<br />

CREATE TABLE table_name AS SELECT …<br />

The same can be achieved in <strong>SQL</strong> <strong>Server</strong> using the following syntax:<br />

SELECT … INTO table_name<br />

The various table types found in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> can be migrated as described in the following list.<br />

Detailed knowledge of each table type is not necessary <strong>to</strong> accomplish the migrati<strong>on</strong>.<br />

● Clustered table. Sometimes simply called clusters, these do not have an<br />

equivalent in <strong>SQL</strong> <strong>Server</strong>. The tables in the cluster have <strong>to</strong> be created as regular<br />

heaps. If rows are frequently accessed using a range search, a clustered index<br />

may be created <strong>on</strong> such column(s). Only <strong>on</strong>e clustered index can be created <strong>on</strong> a<br />

table.<br />

This migrati<strong>on</strong> of clustered tables in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>to</strong> heaps in <strong>SQL</strong> <strong>Server</strong> will be<br />

transparent <strong>to</strong> the applicati<strong>on</strong> and users.<br />

● Partiti<strong>on</strong>ed table. <strong>SQL</strong> <strong>Server</strong> does not have the partiti<strong>on</strong>ed table opti<strong>on</strong>.<br />

However, <strong>SQL</strong> <strong>Server</strong> offers partiti<strong>on</strong>ed views that are built using the same<br />

strategy that was used in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> (be<str<strong>on</strong>g>for</str<strong>on</strong>g>e <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> 8i) when true horiz<strong>on</strong>tal<br />

partiti<strong>on</strong>ing was not available. This involves creating separate tables <str<strong>on</strong>g>for</str<strong>on</strong>g> each of<br />

the partiti<strong>on</strong>s, with a check c<strong>on</strong>straint <strong>on</strong> the partiti<strong>on</strong> key column(s) <strong>to</strong> en<str<strong>on</strong>g>for</str<strong>on</strong>g>ce a<br />

range of values. A partiti<strong>on</strong>ed view is then created as a uni<strong>on</strong> of all the c<strong>on</strong>stituent<br />

tables. Details <strong>on</strong> the implementati<strong>on</strong> of partiti<strong>on</strong>ed views can be found under the<br />

<strong>to</strong>pic "Creating a Partiti<strong>on</strong>ed View" in <strong>SQL</strong> <strong>Server</strong> Books Online.<br />

This migrati<strong>on</strong> of partiti<strong>on</strong>ed tables in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>to</strong> heaps in <strong>SQL</strong> <strong>Server</strong> will be<br />

transparent <strong>to</strong> the applicati<strong>on</strong> and users.<br />

● Nested table. <strong>SQL</strong> <strong>Server</strong> does not support nested tables. The implementati<strong>on</strong><br />

strategy used in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> can be imitated in <strong>SQL</strong> <strong>Server</strong> <str<strong>on</strong>g>for</str<strong>on</strong>g> migrating them. The<br />

nested table column can be separated out in<strong>to</strong> its own table (denormalized with<br />

similar definiti<strong>on</strong>) with a unique identifier used <strong>to</strong> c<strong>on</strong>nect the rows from the parent<br />

table <strong>to</strong> the child table.<br />

● Minor modificati<strong>on</strong> <strong>to</strong> retrieve the data from the child table will be required in<br />

the code <strong>to</strong> accommodate this change.<br />

● Temporary table. <strong>SQL</strong> <strong>Server</strong> supports both local and global temporary tables.<br />

<strong>SQL</strong> <strong>Server</strong>'s local temporary table is equivalent <strong>to</strong> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>'<br />

s global temporary table<br />

( with the ON COMMIT PRESERVE ROWS ) because it provides the same level of<br />

isolati<strong>on</strong> from other sessi<strong>on</strong>s.<br />

Table 6.8 shows the syntax <str<strong>on</strong>g>for</str<strong>on</strong>g> creating temporary tables in <strong>SQL</strong> <strong>Server</strong>.<br />

Table 6.8: <strong>SQL</strong> Statements <str<strong>on</strong>g>for</str<strong>on</strong>g> Creating Temporary Tables in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and<br />

<strong>SQL</strong> <strong>Server</strong><br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g><br />

CREATE GLOBAL TEMPORARY TABLE<br />

table_name …<br />

ON COMMIT DELETE|PRESERVE ROWS<br />

<strong>SQL</strong> <strong>Server</strong><br />

CREATE TABLE<br />

# table_name<br />

Local temporary tables in <strong>SQL</strong> <strong>Server</strong> work identically <strong>to</strong> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> temporary tables<br />

and do not warrant any changes in the code. But the code pieces that assume that<br />

rows are deleted au<strong>to</strong>matically when working with tables with ON COMMIT


110 Developing: Databases — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> Schemas<br />

●<br />

●<br />

●<br />

●<br />

DELETE ROWS has <strong>to</strong> be modified <strong>to</strong> include a DELETE statement in<br />

compensati<strong>on</strong>.<br />

External table. <strong>SQL</strong> <strong>Server</strong> does not have the opti<strong>on</strong> <strong>to</strong> create tables whose data<br />

resides in flat files. Hence such data will have <strong>to</strong> be imported in<strong>to</strong> the database.<br />

Object table. <strong>SQL</strong> <strong>Server</strong> does not support objects. The strategy <str<strong>on</strong>g>for</str<strong>on</strong>g> migrating<br />

object tables <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> is <strong>to</strong> flatten (absorb) the object column in<strong>to</strong> the table<br />

itself. This will induce <strong>on</strong>ly a small change in the <strong>SQL</strong> code that accesses the data.<br />

Index-organized table. The <strong>SQL</strong> <strong>Server</strong> clustered indexes are very similar <strong>to</strong> the<br />

index-organized table (IOT), where the index is merged in<strong>to</strong> the table instead of<br />

two separate structures. Clustered indexes are implemented in a fashi<strong>on</strong> similar <strong>to</strong><br />

index-organized tables and have very similar features.<br />

Index-organized tables are sorted <strong>on</strong> the primary key. To migrate an indexorganized<br />

table <strong>to</strong> <strong>SQL</strong> <strong>Server</strong>, the CLUSTERED keyword can be used in<br />

c<strong>on</strong>juncti<strong>on</strong> with the PRIMARY KEY c<strong>on</strong>straint, as described in the syntax given in<br />

Table 6.9.<br />

In <strong>SQL</strong> <strong>Server</strong>, a clustered index can be created <strong>on</strong> any column(s) of a table, but it<br />

has <strong>to</strong> be created using the CREATE INDEX clause. If a clustered index is created<br />

with n<strong>on</strong>-unique columns, <strong>SQL</strong> <strong>Server</strong> en<str<strong>on</strong>g>for</str<strong>on</strong>g>ces uniqueness by adding an<br />

uniqueifier <strong>to</strong> the rows with duplicates.<br />

In most cases, the primary key would be the ideal column <str<strong>on</strong>g>for</str<strong>on</strong>g> a clustered index. An<br />

identity column can also be used <str<strong>on</strong>g>for</str<strong>on</strong>g> a clustered key. In <strong>SQL</strong> <strong>Server</strong>, it is<br />

recommended that every table should have a clustered index.<br />

Note Clustered indexes should be created be<str<strong>on</strong>g>for</str<strong>on</strong>g>e creating any n<strong>on</strong>clustered<br />

indexes. If clustered indexes are planned <str<strong>on</strong>g>for</str<strong>on</strong>g> a table, defer creati<strong>on</strong> of n<strong>on</strong>clustered<br />

indexes (as part of PRIMARY KEY or UNIQUE c<strong>on</strong>straint definiti<strong>on</strong>) during the<br />

table creati<strong>on</strong> in this step.<br />

Table 6.9 shows the <strong>SQL</strong> <strong>Server</strong> opti<strong>on</strong>s <str<strong>on</strong>g>for</str<strong>on</strong>g> creating the equivalent of an <str<strong>on</strong>g>Oracle</str<strong>on</strong>g><br />

index-organized table.<br />

Table 6.9: <strong>SQL</strong> Statements <str<strong>on</strong>g>for</str<strong>on</strong>g> Creating Index-organized Tables in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and<br />

<strong>SQL</strong> <strong>Server</strong><br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g><br />

CREATE TABLE table_name<br />

(<br />

column_name datatype,<br />

…<br />

)<br />

ORGANIZATION INDEX<br />

[ s<strong>to</strong>rage_definiti<strong>on</strong> ]<br />

<strong>SQL</strong> <strong>Server</strong><br />

CREATE TABLE table_name<br />

(<br />

column_name datatype,<br />

[ CONSTRAINT c<strong>on</strong>straint_name ]<br />

PRIMARY KEY CLUSTERED<br />

[ ON filegroup | DEFAULT ]<br />

)<br />

or<br />

CREATE [UNIQUE] CLUSTERED INDEX<br />

index_name<br />

ON table_name<br />

( column_name [, …] )<br />

[ ON filegroup | DEFAULT ]<br />

Migrati<strong>on</strong> of tables is complicated by the referential integrity (<str<strong>on</strong>g>for</str<strong>on</strong>g>eign key) c<strong>on</strong>straints<br />

between tables. There are two opti<strong>on</strong>s <str<strong>on</strong>g>for</str<strong>on</strong>g> how <strong>to</strong> migrate tables. Opti<strong>on</strong> <strong>on</strong>e is <strong>to</strong> create


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 111<br />

tables in a specific order based <strong>on</strong> the <str<strong>on</strong>g>for</str<strong>on</strong>g>eign key c<strong>on</strong>straints (parent tables first). Opti<strong>on</strong><br />

two is <strong>to</strong> create tables in any order, leaving out the <str<strong>on</strong>g>for</str<strong>on</strong>g>eign key c<strong>on</strong>straints, and adding<br />

them after all the tables have been created.<br />

Comments<br />

This is a property of the table that is often not documented and, hence, easily overlooked<br />

during a migrati<strong>on</strong>. <strong>SQL</strong> <strong>Server</strong> does not have a comment property associated with tables<br />

and columns. However, <strong>SQL</strong> <strong>Server</strong> provides the capability <strong>to</strong> associate cus<strong>to</strong>m<br />

properties, called extended properties, with objects.<br />

Comments can be added <strong>to</strong> tables and columns using Enterprise Manager and system<br />

s<strong>to</strong>red procedures.<br />

To add a comment <strong>on</strong> tables and columns using Enterprise Manager, follow<br />

these steps:<br />

1. Expand <strong>Server</strong>, then Databases, and then the target database.<br />

2. Left-click Tables <strong>to</strong> display the list of tables.<br />

3. Right-click the target table and left-click Design Table. This brings up the Table<br />

Designer.<br />

4. Comments <str<strong>on</strong>g>for</str<strong>on</strong>g> the individual columns can be added in the Descripti<strong>on</strong> field of the<br />

Columns pane at the bot<strong>to</strong>m of the Table Designer window.<br />

5. In the Table Designer window, click the Table and Index Properties butt<strong>on</strong> found<br />

above the grid.<br />

6. Left-click the Tables pane of the Properties window. Table comments can be<br />

added in the Descripti<strong>on</strong> field in the Tables pane.<br />

The sp_addextendedproperty system s<strong>to</strong>red procedure can be used <strong>to</strong> add any userdefined<br />

metadata <strong>to</strong> any column in <strong>SQL</strong> <strong>Server</strong>. This (and any other properties that are<br />

a dded <strong>to</strong> the column) can be retrieved with the fn_listextendedproperty functi<strong>on</strong>.<br />

Table 6.10 shows the syntax <str<strong>on</strong>g>for</str<strong>on</strong>g> adding comments at the table and column levels.<br />

Table 6.10: Comparis<strong>on</strong> of Functi<strong>on</strong>ality<br />

<str<strong>on</strong>g>for</str<strong>on</strong>g> Adding Comments in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and<br />

<strong>SQL</strong> <strong>Server</strong><br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g><br />

COMMENT ON TABLE table_name IS<br />

comment<br />

COMMENT ON COLUMN<br />

table_name.column_name IS comment<br />

<strong>SQL</strong> <strong>Server</strong><br />

sp_ addextendedproperty 'comment',<br />

comment,<br />

'user', schema_name, 'table',<br />

table_name<br />

sp_addextendedproperty 'comment',<br />

comment,<br />

'user', schema_name, 'table',<br />

table_name, 'column', column_name<br />

C<strong>on</strong>straints<br />

C<strong>on</strong>straints are data integrity rules that are defined <strong>on</strong> the columns of a table <strong>to</strong> en<str<strong>on</strong>g>for</str<strong>on</strong>g>ce<br />

certain business rules. As an example, the specificati<strong>on</strong> of data types in the definiti<strong>on</strong> of<br />

the column c<strong>on</strong>stitutes a c<strong>on</strong>straint.


112 Developing: Databases — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> Schemas<br />

Table 6.11 compares the availability of various types of c<strong>on</strong>straints in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and<br />

<strong>SQL</strong> <strong>Server</strong>:<br />

Table 6.11: C<strong>on</strong>straints Available in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong><br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g><br />

NOT NULL<br />

UNIQUE<br />

PRIMARY KEY<br />

FOREIGN KEY<br />

CHECK<br />

<strong>SQL</strong> <strong>Server</strong><br />

NOT NULL<br />

UNIQUE<br />

PRIMARY KEY<br />

FOREIGN KEY<br />

CHECK<br />

The functi<strong>on</strong>ality provided by <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong> <strong>to</strong> define c<strong>on</strong>straints <strong>on</strong> columns,<br />

including the syntactic use of inline (or column) c<strong>on</strong>straints and out-of-line (or table)<br />

c<strong>on</strong>straints, is almost identical. The syntax in Table 6.12 illustrates the similarity. Out-of-<br />

have <strong>to</strong> be used when more than <strong>on</strong>e column is involved in the definiti<strong>on</strong><br />

line c<strong>on</strong>straints<br />

of a c<strong>on</strong>straint. If a c<strong>on</strong>straint name is not specified using the CONSTRAINT clause, a<br />

default name is generated by the database. The default names given by <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> are of the<br />

<str<strong>on</strong>g>for</str<strong>on</strong>g>m SYS_Cn where n is a unique number generated by <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>. The names provided by<br />

<strong>SQL</strong> <strong>Server</strong> are more suggestive with respect <strong>to</strong> the type of c<strong>on</strong>straint (<str<strong>on</strong>g>for</str<strong>on</strong>g> example, CK,<br />

PK, and FK) and the table and column(s) involved. The syntax <str<strong>on</strong>g>for</str<strong>on</strong>g> the two opti<strong>on</strong>s <str<strong>on</strong>g>for</str<strong>on</strong>g><br />

defining c<strong>on</strong>straints in <strong>SQL</strong> <strong>Server</strong> is provided in Table 6.12.<br />

Table 6.12: T-<strong>SQL</strong> Statements <str<strong>on</strong>g>for</str<strong>on</strong>g> Defining Inline and Out-of-line C<strong>on</strong>straints in<br />

<strong>SQL</strong> <strong>Server</strong><br />

Inline (Column) C<strong>on</strong>straint<br />

CREATE TABLE table_name<br />

(column_name datatype<br />

[ CONSTRAINT c<strong>on</strong>straint_name ] [ [<br />

NOT ] NULL | UNIQUE | PRIMARY KEY |<br />

CHECK (c<strong>on</strong>diti<strong>on</strong>) | REFERENCES<br />

ref_table (ref_column) ]<br />

)<br />

Out-of-line (Table) C<strong>on</strong>straint<br />

CREATE TABLE table_name<br />

(column_name datatype,<br />

[ CONSTRAINT c<strong>on</strong>straint_name ] [<br />

UNIQUE (column_name [, ...]) |<br />

PRIMARY KEY (column_name [, ...]) |<br />

CHECK (c<strong>on</strong>diti<strong>on</strong>) | FOREIGN KEY<br />

(column_name [, ...]) REFERENCES<br />

ref_table (ref_column) ]<br />

)<br />

NOT NULL C<strong>on</strong>straint<br />

In both <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong>, the NOT NULL c<strong>on</strong>straint can be specified <strong>on</strong>ly as a<br />

column c<strong>on</strong>straint. More often than not, a c<strong>on</strong>straint name is not provided while creating<br />

NOT NULL c<strong>on</strong>straints.<br />

When a column has not been specifically defined as NOT NULL in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>, it defaults <strong>to</strong><br />

being nullable. When NULL or NOT NULL is not specified explicitly <str<strong>on</strong>g>for</str<strong>on</strong>g> a column<br />

definiti<strong>on</strong>, <strong>SQL</strong> <strong>Server</strong> uses the default of NOT NULL. For ANSI compatibility, setting the<br />

database opti<strong>on</strong> ANSI_NULL_DEFAULT <strong>to</strong> ON changes the database default <strong>to</strong> NULL. In<br />

<strong>SQL</strong> <strong>Server</strong>, database and sessi<strong>on</strong> settings can override the nullability specified by the<br />

column definiti<strong>on</strong>.<br />

Some DBAs like <strong>to</strong> use meaningful names <str<strong>on</strong>g>for</str<strong>on</strong>g> all c<strong>on</strong>straints so that errors referring <strong>to</strong><br />

c<strong>on</strong>s traint violati<strong>on</strong>s can be easily recognized in error messages. When migrating from<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g>, NOT NULL c<strong>on</strong>straints with user-defined<br />

names can be queried using the<br />

following syntax:


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 113<br />

CREATE TABLE NOT NULL CONSTRAINTS<br />

(c<strong>on</strong>straint_name varchar2(30),<br />

owner varchar2(30)<br />

table_name varchar2(30),<br />

column_name varchar2(30),<br />

search_c<strong>on</strong>diti<strong>on</strong> clob);<br />

INSERT INTO NOT NULL CONSTRAINTS<br />

SELECT dc.c<strong>on</strong>straint_name, dc.owner, dc.table_name, dcc.column_name,<br />

<strong>to</strong>_lob(dc.search c<strong>on</strong>diti<strong>on</strong>)<br />

FROM dba_c<strong>on</strong>straints dc, dba_c<strong>on</strong>s_columns dcc<br />

WHERE dc.owner = dcc.owner<br />

AND dc.c<strong>on</strong>straint_name = dc c.c<strong>on</strong>straint_name<br />

AND dc.c<strong>on</strong>straint_type = 'C'<br />

AND dc.owner = 'user_name';<br />

COMMIT;<br />

SELECT *<br />

FROM NOT_NULL_CONSTRAINTS<br />

WHERE dbms_lob.instr(search_c<strong>on</strong>diti<strong>on</strong>, 'IS NOT NULL',1,1) > 0;<br />

NOT NULL c<strong>on</strong>straints can be created <strong>on</strong> tables using Enterprise Manager and the<br />

CREATE TABLE T-<strong>SQL</strong> statement.<br />

To create a NOT NULL c<strong>on</strong>straint using Enterprise Manager, follow these<br />

steps:<br />

1. In the Table Designer, the Allow Nulls column should be unchecked <str<strong>on</strong>g>for</str<strong>on</strong>g> en<str<strong>on</strong>g>for</str<strong>on</strong>g>cing<br />

the NOT NULL c<strong>on</strong>straint and checked <strong>to</strong> indicate a NULL c<strong>on</strong>straint.<br />

To create a NOT NULL c<strong>on</strong>straint Using T-<strong>SQL</strong>, use the following syntax:<br />

CREATE TABLE table_name<br />

(<br />

column_name datatype [ CONSTRAINT c<strong>on</strong>straint_name ]<br />

{ NULL | NOT NULL },<br />

…<br />

)<br />

Check C<strong>on</strong>straint<br />

Both <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong> use the same syntax <strong>to</strong> define check c<strong>on</strong>straints; both also<br />

have similar restricti<strong>on</strong>s in its usage. CHECK c<strong>on</strong>straints can be defined <strong>on</strong> a single<br />

column or multiple columns at the table level. The c<strong>on</strong>diti<strong>on</strong>s specified in the CHECK<br />

clause should evaluate <strong>to</strong> a Boolean value of TRUE or FALSE. The c<strong>on</strong>diti<strong>on</strong>s can refer<br />

<strong>to</strong> other columns but are restricted <strong>to</strong> the row being modified.<br />

Both <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong> allow multiple CHECK c<strong>on</strong>straints <strong>on</strong> a column. A column<br />

c<strong>on</strong>straint can <strong>on</strong>ly reference the column it is being created <strong>on</strong>. Each c<strong>on</strong>straint can have<br />

multiple c<strong>on</strong>catenated c<strong>on</strong>diti<strong>on</strong>s. The process <strong>to</strong> create check c<strong>on</strong>straints <strong>on</strong> tables<br />

using Enterprise Manager and T-<strong>SQL</strong> is provided in the following procedures.<br />

To create a check c<strong>on</strong>straint using the Table Designer in Enterprise Manager,<br />

follow these steps:<br />

1. In the Table Designer, click the Manage C<strong>on</strong>straints butt<strong>on</strong> <strong>to</strong> bring up the table<br />

Properties window with the Check C<strong>on</strong>straints pane active.<br />

2. Click the New butt<strong>on</strong> <strong>to</strong> add a c<strong>on</strong>straint.


114 Developing: Databases — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> Schemas<br />

3. A name of the type CK_table_name is inserted by the system in the C<strong>on</strong>straint<br />

name box. The c<strong>on</strong>straint name can be changed <strong>to</strong> match the name given in<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong>ly after entering a valid c<strong>on</strong>diti<strong>on</strong> in the C<strong>on</strong>straint expressi<strong>on</strong> box.<br />

To create a check c<strong>on</strong>straint using T-<strong>SQL</strong>, use the following syntax:<br />

Table 6.13 provides the syntax <str<strong>on</strong>g>for</str<strong>on</strong>g> the two alternative <str<strong>on</strong>g>for</str<strong>on</strong>g>mats available in <strong>SQL</strong> <strong>to</strong> specify<br />

CHECK c<strong>on</strong>straints during table creati<strong>on</strong>. The syntax is the same in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and<br />

<strong>SQL</strong> <strong>Server</strong>.<br />

Table 6.13: T-<strong>SQL</strong> Statements <str<strong>on</strong>g>for</str<strong>on</strong>g> Defining Inline and Out-of-line CHECK<br />

C<strong>on</strong>straints in <strong>SQL</strong> <strong>Server</strong><br />

Inline (Column) C<strong>on</strong>straint<br />

CREATE TABLE table_name<br />

(column_name datatype<br />

[ CONSTRAINT c<strong>on</strong>straint_name ] CHECK<br />

(c<strong>on</strong>diti<strong>on</strong>)<br />

…<br />

)<br />

Out-of-line (Table) C<strong>on</strong>straint<br />

CREATE TABLE table_name<br />

(column_name datatype,<br />

…<br />

[ CONSTRAINT c<strong>on</strong>straint_name ] CHECK<br />

(c<strong>on</strong>diti<strong>on</strong>)<br />

)<br />

Unique C<strong>on</strong>straints<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong> use indexes <strong>to</strong> en<str<strong>on</strong>g>for</str<strong>on</strong>g>ce unique c<strong>on</strong>straints. In <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>, if a unique<br />

or n<strong>on</strong>-unique index already exists <strong>on</strong> the c<strong>on</strong>straint columns, the index is used <strong>to</strong><br />

en<str<strong>on</strong>g>for</str<strong>on</strong>g>ce the c<strong>on</strong>straint without creating new <strong>on</strong>es. There<str<strong>on</strong>g>for</str<strong>on</strong>g>e, if a user-defined index is<br />

preferred instead of a system-defined (and named) <strong>on</strong>e, it is recommended that the index<br />

be created first. Unless a clustered index is explicitly specified, <strong>SQL</strong> <strong>Server</strong> creates a<br />

n<strong>on</strong>clustered index <strong>on</strong> the unique key column(s).<br />

An important difference in the implementati<strong>on</strong> of the UNIQUE c<strong>on</strong>straint is <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> allows<br />

multiple rows with NULL values in all the columns making up the unique c<strong>on</strong>straint,<br />

whereas <strong>SQL</strong> <strong>Server</strong> allows <strong>on</strong>ly <strong>on</strong>e row <strong>to</strong> have a NULL value <str<strong>on</strong>g>for</str<strong>on</strong>g> the UNIQUE column.<br />

In <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>, the UNIQUE, PRIMARY KEY, and FOREIGN KEY c<strong>on</strong>straints can be a<br />

composite of up <strong>to</strong> 32 columns, while in <strong>SQL</strong> <strong>Server</strong> the limit is 16.<br />

Unique c<strong>on</strong>straints can be created using Enterprise Manager as well as T-<strong>SQL</strong><br />

statements.<br />

To create a UNIQUE c<strong>on</strong>straint using Enterprise Manager, follow these steps:<br />

1. In the Table Designer, click the Table and Index Properties butt<strong>on</strong>.<br />

2. Select the Indexes/Keys tab and click New. A system-assigned index name<br />

appears with the column name, column order, index filegroup, and fill fac<strong>to</strong>r filled in<br />

using defaults. You will need <strong>to</strong> replace these default values with your own.<br />

3. Enter the name of the new index in the Index name text box and select the<br />

columns <strong>to</strong> be included in the c<strong>on</strong>straint in the correct order in the grid.<br />

4. Check the Create UNIQUE check box and select the C<strong>on</strong>straint radio butt<strong>on</strong>.<br />

5. Check the Create as CLUSTERED box if a clustered index is <strong>to</strong> be used <strong>to</strong><br />

en<str<strong>on</strong>g>for</str<strong>on</strong>g>ce the c<strong>on</strong>straint. If a n<strong>on</strong>clustered index is chosen, a filegroup can be<br />

specified <str<strong>on</strong>g>for</str<strong>on</strong>g> the index. Because <strong>on</strong>ly a single clustered index can be created <strong>on</strong> a<br />

table, and the filegroup cannot be changed from the primary filegroup.<br />

6. The equivalent of <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>'s PCTFREE can be specified <str<strong>on</strong>g>for</str<strong>on</strong>g> the index that will be<br />

created <strong>to</strong> en<str<strong>on</strong>g>for</str<strong>on</strong>g>ce the c<strong>on</strong>straint in the Fill Fac<strong>to</strong>r box.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 115<br />

To create a UNIQUE c<strong>on</strong>straint using T-<strong>SQL</strong>, use the following syntax:<br />

The <strong>on</strong>ly syntactic difference in the UNIQUE c<strong>on</strong>straint definiti<strong>on</strong> between <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and<br />

<strong>SQL</strong> <strong>Server</strong> is with the USING INDEX clause used <strong>to</strong> define the index that en<str<strong>on</strong>g>for</str<strong>on</strong>g>ces the<br />

c<strong>on</strong>straint. The USING INDEX clause of <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> has an equivalent in <strong>SQL</strong> <strong>Server</strong> and can<br />

be used with both column and table c<strong>on</strong>straints. The syntax <str<strong>on</strong>g>for</str<strong>on</strong>g> table c<strong>on</strong>straint is<br />

described in Table 6.14.<br />

Table 6.14: <strong>SQL</strong> Statements <str<strong>on</strong>g>for</str<strong>on</strong>g> Defining UNIQUE C<strong>on</strong>straints in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and<br />

<strong>SQL</strong> <strong>Server</strong><br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g><br />

<strong>SQL</strong> <strong>Server</strong><br />

CREATE TABLE table_name<br />

CREATE TABLE table_name<br />

(<br />

(<br />

column_name datatype,<br />

column_name datatype,<br />

…,<br />

…,<br />

[ CONSTRAINT c<strong>on</strong>straint_name ] [ CONSTRAINT c<strong>on</strong>straint_name ]<br />

UNIQUE ( column_name [, …] ) UNIQUE [ CLUSTERED | NONCLUSTERED ]<br />

[ USING INDEX [ TABLESPACE<br />

( column_name [, …] )<br />

tablespace_name ]<br />

[ WITH FILLFACTOR = fillfac<strong>to</strong>r ]<br />

[ s<strong>to</strong>rage_definiti<strong>on</strong> ] ]<br />

[ ON FILEGROUP { filegroup |<br />

DEFAULT } ]<br />

Primary Key C<strong>on</strong>straint<br />

PRIMARY KEY c<strong>on</strong>straints have all the characteristics of UNIQUE c<strong>on</strong>straints, with the<br />

additi<strong>on</strong>al restricti<strong>on</strong> that all primary key columns be NOT NULL. <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> creates a<br />

UNIQUE index and a NOT NULL c<strong>on</strong>straint <strong>to</strong> implement PRIMARY KEY c<strong>on</strong>straints.<br />

With <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> 9i, an existing n<strong>on</strong>-unique index may be used <strong>to</strong> en<str<strong>on</strong>g>for</str<strong>on</strong>g>ce the primary key<br />

c<strong>on</strong>straint. In <strong>SQL</strong> <strong>Server</strong>, if a clustered index does not already exist <strong>on</strong> the table, or a<br />

n<strong>on</strong>clustered index is not explicitly specified, a unique, clustered index is created <strong>to</strong><br />

en<str<strong>on</strong>g>for</str<strong>on</strong>g>ce the PRIMARY KEY c<strong>on</strong>straint. The following procedures dem<strong>on</strong>strate that it is far<br />

easier <strong>to</strong> use T-<strong>SQL</strong> than Enterprise Manager when it comes <strong>to</strong> creating a PRIMARY<br />

KEY c<strong>on</strong>straint.<br />

To create a primary key c<strong>on</strong>straint using Enterprise Manager, follow these<br />

steps:<br />

1. In the Table Designer, click and select the colum n(s) that are part of the primary<br />

key (use the Ctrl key <str<strong>on</strong>g>for</str<strong>on</strong>g> this).<br />

2. Right-clic k anywhere al<strong>on</strong>g the selected column(s) and click Set Primary Key. A<br />

check mark appears next <strong>to</strong> the Set Primary Key opti<strong>on</strong>.<br />

3. A unique clustered in dex using the naming c<strong>on</strong>venti<strong>on</strong> PK_table_name is<br />

au<strong>to</strong>matically created by the system.<br />

4. The name and properties of the index can be changed from those assigned by the<br />

system through the Indexes/Keys pane of the Table and Index Properties<br />

window.<br />

To create a primary key c<strong>on</strong>straint using T-<strong>SQL</strong>, use the following syntax:<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong> differ <strong>on</strong>ly in the USING INDEX part of the PRIMARY KEY<br />

c<strong>on</strong>straint syntax. The syntax differs from the UNIQUE c<strong>on</strong>straint definiti<strong>on</strong> <strong>on</strong>ly in the<br />

UNIQUE keyword being replaced with PRIMARY KEY. In both <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong>, a<br />

NOT NULL c<strong>on</strong>straint is added by the system <str<strong>on</strong>g>for</str<strong>on</strong>g> all primary key columns when <strong>on</strong>e is not<br />

explicitly<br />

specified.


116 Developing: Databases — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> Schemas<br />

The CREATE TABLE syntax in Table 6.15 is <str<strong>on</strong>g>for</str<strong>on</strong>g> defining primary key c<strong>on</strong>straints and its<br />

associated index.<br />

Table 6.15: <strong>SQL</strong> Statements <str<strong>on</strong>g>for</str<strong>on</strong>g> Defining PRIMARY KEY C<strong>on</strong>straints in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g><br />

<strong>SQL</strong> <strong>Server</strong><br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g><br />

<strong>SQL</strong> <strong>Server</strong><br />

CREATE TABLE table_name<br />

CREATE TABLE table_name<br />

(<br />

(<br />

column_name datatype,<br />

column_name datatype,<br />

…,<br />

…,<br />

[ CONSTRAINT c<strong>on</strong>straint_name ]<br />

[ CONSTRAINT c<strong>on</strong>straint_name ]<br />

PRIMARY KEY ( column_name [, …] ) [ PRIMARY KEY [ CLUSTERED |<br />

USING INDEX [ TABLESPACE<br />

NONCLUSTERED ] ( column_name [, …] )<br />

tablespace_name ] [ s<strong>to</strong>rage specs ] ] [ WITH FILLFACTOR = fillfac<strong>to</strong>r ] [ ON<br />

FILEGROUP { filegroup | DEFAULT } ]<br />

and<br />

Foreign Key C<strong>on</strong>straint<br />

A <str<strong>on</strong>g>for</str<strong>on</strong>g>eign key c<strong>on</strong>straint en<str<strong>on</strong>g>for</str<strong>on</strong>g>ces the rule that a n<strong>on</strong>-null value in <strong>on</strong>e or more columns of<br />

a table (child) must exist in a corresp<strong>on</strong>ding set of columns in the same (self-referential)<br />

or another (parent) table. The referenced key columns must possess a primary key or<br />

unique key index <strong>on</strong> them.<br />

The number and data types of columns specified in the FOREIGN KEY clause should<br />

match the corresp<strong>on</strong>ding columns of the referenced table. FOREIGN KEY c<strong>on</strong>straints in<br />

<strong>SQL</strong> <strong>Server</strong> have a restricti<strong>on</strong> of not being able <strong>to</strong> cross database boundaries. In the<br />

case where <str<strong>on</strong>g>for</str<strong>on</strong>g>eign key c<strong>on</strong>straints existing between different schemas of a source<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> database are migrated <strong>to</strong> separate databases in <strong>SQL</strong> <strong>Server</strong>, the c<strong>on</strong>straints will<br />

have <strong>to</strong> be replaced with triggers. In <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>, the ON DELETE clause is used <strong>to</strong> specify<br />

the acti<strong>on</strong>s that will au<strong>to</strong>matically be undertaken if a parent row is deleted. Additi<strong>on</strong>ally,<br />

<strong>SQL</strong> <strong>Server</strong> has the ON UPDATE clause <str<strong>on</strong>g>for</str<strong>on</strong>g> handling updates <strong>to</strong> the parent rows.<br />

Table 6.16 shows the availability of various c<strong>on</strong>trol acti<strong>on</strong>s using these clauses in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g><br />

and <strong>SQL</strong> <strong>Server</strong>:<br />

Table 6.16: Functi<strong>on</strong>ality Available in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong> with Respect <strong>to</strong><br />

Foreign Key C<strong>on</strong>straint<br />

Operati<strong>on</strong> Acti<strong>on</strong> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>SQL</strong> <strong>Server</strong><br />

ON DELETE SET NULL Yes No<br />

ON DELETE CASCADE Yes Yes<br />

ON DELETE NO ACTION Yes Yes<br />

ON UPDATE CASCADE No Yes<br />

ON UPDATE NO ACTION No Yes<br />

Note In <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>, the default of NO ACTION (restrict) is assumed <strong>on</strong>ly by the absence of<br />

an O N DELETE { SET NULL | CASCADE } clause in the definiti<strong>on</strong>. In <strong>SQL</strong> <strong>Server</strong>, the<br />

default is NO ACTION <str<strong>on</strong>g>for</str<strong>on</strong>g> both operati<strong>on</strong>s. To mimic the acti<strong>on</strong> of SET NULL, it has <strong>to</strong><br />

be handled programmatically in the applicati<strong>on</strong> using an appropriate <strong>SQL</strong> statement.<br />

Foreign key c<strong>on</strong>straints can be created in <strong>SQL</strong> <strong>Server</strong> using<br />

Enterprise Manager and T-<br />

<strong>SQL</strong>.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 117<br />

To create a <str<strong>on</strong>g>for</str<strong>on</strong>g>eign key c<strong>on</strong>straint using Enterprise Manager, follow these<br />

steps:<br />

1. Right-click the table name <strong>on</strong> the table list, click Design Table, and then click<br />

Table and Index Properties.<br />

2. Select the Relati<strong>on</strong>ships tab and click New.<br />

3. A new relati<strong>on</strong>ship is created with a default name and current table selected in the<br />

Foreign key table drop-down list. Type in or select (from drop-down list) the<br />

appropriate columns involved in the current table (child table). Also select the<br />

appropriate table <str<strong>on</strong>g>for</str<strong>on</strong>g> the Parent key table and its parent columns.<br />

4. Select appropriate behaviors <str<strong>on</strong>g>for</str<strong>on</strong>g> the trigger in the check boxes at the bot<strong>to</strong>m of the<br />

screen. The important behaviors are Check existing data <strong>on</strong> creati<strong>on</strong> and<br />

En<str<strong>on</strong>g>for</str<strong>on</strong>g>ce relati<strong>on</strong>ship <str<strong>on</strong>g>for</str<strong>on</strong>g> INSERTs and UPDATEs.<br />

To create a <str<strong>on</strong>g>for</str<strong>on</strong>g>eign key c<strong>on</strong>straint using the Database Diagram Wizard, follow<br />

these steps:<br />

1. Expand <strong>Server</strong>, then Databases, then target database.<br />

2. Right-click Diagrams and click New Database Diagram.<br />

3. The wizard will lead you through adding the tables <strong>to</strong> be included in the diagram.<br />

See Figure 6.7.<br />

Figure 6.7<br />

Using Database Diagram Wizard <str<strong>on</strong>g>for</str<strong>on</strong>g> creating referentials<br />

4. To add a relati<strong>on</strong>ship, select the <str<strong>on</strong>g>for</str<strong>on</strong>g>eign key column of the child table, and drag it <strong>to</strong><br />

the primary or unique key column of the parent table.<br />

5. A pop-up dialog will appear with columns filled in based <strong>on</strong> the columns selected<br />

in<br />

the drag and drop. The acti<strong>on</strong>s need not be precise because in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> such as


118 Developing: Databases — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> Schemas<br />

name, primary key, and <str<strong>on</strong>g>for</str<strong>on</strong>g>eign key columns, can be modified be<str<strong>on</strong>g>for</str<strong>on</strong>g>e saving. See<br />

Figure 6.8.<br />

Figure 6.8<br />

Choosing the right relati<strong>on</strong>ship properties<br />

To create a <str<strong>on</strong>g>for</str<strong>on</strong>g>eign key c<strong>on</strong>straint using T-<strong>SQL</strong>, use the following syntax:<br />

Table 6.17 c<strong>on</strong>tains the syntax <strong>to</strong> add <str<strong>on</strong>g>for</str<strong>on</strong>g>eign key c<strong>on</strong>straints with the acti<strong>on</strong>s of ON<br />

DELETE and also the ON UPDATE statement, which do es not exist in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>.<br />

T able 6.17: <strong>SQL</strong> Statements <str<strong>on</strong>g>for</str<strong>on</strong>g> Defining FOREIGN KEY C<strong>on</strong>straints in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g><br />

<strong>SQL</strong> <strong>Server</strong><br />

Operati<strong>on</strong> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>SQL</strong> <strong>Server</strong><br />

ON DELETE<br />

CREATE TABLE<br />

table_ name<br />

CREATE TABLE<br />

table_name<br />

(…,<br />

(…,<br />

column_name datatype,<br />

…,<br />

[ CONSTRAINT<br />

c<strong>on</strong>straint_name ]<br />

FOREIGN KEY<br />

(column_name [,…]<br />

REFERENCES<br />

[schema.]ref_table_name<br />

(ref_column_name[, …])<br />

ON DELETE { SET NULL |<br />

column_name datatype,<br />

…,<br />

[ CONSTRAINT<br />

c<strong>on</strong>straint_name ]<br />

FOREIGN KEY<br />

(column_name [,…]<br />

REFERENCES<br />

ref_table_name<br />

(ref_column_name[, …])<br />

ON DELETE { CASCADE |


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 119<br />

Operati<strong>on</strong> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>SQL</strong> <strong>Server</strong><br />

ON UPDATE<br />

CASCADE }<br />

NO ACTION}<br />

CREATE TABLE<br />

table_name<br />

(…,<br />

column_name datatype,<br />

…,<br />

[ CONSTRAINT<br />

c<strong>on</strong>straint_name ]<br />

FOREIGN KEY<br />

(column_name [,…]<br />

REFERENCES<br />

ref_table_name<br />

(ref_column_name[, …])<br />

ON UPDATE { CASCADE |<br />

NO ACTION}<br />

Triggers<br />

Triggers are used <strong>to</strong> en<str<strong>on</strong>g>for</str<strong>on</strong>g>ce more complex business rules than can be en<str<strong>on</strong>g>for</str<strong>on</strong>g>ced using<br />

c<strong>on</strong>straints. Triggers are s<strong>to</strong>red procedures that are implicitly executed when certain data<br />

modificati<strong>on</strong> (using data manipulati<strong>on</strong> language statements, also known as DML) is<br />

per<str<strong>on</strong>g>for</str<strong>on</strong>g>med against tables and views. In <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>, there can be up <strong>to</strong> twelve combinati<strong>on</strong>s of<br />

trigger executi<strong>on</strong>s (acti<strong>on</strong>s) based <strong>on</strong>:<br />

● DML operati<strong>on</strong>: INSERT, UPDATE, DELETE<br />

● Timing: BEFORE, AFTER<br />

● Level: ROW, STATEMENT<br />

Table 6.18 evaluates <strong>SQL</strong> <strong>Server</strong> support <str<strong>on</strong>g>for</str<strong>on</strong>g> the <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> trigger functi<strong>on</strong>ality.<br />

Table 6.18: Functi<strong>on</strong>ality of <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Triggers Mapped <strong>to</strong> <strong>SQL</strong> <strong>Server</strong><br />

Trigger Feature <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>SQL</strong> <strong>Server</strong><br />

DML – INSERT Yes Yes<br />

DML – UPDATE Column/Row Row<br />

DML – DELETE Yes Yes<br />

Timing – BEFORE Yes Yes (INSTEAD OF)<br />

Timing – AFTER Yes Yes<br />

Level Row/Statemen t<br />

Row<br />

Views – INSTEAD OF Yes Yes<br />

Multiple triggers per acti<strong>on</strong> Yes Yes (first/last specified)<br />

The <strong>SQL</strong> <strong>Server</strong> INSTEAD OF triggers are equivalent <strong>to</strong> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>’s BEFORE triggers.<br />

When migrating triggers from <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>, the <strong>on</strong>ly drawback is that <strong>SQL</strong> <strong>Server</strong> does not<br />

support statement-level triggers. However, there are two pseudo-tables, inserted and<br />

deleted, that are populated during the trig ger executi<strong>on</strong> and which can be used <strong>to</strong><br />

simulate statement-level operati<strong>on</strong>s. These inserted<br />

and deleted pseudo tables are<br />

similar <strong>to</strong> the :old and :new pseudo-rows in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and are populated with all (multiple)<br />

rows affected by the trigger executi<strong>on</strong>. The <strong>SQL</strong> <strong>Server</strong> deleted and inserted pseudotables<br />

are available by default and are not specified as part of the trigger definiti<strong>on</strong>. In


120 Developing: Databases — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> Schemas<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g>, the pseudo-rows have <strong>to</strong> be defined in the trigger using the REFERENCING<br />

clause.<br />

Note This secti<strong>on</strong> is c<strong>on</strong>cerned <strong>on</strong>ly with creati<strong>on</strong> of the trigger object. A detailed<br />

discussi<strong>on</strong> <strong>on</strong> trigger logic (code) and its migrati<strong>on</strong> is found in Chapter 11, "Developing:<br />

Applicati<strong>on</strong>s — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>SQL</strong> and PL/<strong>SQL</strong>" under the "<str<strong>on</strong>g>Migrating</str<strong>on</strong>g> the Data<br />

Access" secti<strong>on</strong>.<br />

When multiple triggers exist <strong>on</strong> a table <str<strong>on</strong>g>for</str<strong>on</strong>g> the same acti<strong>on</strong>, <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> does not guarantee<br />

any particular order of executi<strong>on</strong> of multiple triggers. <strong>SQL</strong> <strong>Server</strong> has the capability <strong>to</strong><br />

specify which trigger should be fired be<str<strong>on</strong>g>for</str<strong>on</strong>g>e (first) and a fter (last) all other triggers using<br />

the system s<strong>to</strong>red pr ocedure sp_ settriggerorder. This feature has been found useful in<br />

e liminating some of the complexities in the code found in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> triggers <strong>to</strong> manage the<br />

s equence of events.<br />

Triggers can be defined <strong>on</strong> tables either using Enterprise Manager or using T-<strong>SQL</strong>.<br />

To create a trigger using Enterprise Manager, follow<br />

these steps:<br />

1. In the Enterprise Manager, expand <strong>Server</strong>, then Databases, then target<br />

database, and then Tables.<br />

2. Right-click the table nam e <strong>on</strong> the table list, click All Tasks, and then click Manage<br />

Triggers. Or, click the Trigge rs butt<strong>on</strong> in the Table Designer.<br />

3. Type in the trigger text using the provided template.<br />

4. Click Apply if m ore than <strong>on</strong>e trigger is <strong>to</strong> be created, or OK <strong>to</strong> save all changes<br />

and close the dialog box.<br />

To create a trigger using T-S QL, use the following syntax:<br />

Table 6.19 compares the comm<strong>on</strong>ly used functi<strong>on</strong>ality of the trigger definiti<strong>on</strong> CREATE<br />

TRIGGER statement in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong>.<br />

Table 6.19: <strong>SQL</strong> Statements <str<strong>on</strong>g>for</str<strong>on</strong>g> Creating Triggers in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong><br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g><br />

CREATE TRIGGER trigger_name<br />

{ BEFORE | AFTER | INSTEAD OF } { {<br />

INSERT [ OR ] | DELETE [ OR ] |<br />

UPDATE [ OF column_name [, …] ] } }<br />

ON table_name<br />

REFERENCING [OLD AS :old] [NEW AS<br />

:new]<br />

[ FOR EACH ROW ]<br />

WHEN ( c<strong>on</strong>diti<strong>on</strong> )<br />

Pl/ sql_block<br />

<strong>SQL</strong> <strong>Server</strong><br />

CREATE TRIGGER trigger_name<br />

ON table_name | view_name<br />

{ { FOR | AFTER | INSTEAD OF } { [<br />

INSERT ] [ , ] [ UPDATE ] [ , ] [<br />

DELETE ] }<br />

AS<br />

[ { IF UPDATE ( column_name )<br />

[ { AND | OR } UPDATE ( column_name<br />

) ] [ ...n ] |<br />

IF ( COLUMNS_UPDATED ( ) {<br />

bitwise_opera<strong>to</strong>r } updated_bitmask<br />

)<br />

{ comparis<strong>on</strong>_ opera<strong>to</strong>r }<br />

column_bitmask [ ...n ] } ]<br />

sql_statement [ ...n ]<br />

}<br />

}


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 121<br />

Indexes<br />

There are two major categories of indexes in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>: B-tree indexes and Bitmap<br />

indexes. All other indexes are variati<strong>on</strong>s of these two basic types <strong>to</strong> provide additi<strong>on</strong>al<br />

features. Table 6.20 provides a quick comparis<strong>on</strong> of the indexing schemes available in<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong>:<br />

Table 6.20: Indexing Schemes Available in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong><br />

Index Scheme <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>SQL</strong> <strong>Server</strong><br />

B-tree — Unique Yes Yes<br />

B-tree — N<strong>on</strong>-unique Yes Yes<br />

B-tree — Composite Yes (32 columns) Yes (16 columns)<br />

B-tree — Ascending Yes Yes<br />

B-tree — Descending Yes Yes<br />

B-tree — Cluster Yes No<br />

B-tree — Reverse Key Yes No<br />

B-tree — Key Compressed Yes No<br />

B-tree — Functi<strong>on</strong>-based Yes No<br />

B-tree — Index-Organized Yes<br />

Yes (Clustered)<br />

Table<br />

B-tree — Partiti<strong>on</strong>ed Yes No<br />

Bitmap Yes (30 columns) No<br />

Bitmap — Join Yes No<br />

B-Tree Indexes<br />

<strong>SQL</strong> <strong>Server</strong> offers two types of indexes: clustered and n<strong>on</strong>clustered. Both these types<br />

are based <strong>on</strong> the B-tree data structure. Hence assumpti<strong>on</strong>s can be drawn as <strong>to</strong> their<br />

per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance in the two systems. An important difference between the two<br />

implementati<strong>on</strong>s is <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> does not index rows when all the key columns have null values<br />

in them, while <strong>SQL</strong> <strong>Server</strong> does.<br />

Both <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong> support the following basic versi<strong>on</strong>s of the B-tree index:<br />

● Comp osite. <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> allows indexes with up <strong>to</strong> 32 columns, whereas <strong>SQL</strong> <strong>Server</strong><br />

allows up <strong>to</strong> 16 columns. While indexes with 16 or more columns are rare, the<br />

number of columns will have <strong>to</strong> be trimmed down if such indexes were <strong>to</strong> be<br />

migrated <strong>to</strong> <strong>SQL</strong> <strong>Server</strong>.<br />

● Unique. Unique indexes are used <strong>to</strong> en<str<strong>on</strong>g>for</str<strong>on</strong>g>ce PRIMARY KEY and UNIQUE<br />

c<strong>on</strong>straints. Even though nulls cannot be compared (nor c<strong>on</strong>sidered equal) <str<strong>on</strong>g>for</str<strong>on</strong>g><br />

sake of uniqueness, when two rows are identical, null values are c<strong>on</strong>sidered as<br />

identical. In <strong>SQL</strong> <strong>Server</strong>, primary key c<strong>on</strong>straints cannot have null values, whereas<br />

unique indexes allow <strong>on</strong>e row with null value. For more in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong>, refer <strong>to</strong> the<br />

"Unique C<strong>on</strong>straints" secti<strong>on</strong> earlier in this chapter.<br />

● N<strong>on</strong>-unique. This is the basic <str<strong>on</strong>g>for</str<strong>on</strong>g>m of the B-tree or n<strong>on</strong>clustered index, where key<br />

values can be repeated.<br />

● Ascending. The key values are sorted and s<strong>to</strong>red in ascending order.<br />

● Descending. The key values are sorted and s<strong>to</strong>red in descending order.<br />

The following list provides variati<strong>on</strong>s of the B-tree index, implemented with a modificati<strong>on</strong><br />

<strong>to</strong> the basic B-tree structure, that provide a specific feature:


122 Developing: Databases — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> Schemas<br />

●<br />

●<br />

●<br />

●<br />

●<br />

●<br />

Cluster indexes. Such indexes can be found in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> clustered tables<br />

(clusters). Clustered tables are not supported by <strong>SQL</strong> <strong>Server</strong> and neither are<br />

cluster indexes.<br />

Index-organized tables. The clustered indexes in <strong>SQL</strong> <strong>Server</strong> are similar <strong>to</strong> the<br />

index organized tables. Refer <strong>to</strong> the discussi<strong>on</strong> under the "Tables" secti<strong>on</strong> earlier in<br />

this chapter.<br />

Reverse key indexes. <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> developed these indexes <strong>to</strong> reduce c<strong>on</strong>tenti<strong>on</strong> <str<strong>on</strong>g>for</str<strong>on</strong>g><br />

index blocks by indexes <strong>on</strong> columns that have sequential values that are written<br />

almost simultaneously. This is achieved by reversing the bytes in the key value <strong>to</strong><br />

produce n<strong>on</strong>-sequential numbers. This indexing scheme is not available in<br />

<strong>SQL</strong> <strong>Server</strong>. The reverse key index is useful in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Real Applicati<strong>on</strong> Cluster<br />

(RAC) implementati<strong>on</strong>s, and there is no disadvantage in migrating such indexes <strong>to</strong><br />

clustered or n<strong>on</strong>clustered indexes.<br />

Partiti<strong>on</strong>ed indexes. In <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>, B-tree indexes can be created that are local <strong>to</strong> the<br />

partiti<strong>on</strong> or global <strong>to</strong> the entire table (partiti<strong>on</strong>ed or n<strong>on</strong>- partiti<strong>on</strong>ed). This feature is<br />

not available in <strong>SQL</strong> <strong>Server</strong> and should be replaced by clustered or n<strong>on</strong>clustered<br />

indexes.<br />

Key compressed index. In key compressi<strong>on</strong>, the leading subsets of a key can be<br />

compressed in a manner similar <strong>to</strong> clustering by s<strong>to</strong>ring the leading subset <strong>on</strong>ly<br />

<strong>on</strong>ce <str<strong>on</strong>g>for</str<strong>on</strong>g> repeating values. <strong>SQL</strong> <strong>Server</strong> does not support key compressi<strong>on</strong>.<br />

Functi<strong>on</strong>-based index. In <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>, expressi<strong>on</strong>s in the WHERE clause that c<strong>on</strong>tain<br />

functi<strong>on</strong>s do not use indexes as an access path. To overcome this disadvantage,<br />

indexes can be created by applying the functi<strong>on</strong> <strong>to</strong> compute the value of the<br />

expressi<strong>on</strong> and s<strong>to</strong>ring it in an index. For example, if the column part_name is<br />

accessed using the expressi<strong>on</strong> UPPER(part_name), a functi<strong>on</strong>-based index can be<br />

defined <strong>on</strong> UPPER(part_name). <strong>SQL</strong> <strong>Server</strong> does not support functi<strong>on</strong>-based<br />

indexes. There is no other index type in <strong>SQL</strong> <strong>Server</strong> that can provide similar<br />

functi<strong>on</strong>ality.<br />

Bitmap Index<br />

The bitmap indexes are specia lly designed <str<strong>on</strong>g>for</str<strong>on</strong>g> improving the retrieval of data based <strong>on</strong><br />

columns with very low cardinality. Becaus e maintenance of the bitmap indexes is very<br />

expensive, their utility is restric ted <strong>to</strong> Data Warehouses and DSS systems where there is<br />

very low or zero update activity.<br />

Bitmap indexes are not available in <strong>SQL</strong> <strong>Server</strong> and cannot be substituted with B-tree<br />

indexes.<br />

I n <strong>SQL</strong> <strong>Server</strong> and versi<strong>on</strong>s of <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> be<str<strong>on</strong>g>for</str<strong>on</strong>g>e 9i, indexes are used <strong>on</strong>ly when the leading<br />

subset of key values are involved. In <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> 9i, <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> introduced the c<strong>on</strong>cept of fast<br />

index scan, whereby the entire index is scanned <str<strong>on</strong>g>for</str<strong>on</strong>g> matching values in the n<strong>on</strong>-leading<br />

keys by skipping the leading key columns. In <strong>SQL</strong> <strong>Server</strong>, additi<strong>on</strong>al indexes have <strong>to</strong> be<br />

created <str<strong>on</strong>g>for</str<strong>on</strong>g> the n<strong>on</strong>-leading columns <strong>to</strong> provide access paths similar <strong>to</strong> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>. This<br />

requirement is not documented inside the database and is dependent <strong>on</strong> the <strong>SQL</strong><br />

statements used in applicati<strong>on</strong>s. These situati<strong>on</strong>s can <strong>on</strong>ly be discovered by profiling the<br />

applicati<strong>on</strong> during testing.<br />

The various types of indexes can be created using Enterprise Manager, the Create Index<br />

Wizard, or T-<strong>SQL</strong>.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 123<br />

To create an index using Enterprise Manager, follow these steps:<br />

The steps <str<strong>on</strong>g>for</str<strong>on</strong>g> creating an index are very similar <strong>to</strong> that described <str<strong>on</strong>g>for</str<strong>on</strong>g> UNIQUE key. Creati<strong>on</strong><br />

of a n<strong>on</strong>-unique, n<strong>on</strong>clustered index is dem<strong>on</strong>strated here.<br />

1. Expand <strong>Server</strong>, then Databases, then target database, and then Tables.<br />

2. Right-click the table nam e <strong>on</strong> the table list, click Design Table, and then click<br />

Table and Index Properties.<br />

3. Select the Indexes/Keys tab and click New.<br />

4. Enter the name of the new ind ex in the Index name text box. Insert the columns or<br />

the index in grid al<strong>on</strong>g with the required sort order fo r the column.<br />

5. Uncheck the Create UN IQUE check box <strong>to</strong> specify a n<strong>on</strong>-unique index.<br />

6. Select the target filegroup fro m the Index Filegroup drop-down list.<br />

7. Click the desired value <str<strong>on</strong>g>for</str<strong>on</strong>g> Fill fac<strong>to</strong>r (equivalent of PCTFREE).<br />

To create an index using the Create Index Wizard, follow these steps:<br />

1. Expand a server group, and then expand the server in which <strong>to</strong> create the index.<br />

2. On the Tools menu, click Wizards.<br />

3. Expand Database.<br />

4. Double-click Create Index Wizard.<br />

5. Complete the steps in the wizard<br />

To create an index using T-<strong>SQL</strong>, use the following syntax:<br />

Table 6.21 shows the syntax of the CREATE INDEX statement <str<strong>on</strong>g>for</str<strong>on</strong>g> the features and<br />

functi<strong>on</strong>ality discussed here.<br />

Table 6.21: <strong>SQL</strong> statements available <str<strong>on</strong>g>for</str<strong>on</strong>g> Creating Indexes in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and<br />

<strong>SQL</strong> <strong>Server</strong><br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g><br />

CREATE [UNIQUE | BITMAP ]<br />

INDEX index_name<br />

ON table_name ( column_name<br />

[ ASC | DESC ] [, …] )<br />

[ physical_attributes ]<br />

[ { COMPRESS | NOCOMPRESS }<br />

prefix_length ]<br />

[ REVERSE ]<br />

[ TABLESPACE tablespace_name ]<br />

[ s<strong>to</strong>rage_descripti<strong>on</strong> ]<br />

<strong>SQL</strong> <strong>Server</strong><br />

CREATE [ UNIQUE ] [ CLUSTERED |<br />

NONCLUSTERED ] INDEX index_name<br />

ON table_name ( column_name<br />

[ ASC | DESC ] [, … ] )<br />

[ WITH index_opti<strong>on</strong>s ]<br />

[ ON filegroup ]<br />

Views<br />

Vie ws are used in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong> <strong>to</strong> hide query complexity and encourage query<br />

reuse. Both <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong> have added features, such as updateability and<br />

inde xes <strong>to</strong> views, <strong>to</strong> improve their utility and per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance.


124 Developing: Databases — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> Schemas<br />

Table 6.22 compares the availability of the various types of views in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and<br />

<strong>SQL</strong> <strong>Server</strong>.<br />

Table 6.22: Types of Views Available in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong><br />

View Type <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>SQL</strong> <strong>Server</strong><br />

Simple Views Yes Yes<br />

Join Views Yes Yes<br />

Partiti<strong>on</strong>ed Views Yes Yes<br />

Read-<strong>on</strong>ly Views Yes No<br />

Updateable Views Yes Yes<br />

Inline Views Yes Yes<br />

Object Views Yes No<br />

The following are the various types of views available in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and the support <str<strong>on</strong>g>for</str<strong>on</strong>g> them<br />

in <strong>SQL</strong> <strong>Server</strong>:<br />

● Simple views. This view query is based <strong>on</strong> a single table and their migrati<strong>on</strong> is<br />

trivial.<br />

● Join views. This view query is based <strong>on</strong> more than <strong>on</strong>e table. The join views<br />

available in <strong>SQL</strong> <strong>Server</strong> are less restrictive than their <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> counterparts in their<br />

use of aggregate functi<strong>on</strong>s in the query. Hence migrating them from <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>to</strong><br />

<strong>SQL</strong> <strong>Server</strong> should not pose any problems. When a view is defined with an outer<br />

join and is queried with a qualificati<strong>on</strong> <strong>on</strong> a column from the inner table of the outer<br />

join, the results from <strong>SQL</strong> <strong>Server</strong> and <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> can differ.<br />

● Partiti<strong>on</strong>ed views. This view query provides a uni<strong>on</strong> of partiti<strong>on</strong>s of data in<br />

different tables (regular n<strong>on</strong>-partiti<strong>on</strong>ed tables). Use of partiti<strong>on</strong>ed views was<br />

comm<strong>on</strong> in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> be<str<strong>on</strong>g>for</str<strong>on</strong>g>e the introducti<strong>on</strong> of partiti<strong>on</strong>ed tables in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> 8.<br />

<strong>SQL</strong> <strong>Server</strong> supports the entire range of features that are available in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> with<br />

respect <strong>to</strong> partiti<strong>on</strong>ed views.<br />

● Read-<strong>on</strong>ly views. This view query with the WITH READ ONLY clause specified <strong>to</strong><br />

curb update activity against the base tables of the view. <strong>SQL</strong> <strong>Server</strong> does not have<br />

an equivalent <str<strong>on</strong>g>for</str<strong>on</strong>g> this feature. When migrating a read-<strong>on</strong>ly view, care has <strong>to</strong> be<br />

taken <strong>to</strong> ensure that <strong>on</strong>ly SELECT privileges are granted <strong>to</strong> the users.<br />

● Updatable views. These are simple, join, or partiti<strong>on</strong>ed views against which DML<br />

statements can be executed, subject <strong>to</strong> certain restricti<strong>on</strong>s. In <strong>SQL</strong> <strong>Server</strong>, the<br />

restricti<strong>on</strong>s can be bypassed (except the use of aggregate functi<strong>on</strong>s) by defining<br />

INSTEAD OF triggers <strong>on</strong> the views. The WITH CHECK OPTION clause prevents<br />

modificati<strong>on</strong>s <strong>to</strong> data that violate the criteria in the WHERE clause of the view<br />

query. DML statements <strong>on</strong> join views can modify data <strong>on</strong>ly in <strong>on</strong>e base table.<br />

● Inline views. An inline view is a subquery that is used like a view in the FROM<br />

clause of <strong>SQL</strong> statements. <strong>SQL</strong> <strong>Server</strong> fully supports their definiti<strong>on</strong>.<br />

● Object views. Object views are virtual object tables that can be used <strong>to</strong><br />

manipulate object data types as well as relati<strong>on</strong>al data cast as objects. Object<br />

views are not available in <strong>SQL</strong> <strong>Server</strong><br />

and should be recreated (flattened) as<br />

regular views.<br />

● Indexed views. <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> does not support creati<strong>on</strong> of indexes <strong>on</strong> views. However,<br />

UNIQUE, PRIMARY KEY, and FOREIGN KEY c<strong>on</strong>straints can be defined <strong>on</strong> views<br />

which indirectly create indexes. These c<strong>on</strong>straints are a subset of those available<br />

with tables and work similarly. <strong>SQL</strong> <strong>Server</strong> allows creati<strong>on</strong> of indexes. However the<br />

first index has <strong>to</strong> be a unique clustered index. Additi<strong>on</strong>al n<strong>on</strong>clustered indexes can<br />

then be created. Thus, <strong>SQL</strong> <strong>Server</strong> can support the migrati<strong>on</strong> of indexed views.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 125<br />

Views can be created using Enterprise Manager, the Create View Wizard, or T-<strong>SQL</strong>.<br />

To create a view using Enterprise Manager, follow these steps:<br />

1. Open Enterprise Manager, expand <strong>Server</strong>, then Databases, and then the target<br />

database.<br />

2. Right-click Views and click New View.<br />

3. The view can be created using the dia gram and grid panes (<strong>to</strong>p two areas) or by<br />

entering the view query in the <strong>SQL</strong> pa ne (SELECT area). See Figure 6.9.<br />

Figure 6.9<br />

Using the View Designer of Enterprise Manager<br />

To create a view using the Create View Wizard, follow these steps:<br />

1. Expand a server group and then expand the server in which <strong>to</strong> create the view.<br />

2. On the Tools menu, click Wizards.<br />

3. Expand Database.<br />

4. Double-click Create View Wizard.<br />

5. Complete the steps in the wizard.


126 Developing: Databases — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> Schemas<br />

To create a view using T-<strong>SQL</strong>, use the following syntax:<br />

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<br />

<strong>SQL</strong> <strong>Server</strong>.<br />

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><br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g><br />

CREATE [OR REPLACE] [FORCE |<br />

NO FORCE] VIEW [schema.]view_name<br />

<strong>SQL</strong> <strong>Server</strong><br />

CREATE VIEW [owner.]view_name<br />

name [,…] ) ]<br />

[ ( column_<br />

[ ( column_alias [ inline_c<strong>on</strong>straint ] [,…] [, AS select_statement<br />

out_of_line_c<strong>on</strong>straint ] ) ]<br />

AS select_statement<br />

[ WITH READ ONLY ]<br />

[ [ WITH CHECK OPTION ] [<br />

CONSTRAINT c<strong>on</strong>straint_name ] ]<br />

[ WITH CHECK OPTION ]<br />

In O racle, views can be created without permissi<strong>on</strong>s <strong>on</strong> the base objects, or even without<br />

the base objects existing, by using the FORCE keyword. This is not allowed in<br />

<strong>SQL</strong> <strong>Server</strong>. <strong>SQL</strong> <strong>Server</strong> also does not allow ORDER BY and GROUP BY clauses in the<br />

view definiti<strong>on</strong>.<br />

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, the<br />

asterisk is expanded <strong>to</strong> the actual column names in the definiti<strong>on</strong> of the view.<br />

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 thing<br />

when 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 view<br />

definiti<strong>on</strong> may be changed back <strong>to</strong> an asterisk instead of specifying every column.<br />

S<strong>to</strong>red Programs<br />

Ora 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>d<br />

c<strong>on</strong>straints) inside the database. The code <strong>to</strong> support such requirements cannot be<br />

provided by <strong>SQL</strong> because it cannot execute commands based <strong>on</strong> logical c<strong>on</strong>diti<strong>on</strong>s. It<br />

also 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 as<br />

inco 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><br />

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>trol<br />

structures 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><br />

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-<br />

<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<br />

(or subprograms).<br />

S<strong>to</strong>red programs provide modularity (<strong>to</strong>p-down design), encapsulati<strong>on</strong> (logic is hidden),<br />

abstracti<strong>on</strong> (black box approach), security (<strong>on</strong>ly execute <strong>on</strong> subprogram), and<br />

extensibility (user-defined functi<strong>on</strong>ality). Additi<strong>on</strong>ally, existence inside the database<br />

promotes accessibility (available <strong>to</strong> all users), reuse (available <strong>to</strong> all database users),<br />

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 of<br />

large amounts of data close <strong>to</strong> its source), and reduced resource requirements (reduces<br />

network bandwidth, memory, and so <strong>on</strong> because <strong>on</strong>ly the results are transported).<br />

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.<br />

A PL/<strong>SQL</strong> procedure can also call external procedures or functi<strong>on</strong>s written in the C<br />

programming language and s<strong>to</strong>red in a shared library.<br />

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, and<br />

triggers. These objects are very similar in c<strong>on</strong>structi<strong>on</strong>, functi<strong>on</strong>ality,<br />

and usage <strong>to</strong> those


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 127<br />

used in <strong>SQL</strong> <strong>Server</strong>. Hence the migrati<strong>on</strong> of their structures is trivial. However, because<br />

of the vast difference between the syntax in the languages (PL/<strong>SQL</strong> and T-<strong>SQL</strong>) used in<br />

these objects, the migrati<strong>on</strong> of the embedded code is far from trivial.<br />

Triggers have already been discussed in this chapter. Functi<strong>on</strong>s, procedures, and<br />

packages are covered here.<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> ensures the purity of the acti<strong>on</strong>s that are per<str<strong>on</strong>g>for</str<strong>on</strong>g>med inside s<strong>to</strong>red programs.<br />

Hence there are no hidden side effects when migrated <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> and you can<br />

c<strong>on</strong>centrate <strong>on</strong> reproducing the logic using T-<strong>SQL</strong>.<br />

Here are a few points that c<strong>on</strong>cern all types of s<strong>to</strong>red programs:<br />

● Overloading. <strong>SQL</strong> <strong>Server</strong> does not support overloading, and such functi<strong>on</strong>s and<br />

procedures will have <strong>to</strong> be recreated using unique names.<br />

● Executi<strong>on</strong> privileges. <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> s<strong>to</strong>red programs can be defined <strong>to</strong> execute with<br />

definer-rights (owner) or invoker-rights (user). <strong>SQL</strong> <strong>Server</strong> <strong>on</strong>ly uses invoker-rights.<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> s<strong>to</strong>red programs that are built <strong>on</strong> definer-rights architecture can be<br />

c<strong>on</strong>verted <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> invoker-rights subprograms by properly qualifying objects<br />

inside s<strong>to</strong>red programs. With invoker rights, the schema name could also be<br />

passed in and <strong>SQL</strong> dynamically c<strong>on</strong>structed.<br />

● Parameters. Both <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong> support positi<strong>on</strong>al, named, or mixed<br />

notati<strong>on</strong> <str<strong>on</strong>g>for</str<strong>on</strong>g> parameters. <strong>SQL</strong> <strong>Server</strong> c an handle all the types of para meters that<br />

are found in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>, including tables.<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> has three parameter modes: IN, OUT, and IN OUT. <strong>SQL</strong> <strong>Server</strong> does not<br />

allow the IN OUT type of parameters, and this type warrants some rework in the<br />

applicati<strong>on</strong> design when migrating. Hence IN OUT parameters will have <strong>to</strong> be<br />

replaced with two separate IN and OUT parameters. The keyword OUTPUT is<br />

used in place of OUT, while the keyword IN does not exist and is implied because<br />

it is the default mode. Also, even though it is not a good practice, there is no<br />

restrictio n <strong>on</strong> the usage of OUT and IN OUT parameters in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> functi<strong>on</strong>s.<br />

Violati<strong>on</strong>s of this rule should be trapped and corrected during migrati<strong>on</strong>.<br />

In <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong>, IN parameters can be given default values. If such<br />

parameters are skipped during a call, the default value is applied. In <strong>SQL</strong> <strong>Server</strong>,<br />

this rule holds <str<strong>on</strong>g>for</str<strong>on</strong>g> s<strong>to</strong>red procedures but not <str<strong>on</strong>g>for</str<strong>on</strong>g> functi<strong>on</strong>s. With functi<strong>on</strong>s, the<br />

keyword "default" has <strong>to</strong> be used in the call <strong>to</strong> the functi<strong>on</strong> and cannot be skipped<br />

as with s<strong>to</strong>red procedures (which imply the use of the default value).<br />

<strong>SQL</strong> <strong>Server</strong> parameters are prefixed by the at (@) symbol.<br />

● Using same name as system. If the first three characters of the procedure name<br />

are sp_, <strong>SQL</strong> <strong>Server</strong> searches the master database <str<strong>on</strong>g>for</str<strong>on</strong>g> the procedure. If no<br />

qualified procedure name is provided, <strong>SQL</strong> <strong>Server</strong> searches <str<strong>on</strong>g>for</str<strong>on</strong>g> the procedure as if<br />

the owner name is dbo. To resolve the s<strong>to</strong>red procedure name as a user-defined<br />

s<strong>to</strong>red procedure with the same name as a system s<strong>to</strong>red procedure, provide the<br />

fully qualified procedure name.<br />

Only the migrati<strong>on</strong> of the object structure is provided in this chapter. Refer <strong>to</strong> Chapter 11,<br />

"Developing: Applicati<strong>on</strong>s — <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>SQL</strong> and PL/<strong>SQL</strong>," <str<strong>on</strong>g>for</str<strong>on</strong>g> a detailed discussi<strong>on</strong> about<br />

migrating the embedded PL/<strong>SQL</strong> code <strong>to</strong> T-<strong>SQL</strong>.<br />

Functi<strong>on</strong>s<br />

While the system provides several built-in<br />

functi<strong>on</strong>s, <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong> provide the<br />

capability <strong>to</strong> define cus<strong>to</strong>m functi<strong>on</strong>s called user-defined functi<strong>on</strong>s. These user-defined<br />

extensi<strong>on</strong>s <strong>to</strong> <strong>SQL</strong> always return a result. They are employed primarily in <strong>SQL</strong><br />

statements.<br />

Functi<strong>on</strong>s can be created using Enterprise Manager or T-<strong>SQL</strong>.


128 Developing: Databases — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> Schemas<br />

To create a functi<strong>on</strong> using Enterprise Manager, follow these steps:<br />

1. Expand a server group, and then expand a server.<br />

2. Expand Databases, and then expand the database in which <strong>to</strong> create the functi<strong>on</strong>.<br />

3. Right-click User Defined Functi<strong>on</strong>s and select New User Defined Functi<strong>on</strong>.<br />

4. In the Text box, enter the text of the functi<strong>on</strong>. Use TAB <strong>to</strong> indent the text of a<br />

functi<strong>on</strong>.<br />

5. To check the syntax, click Check Syntax and OK <strong>to</strong> create.<br />

To create a functi<strong>on</strong> using T-<strong>SQL</strong>, use the following syntax:<br />

Functi<strong>on</strong>s can be created in <strong>SQL</strong> <strong>Server</strong> using the CREATE FUNCTION statement,<br />

which is very similar <strong>to</strong> the <strong>on</strong>e found in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>, as show in Table 6.24.<br />

Table 6.24: <strong>SQL</strong> Statements <str<strong>on</strong>g>for</str<strong>on</strong>g> Creating Triggers in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong><br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g><br />

CREATE OR REPLACE FUNCTION<br />

[schema.]functi<strong>on</strong>_name<br />

[ ({parameter [IN] datatype [=<br />

default]} [, …]) ]<br />

RETURN scalar_expressi<strong>on</strong><br />

{IS | AS}<br />

variable_declarati<strong>on</strong><br />

BEGIN<br />

statements<br />

RETURN scalar_expressi<strong>on</strong><br />

EXCEPTION<br />

statements<br />

END;<br />

<strong>SQL</strong> <strong>Server</strong><br />

CREATE FUNCTION [owner.]<br />

functi<strong>on</strong>_name<br />

[ ({@parameter [AS] datatype [ =<br />

default ]} [, …]) ]<br />

RETURN scalar_expressi<strong>on</strong><br />

[ AS ]<br />

BEGIN<br />

variable_declarati<strong>on</strong><br />

statements<br />

RETURN scalar_expressi<strong>on</strong><br />

END<br />

S<strong>to</strong>red Procedures<br />

<strong>SQL</strong> <strong>Server</strong> has s<strong>to</strong>red procedures that closely resemble <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>. These s<strong>to</strong>red<br />

procedures provide the capability <strong>to</strong> pass multiple parameters back <strong>to</strong> the calling<br />

envir<strong>on</strong>ment. Another advantage of s<strong>to</strong>red procedures is that they can per<str<strong>on</strong>g>for</str<strong>on</strong>g>m acti<strong>on</strong>s in<br />

the database without being tied <strong>to</strong> a <strong>SQL</strong> statement.<br />

S<strong>to</strong>red procedures can be created using the Create S<strong>to</strong>red Procedure Wizard, Enterprise<br />

Manager, or T-<strong>SQL</strong>.<br />

To create a view using the Create S<strong>to</strong>red Procedure Wizard, follow these<br />

steps:<br />

1. Expand a server group and then expand the server in which <strong>to</strong> create the view.<br />

2. On the Tools menu, click Wizards.<br />

3. Expand Database.<br />

4. Double-click Create S<strong>to</strong>red Procedure Wizard.<br />

5. Complete the<br />

steps in the wizard.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 129<br />

To create a s<strong>to</strong>red procedure using Enterprise Manager, follow these steps:<br />

1. Expand a server group, and then expand a server.<br />

2. Expand Databases, and then expand the database in which <strong>to</strong> create the s<strong>to</strong>red<br />

procedure.<br />

3. Right-click S<strong>to</strong>red Procedures and select New S<strong>to</strong>red Procedure.<br />

4. In the Text box, enter the text of the s<strong>to</strong>red procedure. Use TAB <strong>to</strong> indent the text<br />

within.<br />

5. To check the syntax, click Check Syntax and OK <strong>to</strong> create.<br />

To create a s<strong>to</strong>red procedure using T-<strong>SQL</strong>, use the following syntax:<br />

Both <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong> offer the CREATE PROCEDURE statement, which is very<br />

similar in structure and is shown in Table 6.25.<br />

Table 6.25: <strong>SQL</strong> Statements <str<strong>on</strong>g>for</str<strong>on</strong>g> Creating Procedures in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong><br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g><br />

CREATE OR REPLACE PROCEDURE<br />

[schema.]procedure_name<br />

[ ({parameter [IN|OUT|IN OUT]<br />

datatype [= default]} [, …]) ]<br />

{IS | AS}<br />

variable_declarati<strong>on</strong><br />

BEGIN<br />

statements<br />

EXCEPTION<br />

statements<br />

END;<br />

<strong>SQL</strong> <strong>Server</strong><br />

CREATE PROCEDURE [owner.]<br />

procedure_name<br />

[ ({@parameter [AS] datatype [ =<br />

default ] [OUTPUT]} [, …]) ]<br />

AS<br />

BEGIN<br />

variable_declarati<strong>on</strong><br />

statements<br />

END<br />

Packages<br />

One of the main differentia<strong>to</strong>rs between s<strong>to</strong>red procedures and packages is the capability<br />

<strong>to</strong> declare variables in the package header that act as global variables. <strong>SQL</strong> <strong>Server</strong> does<br />

not have packages, and these have <strong>to</strong> be replaced with s<strong>to</strong>red procedures. However,<br />

<strong>SQL</strong> <strong>Server</strong> allows the nesting of procedures, and this capability can be used <strong>to</strong> simulate<br />

the structure of packages by nesting functi<strong>on</strong>s and procedures. Variables can be made<br />

available <strong>to</strong> all the nested functi<strong>on</strong>s and procedures by declaring them in the outmost (or<br />

main) procedure. This, however, does not provide database-wide accessibility <strong>to</strong> these<br />

variables, a shortcoming which has <strong>to</strong> be accommodated by migrating the global variable<br />

from the package <strong>to</strong> the applicati<strong>on</strong> code.<br />

<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g>s <str<strong>on</strong>g>for</str<strong>on</strong>g> Objects not Found in <strong>SQL</strong> <strong>Server</strong><br />

Some <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> objects, such as syn<strong>on</strong>yms and sequences, are widely used in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g><br />

applicati<strong>on</strong>s. However, there is no equivalent object with similar functi<strong>on</strong>ality in<br />

<strong>SQL</strong> <strong>Server</strong>. Finding soluti<strong>on</strong>s <strong>to</strong> implement the logic and functi<strong>on</strong>ality around these<br />

objects in <strong>SQL</strong> <strong>Server</strong> is critical <strong>to</strong> the migrati<strong>on</strong>.<br />

Syn<strong>on</strong>yms<br />

In <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>, syn<strong>on</strong>yms are aliases <str<strong>on</strong>g>for</str<strong>on</strong>g> tables, views, sequences, functi<strong>on</strong>s, procedures, and<br />

packages. The primary purpose of using syn<strong>on</strong>yms is <str<strong>on</strong>g>for</str<strong>on</strong>g> locati<strong>on</strong> transparency<br />

and<br />

naming transparency. By creating public syn<strong>on</strong>yms or private syn<strong>on</strong>yms (<str<strong>on</strong>g>for</str<strong>on</strong>g> each user),


130 Developing: Databases — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> Schemas<br />

applicati<strong>on</strong>s can be written without schema qualificati<strong>on</strong> in the <strong>SQL</strong> code because the<br />

qualifier is defined in the syn<strong>on</strong>yms. The original object names can also be hidden.<br />

Syn<strong>on</strong>yms <str<strong>on</strong>g>for</str<strong>on</strong>g> tables are more easily migrated by substituting them with views. Views<br />

provide the required locati<strong>on</strong> and naming transparency as well. For example, a private<br />

syn<strong>on</strong>ym, CLINTB.DEPT, which c<strong>on</strong>nects <strong>to</strong> the table HR.DEPARTMENT, can be<br />

r eplaced in <strong>SQL</strong> <strong>Server</strong> by a VIEW as follows:<br />

CREATE VIEW CLINTB.DEPT AS SELECT * FROM HR.DEPARTMENT<br />

One of the known drawbacks when creating SELECT * views in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> is that any<br />

changes that are made <strong>to</strong> the base table definiti<strong>on</strong> in terms of adding, dropping, and<br />

renaming columns are not au<strong>to</strong>matically reflected in the view definiti<strong>on</strong>. This is because<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> c<strong>on</strong>verts the query piece:<br />

SELECT * FROM table_name<br />

in<strong>to</strong><br />

S ELECT column_name [, …] FROM table_name<br />

C<strong>on</strong>sequently, when a column is added <strong>to</strong> the base table, the view definiti<strong>on</strong> does not<br />

change. Dropping or renaming a column invalidates the view. However, <strong>SQL</strong> <strong>Server</strong> does<br />

not have this problem because the view DDL is s<strong>to</strong>red as it was written, that is, SELECT<br />

* FROM table_name.<br />

I t is not possible <strong>to</strong> find an object-based soluti<strong>on</strong> <str<strong>on</strong>g>for</str<strong>on</strong>g> syn<strong>on</strong>yms c<strong>on</strong>necting <strong>to</strong> other types<br />

of objects, such as procedures and sequences. The simplest soluti<strong>on</strong> is <strong>to</strong> qualify the<br />

object schema or owner in the applicati<strong>on</strong> rather than resolve it at the database login<br />

level.<br />

The inherent quality of <strong>SQL</strong> <strong>Server</strong> in resoluti<strong>on</strong> of objects can be used <str<strong>on</strong>g>for</str<strong>on</strong>g> providing a<br />

soluti<strong>on</strong>. Syn<strong>on</strong>yms are usually employed in situati<strong>on</strong>s where there are multiple versi<strong>on</strong>s<br />

of the same applicati<strong>on</strong> being used <strong>to</strong> support different clients, with each client having its<br />

own schema. The schema that will be used is driven by the user login and not the<br />

applicati<strong>on</strong> itself. This can be achieved in <strong>SQL</strong> <strong>Server</strong> by setting the default database <str<strong>on</strong>g>for</str<strong>on</strong>g><br />

a user account and giving the login the appropriate privileges at the object level. This<br />

scheme will work as l<strong>on</strong>g as all the objects that will be accessed are in a single database<br />

and it is set as the default database <str<strong>on</strong>g>for</str<strong>on</strong>g> the user. For more in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> about these<br />

issues, refer <strong>to</strong> Chapter 7, "Developing: Databases — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> the Database Users."<br />

Sequences<br />

In <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>, sequences are aut<strong>on</strong>omous schema objects that can be used <strong>to</strong> generate<br />

numbers that are in sequential order. In applicati<strong>on</strong>s, sequences are comm<strong>on</strong>ly used <strong>to</strong><br />

produce artificial keys <str<strong>on</strong>g>for</str<strong>on</strong>g> tables which do not have a natural key, or the natural key is <strong>to</strong>o<br />

l<strong>on</strong>g. <strong>SQL</strong> <strong>Server</strong> does not have an equivalent <str<strong>on</strong>g>for</str<strong>on</strong>g> sequences. However, a <strong>SQL</strong> <strong>Server</strong><br />

table can have columns that are defined with the IDENTITY property, which simulates the<br />

behavior of <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> sequences. The IDENTITY column is an <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> sequence and table<br />

column rolled in<strong>to</strong> <strong>on</strong>e, that is, the column definiti<strong>on</strong> includes the sequence definiti<strong>on</strong>.<br />

The syntax of the <strong>SQL</strong> <strong>Server</strong> IDENTITY property is<br />

IDENTITY [(seed, increment)]<br />

The <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> start with is replaced by the <strong>SQL</strong> <strong>Server</strong> seed.<br />

The <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> increment by is equivalent <strong>to</strong> the <strong>SQL</strong> <strong>Server</strong> increment<br />

The <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> maxvalue is provided by the <strong>SQL</strong> <strong>Server</strong> column data type.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 131<br />

Table 6.26 shows the implementati<strong>on</strong> of the IDENTITY property feature in <strong>SQL</strong> <strong>Server</strong><br />

and what would be the equivalent in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>.<br />

Table 6.26: Implementati<strong>on</strong> of <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Sequence in <strong>SQL</strong> <strong>Server</strong><br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g><br />

CREATE SEQUENCE sequence_name<br />

START WITH 1 INCREMENT BY 1<br />

CREATE TABLE table_name (column1<br />

NUMBER DEFAULT<br />

sequence_name.NEXTVAl,<br />

column2 …<br />

);<br />

INSERT INTO table_name (column2, …)<br />

VALUES ( … )<br />

CREATE TABLE table_name (column1<br />

NUMBER,<br />

column2 …<br />

);<br />

INSERT INTO table_name (column1,<br />

column2, …) VALUES<br />

(sequence_name.NEXTVAL, … )<br />

<strong>SQL</strong> <strong>Server</strong><br />

-<br />

CREATE TA BLE table_name (column1<br />

NUMBER IDENTITY(1,1),<br />

column2 …<br />

);<br />

INSERT INTO table_name (column2, …)<br />

VALUES ( … )<br />

CREATE TABLE table_name (column1<br />

NUMBER IDENTITY(1,1),<br />

column2 …<br />

);<br />

INSERT INTO table_name (column2, …)<br />

VALUES ( … )<br />

One of the advantages of sequences being independent objects is that they can be used<br />

<strong>to</strong> supply a unique identifier across multiple tables. This property of <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> sequences is<br />

not inherent in <strong>SQL</strong> <strong>Server</strong>’s IDENTITY property. If an identifier is required <strong>to</strong> be unique<br />

across tables (or even databases across the globe), use the uniqueidentifier data type,<br />

which can be populated using the NEWID() functi<strong>on</strong>. The IDENTITY column can <strong>on</strong>ly<br />

handle unique values and hence it cannot support the cycle feature of <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> sequence.<br />

A maximum value also cannot be set but can be en<str<strong>on</strong>g>for</str<strong>on</strong>g>ced by choosing an appropriate<br />

sized data type <str<strong>on</strong>g>for</str<strong>on</strong>g> the IDENTITY column.<br />

Note There is no sufficient in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> inside the <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> database <strong>to</strong> figure out how<br />

and where a sequence is used. Hence the applicati<strong>on</strong>'s documentati<strong>on</strong>, code, or<br />

developer will have <strong>to</strong> be c<strong>on</strong>sulted <strong>to</strong> learn which sequence is used <strong>to</strong> populate a<br />

column. This in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> is then used <strong>to</strong> define an IDENTITY column in that table.<br />

Database Links<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> database links are used <strong>to</strong> <str<strong>on</strong>g>for</str<strong>on</strong>g>m a bridge between databases (instances). Remote<br />

and distributed transacti<strong>on</strong>s can be executed against the remote database using the<br />

database link. <strong>SQL</strong> <strong>Server</strong><br />

provides similar functi<strong>on</strong>ality under the linked server.


132 Developing: Databases — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> Schemas<br />

Table 6.27 compares some of the characteristics of database links in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and<br />

<strong>SQL</strong> <strong>Server</strong>.<br />

Table 6.27: Comparis<strong>on</strong> of Database Links in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong><br />

Attribute<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g><br />

<strong>SQL</strong> <strong>Server</strong><br />

Link Types Public and Private Public<br />

Database Types Homogeneous Homogeneous and<br />

Heterogeneous<br />

CREATE [ PUBLIC ] DATABASE<br />

LINK [ CONNECT TO {<br />

sp_addlinkedserver [ @server<br />

= ] 'server'<br />

CURRENT_USER | user [ , [ @srvproduct = ]<br />

IDENTIFIED BY password } ] 'product_name' ]<br />

USING 'c<strong>on</strong>nect_string'<br />

[ , [ @provider = ]<br />

'provider_name' ]<br />

[ , [ @datasrc = ]<br />

'data_source' ]<br />

[ , [ @locati<strong>on</strong> = ] 'locati<strong>on</strong>' ]<br />

[ , [ @provstr = ]<br />

'provider_string' ]<br />

[ , [ @catalog = ] 'catalog'<br />

Note The provider_name <str<strong>on</strong>g>for</str<strong>on</strong>g> an OLE DB-based c<strong>on</strong>necti<strong>on</strong> <strong>to</strong> another <strong>SQL</strong> <strong>Server</strong> is<br />

'<strong>SQL</strong>OLEDB'.<br />

The following example shows the use of sp_addlinkedserver <strong>to</strong> create a linked server <strong>to</strong><br />

c<strong>on</strong>nect <strong>to</strong> another database <str<strong>on</strong>g>for</str<strong>on</strong>g> executing distributed queries:<br />

sp_addlinkedserver<br />

@server='CORP2',<br />

@srvproduct='',<br />

@provider='<strong>SQL</strong>OLEDB',<br />

@datasrc='SHUTTLE\CORP2'<br />

Sample Schema Object Migrati<strong>on</strong><br />

The following example illustrates the schema owner and schema objects migrati<strong>on</strong> task<br />

of the database migrati<strong>on</strong>. The HR schema has been used in this example.<br />

1. Create the <strong>SQL</strong> <strong>Server</strong> login account (database authenticated).<br />

The following commands create a database-authenticated login with name HR.<br />

Use MASTER<br />

EXEC sp_addlogin<br />

@loginame='HR',<br />

@passwd='HR',<br />

@defdb='HRDATA'<br />

2. Create user account in the database.<br />

The following commands create a user account <str<strong>on</strong>g>for</str<strong>on</strong>g> the HR login in the HRDATA<br />

database in which objects will be created.<br />

Use HRDATA<br />

EXEC sp_grantdbaccess<br />

@loginame='HR',


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 133<br />

@name_in_db='HR'<br />

3. Gra nt privileges <strong>to</strong> create objects in the database.<br />

Priv ileges can be granted <strong>to</strong> the schema owner <strong>to</strong> create objects in a database<br />

using either the CREATE permissi<strong>on</strong>s or the db_owner fixed database role.<br />

a.<br />

b.<br />

Grant complete authority <strong>on</strong> the database.<br />

The following command can be used <strong>to</strong> grant the db_owner role:<br />

EXEC sp_addrolemember<br />

@rolename='db_owner',<br />

@membername='HR'<br />

Grant privileges <strong>to</strong> create objects <strong>on</strong>ly.<br />

The following commands can be executed <strong>to</strong> <strong>on</strong>ly grant permissi<strong>on</strong> <strong>to</strong> create<br />

objects:<br />

GRANT CREATE FUNCTION TO HR<br />

GRANT CREATE PROCEDURE TO HR<br />

GRANT CREATE TABLE TO HR<br />

GRANT CREATE VIEW TO HR<br />

4. Create sequences.<br />

While sequences cannot be migrated <strong>to</strong> <strong>SQL</strong> <strong>Server</strong>, in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> about the<br />

seq uences in the <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> database should be extracted first. Because sequences<br />

are migrated <strong>to</strong> IDENTITY columns in tables, the in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> about sequences is<br />

required <strong>to</strong> appropriately define tables (in the next step).<br />

The following command extracts the required in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <strong>on</strong> sequences.<br />

SELECT sequence_name, min_value, max_value, increment_by<br />

FROM dba_sequences<br />

WHERE sequence_owner = 'HR'<br />

The following output is obtained:<br />

SEQUENCE_NAME MIN_VALUE MAX_VALUE INCREMENT_BY<br />

DEPARTMENTS_SEQ 1 9990 10<br />

EMPLOYEES_SEQ 1 999999999999999999999999999 1<br />

LOCATIONS_SEQ 1 9900 100<br />

The three sequences in the HR schema are assumed <strong>to</strong> be used <strong>to</strong> populate the<br />

columns DEPARTMENTS.DEPARTMENT_ID, EMPLOYEES.EMPLOYEE_ID and<br />

LOCATIONS.LOCATION_ID, respectively.<br />

5. Create tables.<br />

There are two opti<strong>on</strong>s <str<strong>on</strong>g>for</str<strong>on</strong>g> how <strong>to</strong> migrate tables. Opti<strong>on</strong> <strong>on</strong>e is <strong>to</strong> create tables in a<br />

specific order based <strong>on</strong> the <str<strong>on</strong>g>for</str<strong>on</strong>g>eign key c<strong>on</strong>straints (parent tables first). Opti<strong>on</strong> two<br />

is <strong>to</strong> create tables in any order, leaving out the <str<strong>on</strong>g>for</str<strong>on</strong>g>eign key c<strong>on</strong>straints and then<br />

adding them after all the tables have been created.<br />

a. Obtain a list of tables.<br />

If opti<strong>on</strong> <strong>on</strong>e is followed, the dependenci es between tables and the right order<br />

in which <strong>to</strong> create the tables is required. There are several scripts available<br />

(mostly PL/<strong>SQL</strong>-based) <strong>to</strong> produce such a list. Tables without any<br />

dependencies <str<strong>on</strong>g>for</str<strong>on</strong>g>m the first level, and other levels are <str<strong>on</strong>g>for</str<strong>on</strong>g>med based <strong>on</strong> the<br />

nesting of the dependencies.<br />

Note N<strong>on</strong>e of the available scripts will work when there are interdependencies<br />

between tables that <str<strong>on</strong>g>for</str<strong>on</strong>g>m a closed loop. The following script shows such<br />

circular dependencies that<br />

make these scripts not viable.


134 Developing: Databases — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> Schemas<br />

SELECT table_name parent_table_name, NULL child_table_name<br />

FROM dba_tables ut<br />

WHERE owner = 'HR'<br />

AND NOT EXISTS (SELECT 'x'<br />

FROM user_c<strong>on</strong>straints uc<br />

WHERE c<strong>on</strong>straint_type = 'R'<br />

AND ut.table_name = uc.table_name)<br />

UNION ALL<br />

SELECT p.table_name parent_table_name,<br />

c.table_name child_table_name<br />

FROM dba_c<strong>on</strong>straints p, dba_c<strong>on</strong>straints c<br />

WHERE p.owner = c.owner<br />

AND p.owner = 'HR'<br />

AND p.c<strong>on</strong>straint_type IN ('P','U')<br />

AND c.c<strong>on</strong>straint_type = 'R'<br />

AND p.c<strong>on</strong>straint_name = c.r_c<strong>on</strong>straint_name<br />

Note In the following output there is a parent-child relati<strong>on</strong>ship between<br />

EMPLOYEES and DEPARTMENTS in both directi<strong>on</strong>s that creates the loop.<br />

PARENT_TABLE_NAME CHILD_TABLE_NAME<br />

JOBS<br />

REGIONS<br />

REGIONS<br />

COUNTRIES<br />

LOCATIONS<br />

DEPARTMENTS<br />

EMPLOYEES<br />

DEPARTMENTS<br />

DEPARTMENTS EMPLOYEES<br />

JOBS<br />

EMPLOYEES<br />

EMPLOYEES<br />

EMPLOYEES<br />

JOBS<br />

JOB_HISTORY<br />

EMPLOYEES<br />

JOB_HISTORY<br />

DEPARTMENTS JOB_HISTORY<br />

COUNTRIES<br />

LOCATIONS<br />

To implement opti<strong>on</strong> two, first obtain a list of all tables that need <strong>to</strong> be migrated<br />

using the following command:<br />

SELECT table_name, tablespace_name, iot_type<br />

FROM dba_tables<br />

WHERE owner = 'HR'<br />

The output obtained is:<br />

TABLE_NAME<br />

COUNTRIES<br />

TABLESPACE_NAME<br />

IOT_TYPE<br />

IOT<br />

DEPARTMENTS EXAMPLE<br />

EMPLOYEES EXAMPLE<br />

JOBS<br />

EXAMPLE<br />

JOB_HISTORY EXAMPLE<br />

LOCATIONS EXAMPLE<br />

REGIONS EXAMPLE


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 135<br />

b.<br />

Extract DDL al<strong>on</strong>g with c<strong>on</strong>straints.<br />

There are several scripts and <strong>to</strong>ols that<br />

table object.<br />

can be used <strong>to</strong> extract the DDL <str<strong>on</strong>g>for</str<strong>on</strong>g> the<br />

For an <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> 9i database, the <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>-supplied package DBMS_METADATA<br />

can be used. First, execute the following in <strong>SQL</strong>*Plus <strong>to</strong> define the output style.<br />

set pagesize 0<br />

set l<strong>on</strong>g 10000<br />

EXECUTE<br />

DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM,<br />

'STORAGE', FALSE);<br />

EXECUTE DBMS_METADATA.SET_TRANSFORM_PARAM<br />

(DBMS_METADATA.SESSION_TRANSFORM, 'TABLESPACE', TRUE);<br />

EXECUTE DBMS_METADATA.SET_TRANSFORM_PARAM<br />

(DBMS_METADATA.SESSION_TRANSFORM, '<strong>SQL</strong>TERMINATOR', TRUE);<br />

EXECUTE DBMS_METADATA.SET_TRANSFORM_PARAM<br />

(DBMS_METADATA.SESSION_TRANSFORM, 'CONSTRAINTS', TRUE);<br />

EXECUTE DBMS_METADATA.SET_TRANSFORM_PARAM<br />

(DBMS_METADATA.SESSION_TRANSFORM, 'REF_CONSTRAINTS', TRUE);<br />

EXECUTE DBMS_METADATA.SET_TRANSFORM_PARAM<br />

(DBMS_METADATA.SESSION_TRANSFORM, 'CONSTRAINTS_AS_ALTER', TRUE);<br />

Then execute DBMS_METADATA.get_ddl <str<strong>on</strong>g>for</str<strong>on</strong>g> each of the tables. The following<br />

two examples show how <strong>to</strong> extract the DDL <str<strong>on</strong>g>for</str<strong>on</strong>g> entire tables using this<br />

procedure:<br />

SELECT dbms_metadata.get_ddl('TABLE', 'COUNTRIES', 'HR')<br />

FROM DUAL;<br />

The output is as follows:<br />

CREATE TABLE "HR"."COUNTRIES"<br />

("COUNTRY_ID" CHAR(2) CONSTRAINT "COUNTRY_ID_NN" NOT NULL ENABLE,<br />

"COUNTRY_NAME" VARCHAR2(40),<br />

"REGION_ID" NUMBER,<br />

CONSTRAINT "COUNTRY_C_ID_PK" PRIMARY KEY ("COUNTRY_ID") ENABLE<br />

) ORGANIZATION INDEX<br />

NOCOMPRESS PCTFREE 10 INITRANS 2 MAXTRANS 255 LOGGING<br />

TABLESPACE "EXAMPLE"<br />

PCTTHRESHOLD 50;<br />

ALTER TABLE "HR"."COUNTRIES" ADD CONSTRAINT<br />

"COUNTR_REG_FK" FOREIGN KEY ("REGION_ID")<br />

REFERENCES "HR"."REGIONS" ("REGION_ID") ENABLE;<br />

Execute the following command <strong>to</strong> obtain the definiti<strong>on</strong> of the LOCATIONS<br />

table.<br />

SELECT dbms_metadata.get_ddl('TABLE', 'LOCATIONS', 'HR')<br />

FROM DUAL;<br />

The output returned is:<br />

CREATE TABLE "HR"."LOCATIONS"<br />

("LOCATION_ID" NUMBER(4,0),<br />

"STREET_ADDRESS" VARCHAR2(40),<br />

"POSTAL_CODE" VARCHAR2(12),<br />

"CITY" VARCHAR2(30) CONSTRAINT "LOC_CITY_NN" NOT NULL ENABLE,<br />

"ST ATE_PROVINCE"<br />

VARCHAR2(25),<br />

"COUNTRY_ID" CHAR(2)<br />

) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING<br />

TABLESPACE "EXAMPLE" ;


136 Developing: Databases — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> Schemas<br />

CREATE UNIQUE INDEX "HR"."LOC_ID_PK" ON<br />

"HR"."LOCATIONS" ("LOCATION_ID")<br />

PCTFREE 10 INITRANS 2 MAXTRANS 255 NOLOGGING<br />

TABLESPACE "INDX" ;<br />

ALTER TABLE "HR"."LOCATIONS" ADD CONSTRAINT<br />

"LOC_ID_PK" PRIMARY KEY ("LOCATION_ID")<br />

USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 NOLOGGING<br />

TABLESPACE "INDX" ENABLE;<br />

ALTER TABLE "HR"."LOCATIONS" ADD CONSTRAINT<br />

"LOC_C_ID_FK" FOREIGN KEY ("COUNTRY_ID")<br />

REFERENCES "HR"."COUNTRIES" ("COUNTRY_ID") ENABLE;<br />

c. C<strong>on</strong>vert the extracted <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> DDL <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> syntax.<br />

In this step, the table DDL is c<strong>on</strong>verted al<strong>on</strong>g with c<strong>on</strong>straint and index<br />

definiti<strong>on</strong>s. Foreign key c<strong>on</strong>straints are handled separately in the next step.<br />

Create clustered indexes be<str<strong>on</strong>g>for</str<strong>on</strong>g>e creating any n<strong>on</strong>-clustered indexes. If<br />

clustered indexes are planned <str<strong>on</strong>g>for</str<strong>on</strong>g> a table, defer creati<strong>on</strong> of n<strong>on</strong>clustered<br />

indexes (as part of PRIMARY KEY or UNIQUE c<strong>on</strong>straint definiti<strong>on</strong>) during the<br />

table creati<strong>on</strong> in this step.<br />

The first table in the example, COUNTRIES, is an index-organized table. For<br />

<strong>SQL</strong> <strong>Server</strong>, it is c<strong>on</strong>verted in<strong>to</strong> a heap with a clustered index <strong>on</strong> the primary<br />

key, COUNTRY_ID.<br />

Note In <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>, there is a single datatype of the number variety which is<br />

c<strong>on</strong>strained with appropriate scale. While c<strong>on</strong>verting <strong>to</strong> <strong>SQL</strong> <strong>Server</strong>, the data<br />

type which is closest in scale needs <strong>to</strong> be used, as has been dem<strong>on</strong>strated in<br />

the example.<br />

The following commands are used <strong>to</strong> create the COUNTRIES and<br />

LOCATIONS tables respectively.<br />

CREATE TABLE HR.COUNTRIES<br />

(COUNTRY_ID CHAR(2) CONSTRAINT NN_COUNTRY_ID NOT NULL,<br />

COUNTRY_NAME VARCHAR(40),<br />

REGION_ID NUMERIC,<br />

CONSTRAINT PK_COUNTRY_C_ID PRIMARY KEY CLUSTERED (COUNTRY_ID)<br />

ON HR_INDX<br />

)<br />

CREATE TABLE HR.LOCATIONS<br />

(LOCATION_ID SMALLINT NOT NULL,<br />

STREET_ADDRESS VARCHAR (40),<br />

POSTAL_CODE VARCHAR(12),<br />

CITY VARCHAR(30) CONSTRAINT NN_LOC_CITY NOT NULL,<br />

STATE_PROVINCE VARCHAR(25),<br />

COUNTRY_ID CHAR(2)<br />

)<br />

ALTER TABLE HR. LOCATIONS ADD CONSTRAINT<br />

PK__ID PRIMARY KEY NONCLUSTERED (LOCATION_ID)<br />

ON HR_INDX


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 137<br />

6.<br />

d.<br />

Create the <str<strong>on</strong>g>for</str<strong>on</strong>g>eign key c<strong>on</strong>straints.<br />

After all the tables have been created, the <str<strong>on</strong>g>for</str<strong>on</strong>g>eign key c<strong>on</strong>straints can be<br />

created in any order.<br />

The following commands create <str<strong>on</strong>g>for</str<strong>on</strong>g>eign keys <strong>on</strong> the COUNTRIES and<br />

LOCATIONS tables.<br />

ALTER TABLE HR.COUNTRIES ADD CONSTRAINT<br />

FK_COUNTR_REG FOREIGN KEY (REGION_ID)<br />

REFERENCES HR.REGIONS (REGION_ID);<br />

ALTER TABLE HR.LOCATIONS ADD CONSTRAINT<br />

FK_LOC_C_ID FOREIGN KEY (COUNTRY_ID)<br />

REFERENCES HR.COUNTRIES (COUNTRY_ID);<br />

e. Extract and migrate the table comments.<br />

The following command can be used <strong>to</strong> extract comments in tables in the HR<br />

schema.<br />

SELECT table_name, comments<br />

FROM dba_tab_comments<br />

WHERE owner = 'HR'<br />

AND comments IS NOT NULL<br />

The output returned c<strong>on</strong>tains the comments <str<strong>on</strong>g>for</str<strong>on</strong>g> the tables in the HR schema,<br />

such as COUNTRIES, DEPARTMENTS, EMPLOYEES, JOBS,<br />

JOB_HISTORY and LOCATIONS. The output can then be copied in<strong>to</strong> the<br />

statements <str<strong>on</strong>g>for</str<strong>on</strong>g> adding comments <strong>to</strong> tables in <strong>SQL</strong> <strong>Server</strong>.<br />

The following is an example of the use of the sp_addextendedproperty<br />

procedure <strong>to</strong> add a comment <strong>on</strong> the COUNTRIES table.<br />

sp_addextendedproperty 'comment', 'country table. C<strong>on</strong>tains 25 rows.<br />

References with locati<strong>on</strong>s table.', 'user', HR, 'table', countries<br />

f. Extract and migrate the column comments:<br />

SELECT table_name, column_name, comments<br />

FROM dba_col_comments<br />

WHERE owner = 'HR'<br />

AND comments IS NOT NULL<br />

The output c<strong>on</strong>tains the column level comments.<br />

The following is an example of the use of the sp_addextendedproperty<br />

procedure <strong>to</strong> add a comment <strong>on</strong> the REGION_ID column of the COUNTRIES<br />

table.<br />

sp_addextendedproperty 'comment', 'Regi<strong>on</strong> ID <str<strong>on</strong>g>for</str<strong>on</strong>g> the country. Foreign<br />

key <strong>to</strong> regi<strong>on</strong>_id column in the departments table.' , 'user', hr,<br />

'table', countries, 'column', regi<strong>on</strong>_id<br />

Create triggers.<br />

This step dem<strong>on</strong>strates how <strong>to</strong> migrate the table triggers from <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>to</strong><br />

<strong>SQL</strong> <strong>Server</strong>. The logic (code) that is embedded in the triggers is not discussed<br />

here. For more in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong>, refer <strong>to</strong> the "<str<strong>on</strong>g>Migrating</str<strong>on</strong>g> the Data Access" secti<strong>on</strong> in<br />

Chapter 11, "Developing: Databases — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>SQL</strong> and PL/<strong>SQL</strong>."<br />

SELECT table_name, 'CRE ATE TRIGGER ' || descripti<strong>on</strong> header<br />

FROM dba_triggers<br />

WHERE owner = table_owner<br />

AND table_owner = 'HR'<br />

AND base_object_type = 'TABLE'<br />

TABLE_NAME HEADER<br />

EMPLOYEES CREATE TRIGGER secure_employees


138 Developing: Databases — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> Schemas<br />

BEFORE INSERT OR UPDATE OR DELETE ON employees<br />

EMPLOYEES CREATE TRIGGER update_job_his<strong>to</strong>ry<br />

AFTER UPDATE OF job_id, department_id ON employees<br />

FOR EACH ROW<br />

The equivalent syntax <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>SQL</strong> <strong>Server</strong> can be generated with the aid of Table 6.24.<br />

The commands <str<strong>on</strong>g>for</str<strong>on</strong>g> creating the secure_ employees and update_job_his<strong>to</strong>ry<br />

triggers will c<strong>on</strong>vert as:<br />

7.<br />

CREATE TRIGGER secure_employees<br />

ON employees<br />

INSTEAD OF INSERT, UPDATE, DELETE<br />

AS<br />

…<br />

GO<br />

CREATE TRIGGER update_job_his<strong>to</strong>ry<br />

ON employees<br />

AFTER UPDATE<br />

AS<br />

…<br />

GO<br />

IF (UPDATE(job_id) or UPDATE(department_id))<br />

Create indexes.<br />

All indexes related <strong>to</strong> c<strong>on</strong>straints should have been created in Substep 5.b. This<br />

step covers the indexes that are not related <strong>to</strong> any c<strong>on</strong>straints.<br />

The following query can be used <strong>to</strong> retrieve in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <strong>on</strong> indexes in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> that<br />

are not related <strong>to</strong> any c<strong>on</strong>straints. This query will work <strong>on</strong>ly in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> 9i because<br />

the data dicti<strong>on</strong>ary be<str<strong>on</strong>g>for</str<strong>on</strong>g>e this release of <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> does not have the columns used in<br />

this query.<br />

SELECT i.table_name, i.index_name, c.column_name, i.uniqueness,<br />

i.tablespace_name, i.pct_free<br />

FROM dba_indexes i, dba_ind_columns c<br />

WHERE i.table_name = c.table_name<br />

AND i.index_name = c.index_name<br />

AND i.owner = c.index_owner<br />

AND i.owner = 'HR'<br />

AND (i.owner, i.index_name) NOT IN<br />

(SELECT index_owner, index_name<br />

FROM dba_c<strong>on</strong>straints<br />

WHERE owner = 'HR'<br />

AND index_name IS NOT NULL)<br />

ORDER BY i.table_name, i.index_name, c.column_positi<strong>on</strong><br />

The output obtained has been <str<strong>on</strong>g>for</str<strong>on</strong>g>matted as follows:<br />

TABLE_NAME INDEX_NAME<br />

COLUMN_NAME<br />

UNIQUENESS<br />

TABLESPACE_NAME<br />

PCT_FREE<br />

DEPARTMENTSDEPT_LOCATION_IX LOCATION_ID NONUNIQUE<br />

INDX 10<br />

EMPLOYEES EMP_DEPARTMENT_IX<br />

INDX 10<br />

EMPLOYEES EMP-JOB-IX<br />

INDX 10<br />

DEPARTMENT_ID<br />

JOB_ID<br />

NONUNIQUE<br />

NONUNIQUE


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 139<br />

EMPLOYEES EMP_MANAGER_IX MANAGER_ID NONUNIQUE<br />

INDX 10<br />

EMPLOYEES EMP_NAME_IX LAST_NAME NONUNIQUE<br />

INDX 10<br />

EMPLOYEES EMP_NAME_IX<br />

FIRST_NAME<br />

NONUNIQUE<br />

INDX<br />

10<br />

JOB_HISTORYJHIST_ DEPARTMENT_IX DEPARTMENT_ID NONUNIQUE<br />

INDX<br />

10<br />

JOB_HISTORYJHIST_EMPLOYEE_IX EMPLOYEE_ID NONUNIQUE<br />

INDX<br />

10<br />

JOB_HISTORYJHIST_ JOB_IX JOB_ID NONUNIQUE<br />

INDX<br />

10<br />

LOCATIONS LOC_CITY_IX CITY NONUNIQUE<br />

INDX<br />

10<br />

LOCATIONS LOC_COUNTRY_IX COUNTRY_ID NONUNIQUE<br />

INDX<br />

10<br />

LOCATIONS LOC_STATE_PROVINCE_IX STATE_PROVINCE NONUNIQUE<br />

INDX<br />

10<br />

This in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> can be used <strong>to</strong> create indexes in <strong>SQL</strong> <strong>Server</strong> as follows:<br />

CREATE NONCLUSTERED<br />

INDEX hr.dept_locati<strong>on</strong>_ix<br />

ON hr.departments(<br />

locati<strong>on</strong>_id)<br />

WITH FILLFACTOR = 90<br />

ON HR_INDX<br />

CREATE NONCLUSTERED INDEX hr.emp_name_ix<br />

ON hr.employees(last_name, first_name)<br />

WITH FILLFACTOR = 90<br />

ON HR_INDX<br />

Because indexes have been created over several steps, you should verify that an<br />

equivalent index has been created in <strong>SQL</strong> <strong>Server</strong> <str<strong>on</strong>g>for</str<strong>on</strong>g> each index in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>.<br />

In <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>, generate a listing of all indexes using the following command:<br />

8.<br />

SELECT i.table_name, i.index_name,<br />

c.column_name, i.uniqueness, i. tablespace_name,<br />

i.pct_free<br />

FROM dba_indexes i, dba_ind_columns c<br />

WHERE i.table_name = c.table_name<br />

AND i.index_name = c.index_name<br />

AND i.owner = c.index_owner<br />

AND i.owner = 'HR'<br />

ORDER BY i.table_name, i.index_name, c.column_positi<strong>on</strong><br />

In <strong>SQL</strong> <strong>Server</strong>, execute the following command <strong>on</strong> each table with the table name<br />

substituted <str<strong>on</strong>g>for</str<strong>on</strong>g> name <strong>to</strong> retrieve in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <strong>on</strong> the indexes available <str<strong>on</strong>g>for</str<strong>on</strong>g> the table:<br />

sp_helpindex [ @objname = ] 'name'<br />

Create views.<br />

Extract the views and their definiti<strong>on</strong> from <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> using the following command:<br />

SELECT view_name, text<br />

FROM dba_views<br />

WHERE owner = 'HR'<br />

The output provides the view query.


140 Developing: Databases — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> Schemas<br />

The query <str<strong>on</strong>g>for</str<strong>on</strong>g> DEPT is as follows:<br />

select "DEPARTMENT_ID", "DEPARTMENT_NAME", "MANAGER_ID", "LOCATION_D",<br />

"DEPT_LOC"<br />

from hr.departments<br />

The query <str<strong>on</strong>g>for</str<strong>on</strong>g> EMB_DETAILS_VIEW is as follows:<br />

SELECT<br />

e.employee_id,<br />

e.job_id,<br />

e.manager_id,<br />

e.department_ id,<br />

d.locati<strong>on</strong>_id,<br />

l.country_id,<br />

e.first_name,<br />

e.last_name,<br />

e.salary,<br />

e.commissi<strong>on</strong>_pct,<br />

d.department_ name,<br />

j.job_title,<br />

l.city,<br />

l.state_province,<br />

c.country_name,<br />

r.regi<strong>on</strong>_name<br />

FROM<br />

employees e,<br />

departments d,<br />

jobs j,<br />

locati<strong>on</strong>s l,<br />

countries c,<br />

regi<strong>on</strong>s r<br />

WHERE e.department_id = d.department_id<br />

AN D d.locati<strong>on</strong>_id = l.locati<strong>on</strong>_id<br />

AND l.country_id = c.country_id<br />

AN D c.regi<strong>on</strong>_id = r.regi<strong>on</strong>_id<br />

AND j.job_id = e.job_id<br />

WITH READ ONLY<br />

For the view DEPT, the view text shows capitalized names enclosed in double<br />

quotes <str<strong>on</strong>g>for</str<strong>on</strong>g> the column names:<br />

select "DEPARTMENT_ID", "DEPARTMENT_NAME", "MANAGER_ID", "LOCATION_D",<br />

"DEPT_LOC" from hr.departments<br />

This is an indicati<strong>on</strong> that the column names were filled in by the system, and the<br />

original DDL <str<strong>on</strong>g>for</str<strong>on</strong>g> the CREATE VIEW dept is as follows:<br />

select * from hr.departments<br />

As pointed out in the discussi<strong>on</strong> <strong>on</strong> using views instead of syn<strong>on</strong>yms <str<strong>on</strong>g>for</str<strong>on</strong>g> tables,<br />

<strong>SQL</strong> <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<br />

thing when an asterisk (*) is not used. This behavior is shown in the<br />

EMP_DETAILS_VIEW view text. Thus, while c<strong>on</strong>verting the syntax, the DDL may<br />

be changed back <strong>to</strong> an asterisk<br />

instead of specifying every column.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 141<br />

Note The DEPT view was added <strong>to</strong> the HR schema <strong>to</strong> dem<strong>on</strong>strate this point.<br />

The EMP_DETAILS_VIEW can be created under the HR schema using the<br />

following command:<br />

CREATE VIEW hr.EMP_DETAILS_VIEW AS<br />

SELECT<br />

e.employee_id,<br />

e.job_id,<br />

e.manager_id,<br />

e.department_id,<br />

d.locati<strong>on</strong>_id,<br />

l.country_id,<br />

e. first_name,<br />

e.last_name,<br />

e.salary,<br />

e.commissi<strong>on</strong>_pct,<br />

d.department_name,<br />

j.job_title,<br />

l.city,<br />

l.state_province,<br />

c.country_name,<br />

r.regi<strong>on</strong>_name<br />

FROM hr.employees e INNER JOIN hr.departments d<br />

ON e.department_id = d.department_id<br />

INNER JOIN hr.locati<strong>on</strong>s l<br />

ON d.locati<strong>on</strong>_id = l.locati<strong>on</strong>_id<br />

INNER JOIN hr.countries c<br />

ON l.country_id = c.country_id<br />

INNER JOIN hr.regi<strong>on</strong>s r<br />

ON c.regi<strong>on</strong>_id = r.regi<strong>on</strong>_id<br />

INNER JOIN hr.jobs j<br />

ON j.job_id = e.job_id;<br />

The WITH READ ONLY clause will have <strong>to</strong> be en<str<strong>on</strong>g>for</str<strong>on</strong>g>ced by ensuring <strong>on</strong>ly SELECT<br />

privilege is given <strong>to</strong> users.<br />

9. Create functi<strong>on</strong>s, s<strong>to</strong>red procedures, and packages.<br />

The following command can be used <strong>to</strong> get a listing of all functi<strong>on</strong>s defined by the<br />

schema owner, HR:<br />

SELECT object_name, object_type<br />

FROM dba_objects<br />

WHERE owner = 'HR'<br />

AND object_type IN ('FUNCTION', 'PROCEDURE', 'PACKAGE', 'PACKAGE BODY')<br />

The output retuned is:<br />

OBJECT_NAME OBJECT_TYPE<br />

ADD_JOB_HISTORY PROCEDURE<br />

SECURE_DML PROCEDURE<br />

The source code of each of these objects can be extracted from the data dicti<strong>on</strong>ary<br />

using the command:


142 Developing: Databases — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> Schemas<br />

SELECT text<br />

FROM dba_source<br />

WHERE owner = 'HR'<br />

AND NAME = 'ADD_JOB_HISTORY'<br />

ORDER BY line<br />

The output is:<br />

TEXT<br />

PROCEDURE add_job_his<strong>to</strong>ry<br />

( p_emp_id job_his<strong>to</strong>ry.employee_id%type<br />

, p_start_date job_his<strong>to</strong>ry.start_date%type<br />

, p_end_date job_his<strong>to</strong>ry.end_date%type<br />

, p_job_id job_his<strong>to</strong>ry.job_id%type<br />

, p_department_id job_his<strong>to</strong>ry.department_id%type<br />

)<br />

IS<br />

BEGIN<br />

INSERT INTO job_his<strong>to</strong>ry (employee_id, start_date,<br />

end_date, job_id, department_id)<br />

VALUES(p_emp_id, p_start_date, p_end_date, p_job_id, p_department_id);<br />

END add_job_his<strong>to</strong>ry;<br />

An overview of the ef<str<strong>on</strong>g>for</str<strong>on</strong>g>t in migrating functi<strong>on</strong>s, s<strong>to</strong>red procedures, and packages<br />

has been given in the "S<strong>to</strong>red Programs" secti<strong>on</strong> of this chapter. For a detailed<br />

discussi<strong>on</strong> of migrating the code, refer <strong>to</strong> the "<str<strong>on</strong>g>Migrating</str<strong>on</strong>g> the Data Access" secti<strong>on</strong><br />

in Chapter 11.<br />

10. Create syn<strong>on</strong>yms.<br />

Syn<strong>on</strong>yms are used with n<strong>on</strong>-schema users <strong>to</strong> provide locati<strong>on</strong> transparency.<br />

Because <strong>SQL</strong> <strong>Server</strong> does not support syn<strong>on</strong>yms, the <strong>SQL</strong> will have <strong>to</strong> be<br />

modified <strong>to</strong> c<strong>on</strong>tain a schema prefix.<br />

Note An <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> schema could potentially have objects or properties that are not in<br />

use. Examples of such objects are disabled c<strong>on</strong>straints, invalid views, invalid<br />

syn<strong>on</strong>yms, invalid functi<strong>on</strong>, invalid procedures, and dropped column (not purged<br />

from table). Although it is not necessary <strong>to</strong> migrate these objects <strong>to</strong> the new<br />

envir<strong>on</strong>ment, certain clients may differ in this regard.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 143<br />

7<br />

Developing: Databases —<br />

<str<strong>on</strong>g>Migrating</str<strong>on</strong>g> the Database Users<br />

Introducti<strong>on</strong> and Goals<br />

Chapter 6, "Developing: Database — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> Schemas," c<strong>on</strong>centrated strictly <strong>on</strong> the<br />

migrati<strong>on</strong> of the schema, its owner, and objects. The other class of database users is the<br />

<strong>on</strong>e that accesses the data in the tables of these schemas. These users do not own any<br />

objects, such as tables or views, but may have some syn<strong>on</strong>yms that may point <strong>to</strong> the<br />

tables and views in the applicati<strong>on</strong> schema. The ef<str<strong>on</strong>g>for</str<strong>on</strong>g>t in migrating these users <strong>to</strong><br />

Microsoft® <strong>SQL</strong> <strong>Server</strong> is in creating the users and reproducing the privileges they<br />

possess in the <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> database. The privileges may be granted <strong>to</strong> the user directly or<br />

through roles. The migrati<strong>on</strong> of roles is also discussed in this chapter.<br />

The steps in migrating the users are:<br />

1. Create the user account.<br />

2. Create roles and grant privileges.<br />

Create User Accounts<br />

A detailed discussi<strong>on</strong> of database accounts, authenticati<strong>on</strong>, and password management<br />

was provided in the "Create the Schema Owner" secti<strong>on</strong> of Chapter 6. The creati<strong>on</strong> of<br />

user accounts does not differ from the creati<strong>on</strong> of schema accounts in any respect. The<br />

difference is in the privileges that they are granted. Figure 7.1 shows the relati<strong>on</strong>ship<br />

between database users, roles, and schema objects.


144 Developing: Databases — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> the Database Users<br />

Figure 7.1<br />

Dependencies in the migrati<strong>on</strong> of users from <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong><br />

The following query can be run in the source <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> database <strong>to</strong> create a list of users that<br />

have privileges <strong>on</strong> any object in a specific schema. The query has been c<strong>on</strong>strained <strong>to</strong><br />

<strong>on</strong>ly a specific schema and its users. This aids in situati<strong>on</strong>s where <strong>on</strong>ly a subset of the<br />

schemas and the related users are migrated from an <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> database.<br />

SELECT grantee<br />

FROM dba_tab_privs<br />

WHERE owner = username<br />

UNION<br />

SELECT grantee<br />

FROM dba_col_privs<br />

WHERE owner = username<br />

The grantee could be a user or a role. As with the case of the schema owner, the<br />

following query can be used <strong>to</strong> retrieve the characteristics of any login.<br />

SELECT du.username,<br />

DECODE(du.password,'EXTERNAL','EXTERNAL','DB') "AUTHENTICATION MODE",<br />

du.default_tablespace, du.temporary_tablespace,<br />

dp.resource_name, dp.limit<br />

FROM dba_users du, dba_profiles dp<br />

WHERE du.profile = dp.profile<br />

AND dp.resource_type = 'PASSWORD'<br />

AND du.username = username<br />

The system s<strong>to</strong>red procedure sp_grantlogin is used <strong>to</strong> create a <strong>SQL</strong> <strong>Server</strong> login <str<strong>on</strong>g>for</str<strong>on</strong>g> a<br />

domain-authenticated account, and sp_addlogin is used <strong>to</strong> create a <strong>SQL</strong> <strong>Server</strong><br />

authenticated account. The procedure sp_grantdbaccess is used <strong>to</strong> create user


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 145<br />

accounts in the individual databases <str<strong>on</strong>g>for</str<strong>on</strong>g> these logins. User accounts should be created in<br />

a database <strong>on</strong>ly if there are objects in the database the user needs <strong>to</strong> access.<br />

Note While migrating <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> accounts, there may be user accounts that are locked.<br />

The <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> DBA of the original envir<strong>on</strong>ment should be c<strong>on</strong>sulted be<str<strong>on</strong>g>for</str<strong>on</strong>g>e making<br />

decisi<strong>on</strong>s <strong>on</strong> whether <strong>to</strong> migrate these accounts.<br />

Create Roles and Grant Privileges<br />

A privilege is permissi<strong>on</strong> (as it is called in <strong>SQL</strong> <strong>Server</strong>) <strong>to</strong> per<str<strong>on</strong>g>for</str<strong>on</strong>g>m work inside the<br />

database. <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong> provide two sets of privileges: system privileges and<br />

object privileges.<br />

Table 7.1 provides terms relating <strong>to</strong> privileges in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong> that can help<br />

avoid any c<strong>on</strong>fusi<strong>on</strong> during a migrati<strong>on</strong>.<br />

Table 7.1: Privilege Terms Used in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong><br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Terminology<br />

Privilege<br />

System privilege<br />

Object privilege<br />

Predefined role permissi<strong>on</strong> (<str<strong>on</strong>g>for</str<strong>on</strong>g> example,<br />

DBA)<br />

Grantee<br />

<strong>SQL</strong> <strong>Server</strong> Terminology<br />

Permissi<strong>on</strong><br />

Statement permissi<strong>on</strong><br />

Object permissi<strong>on</strong><br />

Implied permissi<strong>on</strong>s (<str<strong>on</strong>g>for</str<strong>on</strong>g> example,<br />

sysadmin)<br />

Security account<br />

While <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> has several object privileges, the <strong>on</strong>es comm<strong>on</strong>ly granted <strong>to</strong> users are<br />

SELECT, INSERT, DELETE, and UPDATE <strong>on</strong> tables and EXECUTE <strong>on</strong> s<strong>to</strong>red<br />

programs. <strong>SQL</strong> <strong>Server</strong> has the same object privileges.<br />

System and object privileges can be granted <strong>to</strong> users either directly or through roles.<br />

<strong>SQL</strong> <strong>Server</strong> also offers the WITH GRANT OPTION clause <str<strong>on</strong>g>for</str<strong>on</strong>g> object privileges.<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong> differ a lot in the system privileges that are available. <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> has<br />

very granular (more than 100) system privileges. <strong>SQL</strong> <strong>Server</strong> system privileges, called<br />

statement permissi<strong>on</strong>s, are restricted <strong>to</strong> the following list:<br />

● BACKUP DATABASE<br />

● BACKUP LOG<br />

● CREATE DATABASE<br />

● CREATE DEFAULT<br />

● CREATE FUNCTION<br />

● CREATE PROCEDURE<br />

● CREATE RULE<br />

● CREATE TABLE<br />

● CREATE VIEW<br />

The rest of the <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> system privileges are bundled in<strong>to</strong> several large fixed roles. For<br />

example, the fixed database role db_datareader is equivalent <strong>to</strong> the SELECT ANY<br />

TABLE system privilege in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>.<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong> offer predefined roles and user-defined roles. The predefined<br />

roles have powerful system and object privileges <strong>on</strong> the data dicti<strong>on</strong>ary and the instance.


146 Developing: Databases — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> the Database Users<br />

The "Roles" <strong>to</strong>pic in <strong>SQL</strong> <strong>Server</strong> Books Online provides a list of fixed server roles and<br />

fixed database roles and their descripti<strong>on</strong>. User-defined roles can be granted system as<br />

well as object privileges.<br />

The privileges <str<strong>on</strong>g>for</str<strong>on</strong>g> administrative users should be revisited when migrating <strong>to</strong> a<br />

<strong>SQL</strong> <strong>Server</strong> database because each database is far more self-c<strong>on</strong>tained with respect <strong>to</strong><br />

administrati<strong>on</strong>. Fixed database roles can be granted privileges <strong>on</strong> a single database<br />

instead of the system-wide powers af<str<strong>on</strong>g>for</str<strong>on</strong>g>ded by the DBA role in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>. A complete<br />

discussi<strong>on</strong> of the system privileges and their equivalents in <strong>SQL</strong> <strong>Server</strong> is bey<strong>on</strong>d the<br />

scope of this guidance. For more in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> about the fixed server roles and fixed<br />

database roles available in <strong>SQL</strong> <strong>Server</strong> and their descripti<strong>on</strong>s, refer <strong>to</strong><br />

http://msdn.microsoft.com/library/default.asp?url=/library/enus/architec/8_ar_da_3xns.asp.<br />

There are two important s<strong>to</strong>red procedures <str<strong>on</strong>g>for</str<strong>on</strong>g> granting system privileges in <strong>SQL</strong> <strong>Server</strong>:<br />

sp_addsrvrolemember can be used <str<strong>on</strong>g>for</str<strong>on</strong>g> granting fixed system roles and<br />

sp_addrolemember can be used <str<strong>on</strong>g>for</str<strong>on</strong>g> granting fixed database roles.<br />

In <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>, roles are available at the instance or server level and can be granted privileges<br />

<strong>on</strong> more than <strong>on</strong>e schema. <strong>SQL</strong> <strong>Server</strong> user-defined roles are local <strong>to</strong> a database and<br />

owned by a user. Hence, when migrating a role from <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong>, a role has <strong>to</strong><br />

be created in each of the databases in which privileges have <strong>to</strong> be granted.<br />

To grant privileges and roles <strong>to</strong> a user, follow these steps:<br />

1. Create role(s) in each of the <strong>SQL</strong> <strong>Server</strong> database(s) that will be used <strong>to</strong> c<strong>on</strong>trol<br />

the permissi<strong>on</strong> given <strong>to</strong> users. A role can be created in a database using the<br />

following commands:<br />

Use database<br />

GO<br />

sp_addrole [ @rolename = ] 'role_name'<br />

[ , [ @ownername = ] 'owner' ]<br />

GO<br />

Where role_name is the name of the role <strong>to</strong> be created and owner is the user who<br />

will own the role (which will normally be the schema owner or a security account<br />

<str<strong>on</strong>g>for</str<strong>on</strong>g> the applicati<strong>on</strong>).<br />

2. System level privileges can either be granted <strong>to</strong> the role created in step 1 or<br />

directly <strong>to</strong> the user. The following statement can be used <str<strong>on</strong>g>for</str<strong>on</strong>g> granting system<br />

privileges <strong>to</strong> roles and users:<br />

GRANT {ALL | system_privilege_name}<br />

TO {user_name | role_name}<br />

Where system_privilege_name is the system privilege <strong>to</strong> be granted, user_name is<br />

the name of the user <strong>to</strong> whom the grant is made, and role_name is the name of the<br />

role through which the privileges will be granted <strong>to</strong> the user.<br />

3. As with system privileges, object privileges can be granted directly <strong>to</strong> the user or<br />

through roles. The following statement can be used <strong>to</strong> grant object privileges <strong>to</strong><br />

users and roles:<br />

GRANT {ALL | object_privilege_name}<br />

ON object_name<br />

TO {user_name | role_name}<br />

[WITH GRANT OPTION]<br />

Where object_privilege_name is the object privilege <strong>to</strong> be granted, object_name is<br />

the object <strong>on</strong> which the privilege is granted, user_name is the name of the user <strong>to</strong><br />

whom the grant is made, and role_name is the name of the role through which the<br />

privileges will be granted <strong>to</strong> the user.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 147<br />

Object privileges can also be granted at the more granular column level instead of<br />

<strong>on</strong> the entire table. The following statement can be used <strong>to</strong> grant privileges <strong>on</strong> <strong>on</strong>e<br />

or more columns of a table:<br />

GRANT {ALL | object_privilege_name}<br />

ON table_name ( column_name [,…] )<br />

TO {user_name | role_name}<br />

[WITH GRANT OPTION]<br />

Where object_privilege_name is the object privilege <strong>to</strong> be granted, table_name is<br />

the table <strong>to</strong> which the column bel<strong>on</strong>gs, column_name is the specific column <strong>on</strong> which<br />

the privilege is being granted, user_name is the name of the user <strong>to</strong> whom the grant<br />

is made, and role_name is the name of the role through which the privileges will be<br />

granted <strong>to</strong> the user.<br />

4. If privileges are being granted through a role, the role can be granted <strong>to</strong> a user<br />

using the following command:<br />

sp_addrolemember [ @rolename = ] 'role_name' ,<br />

[ @membername = ] 'user_name'<br />

Where role_name is the name of the role <strong>to</strong> be granted and user_name is the target<br />

user.<br />

Sample User Migrati<strong>on</strong><br />

When a user is migrated from <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong>, the same security architecture can<br />

be maintained by creating roles and granting privileges in a functi<strong>on</strong>ally equivalent<br />

manner. The difference in the implementati<strong>on</strong> is depicted in Figure 7.1.<br />

Privileges <strong>on</strong> objects in a database are given <strong>to</strong> a local user account at the database<br />

level and do not transgress database boundaries. This implies that, <str<strong>on</strong>g>for</str<strong>on</strong>g> a server or<br />

instance level login, a user account has <strong>to</strong> be created in each of the databases that it<br />

needs privileges in (either directly or through roles). The following steps are a practical<br />

example of how <strong>to</strong> migrate the security architecture of an applicati<strong>on</strong> and its user from<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong>. This example is an extenuati<strong>on</strong> of the migrati<strong>on</strong> of the HR schema<br />

in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> which was started in Chapter 6.<br />

1. Create the user account in <strong>SQL</strong> <strong>Server</strong> <str<strong>on</strong>g>for</str<strong>on</strong>g> each of the <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> users.<br />

In <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>, there is a single user account that is granted privileges <strong>on</strong> various<br />

schemas. In <strong>SQL</strong> <strong>Server</strong>, the single user account translates <strong>to</strong> a two-tier<br />

implementati<strong>on</strong>.<br />

a. Obtain a list of user accounts in the <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> database that have <strong>to</strong> be migrated<br />

<strong>to</strong> <strong>SQL</strong> <strong>Server</strong>. The list can be obtained using the following statement:<br />

SELECT grantee<br />

FROM dba_tab_privs<br />

WHERE owner = 'HR'<br />

UNION<br />

SELECT grantee<br />

FROM dba_col_privs<br />

WHERE owner = 'HR'<br />

where owner is the name of the schema whose security is being migrated.<br />

The following is the output <str<strong>on</strong>g>for</str<strong>on</strong>g> the HR schema.<br />

GRANTEE<br />

OE


148 Developing: Databases — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> the Database Users<br />

b.<br />

Obtain the characteristics of user accounts in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> that were identified in<br />

substep a.<br />

The following statement can be executed <strong>to</strong> gather in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <strong>on</strong> each of the<br />

use rs <strong>to</strong> be migrated:<br />

SELECT du.username,<br />

DECODE(du.password,'EXTERNAL','EXTERNAL','DB')<br />

"AUTHENTICATION MODE",<br />

du.default_tablespace, du.temporary_tablespace,<br />

dp.resource_name, dp.limit<br />

FROM dba_users du, dba_profiles dp<br />

WHERE du.profile = dp.profile<br />

AND dp.resource_type = 'PASSWORD'<br />

AND du.username = 'OE'<br />

where OE is the name of the user that is being migrated.<br />

The privileges granted <strong>to</strong> OE user are:<br />

USERNAME AUTHENTICATION MODE DEFAULT_TABLESPACE<br />

TEMPORARY_TABLESPACE RESOURCE_NAME<br />

LIMIT<br />

OE<br />

DB<br />

EXAMPLE<br />

TEMP<br />

FAILED_LOGIN_ATTEMPTS UNLIMITED<br />

OE<br />

DB<br />

EXAMPLE<br />

TEMP<br />

PASSWORD_LIFE_TIME UNLIMITED<br />

OE<br />

DB<br />

EXAMPLE<br />

TEMP<br />

PASSWORD_REUSE_TIME UNLIMITED<br />

OE<br />

DB<br />

EXAMPLE<br />

TEMP<br />

PASSWORD_REUSE_MAX UNLIMITED<br />

OE<br />

DB<br />

EXAMPLE<br />

TEMP<br />

PASSWORD_VERIFY_FUNCTION NULL<br />

OE<br />

DB<br />

EXAMPLE<br />

TEMP PASSWORD_LOCK_TIME UNLIMITED<br />

OE DB EXAMPLE<br />

TEMP PASSWORD_GRACE_TIME UNLIMITED<br />

c.<br />

Create <strong>SQL</strong> <strong>Server</strong> login accounts that provide access <strong>to</strong> the <strong>SQL</strong> <strong>Server</strong><br />

instance.<br />

Because the <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> account in this example is database-authenticated and<br />

n<strong>on</strong>e of the password features are in use, the <strong>SQL</strong> <strong>Server</strong> login can be created<br />

as a <strong>SQL</strong> <strong>Server</strong>-authenticated login.<br />

The following commands can be executed <strong>to</strong> create the <strong>SQL</strong> <strong>Server</strong> login <str<strong>on</strong>g>for</str<strong>on</strong>g><br />

the user OE with the password OE in the HRDATA database in<strong>to</strong> which the HR<br />

schema's objects are migrated:<br />

Use MASTER<br />

EXEC sp_addlogin<br />

@loginame='OE',<br />

@passwd='OE',<br />

@defdb='HRDATA'<br />

d. Create a user account in each of the databases in which the schema's objects<br />

have been migrated.<br />

The databases in which user accounts have <strong>to</strong> be created depend <strong>on</strong> the<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> schemas <str<strong>on</strong>g>for</str<strong>on</strong>g> which the user has privileges and the <strong>SQL</strong> <strong>Server</strong>


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 149<br />

database <strong>to</strong> which they have been migrated. The following statement can be<br />

used <strong>to</strong> see the schemas <strong>on</strong> which the user OE has been granted privileges.<br />

SELECT owner<br />

FROM dba_tab_privs<br />

WHERE grantee = 'OE'<br />

UNION<br />

SELECT owner<br />

FROM dba_col_privs<br />

WHERE grantee = 'OE'<br />

The output of the statement is as follows:<br />

OWNER<br />

HR<br />

SYS<br />

In Chapter 6, the HR schema was migrated <strong>to</strong> the HRDATA database in<br />

<strong>SQL</strong> <strong>Server</strong>. SYS is the data dicti<strong>on</strong>ary owner, which translates <strong>to</strong> master<br />

database in <strong>SQL</strong> <strong>Server</strong>. However, because the data dicti<strong>on</strong>ary is divided<br />

between the master database and the applicati<strong>on</strong> (user-created) databases,<br />

<str<strong>on</strong>g>for</str<strong>on</strong>g> an applicati<strong>on</strong> user, an account in the master database may not be<br />

necessary and should be created after proper scrutiny of the security<br />

requirements.<br />

The following commands can be used <strong>to</strong> create a user <str<strong>on</strong>g>for</str<strong>on</strong>g> the OE login in the<br />

HRDATA database:<br />

Use HRDATA<br />

EXEC sp_grantdbaccess<br />

@loginame='OE',<br />

@name_in_db='OE'<br />

2.<br />

Create roles through which the privileges will be granted <strong>to</strong> users.<br />

Only those roles that are granted <strong>to</strong> users and schemas that are being migrated<br />

will be created in <strong>SQL</strong> <strong>Server</strong>. Also, the role has <strong>to</strong> be created in each of the<br />

databases with the applicati<strong>on</strong> schema as the owner.<br />

The following statement can be used <strong>to</strong> retrieve the roles that have been granted<br />

<strong>to</strong> the user OE:<br />

SELECT granted_role, admin_opti<strong>on</strong><br />

FROM dba_role_privs<br />

WHERE grantee = 'OE'<br />

The following is the output <str<strong>on</strong>g>for</str<strong>on</strong>g> the OE user:<br />

3.<br />

GRANTED_ROLE<br />

CONNECT<br />

RESOURCE<br />

ADMIN_OPTION<br />

NO<br />

NO<br />

The CONNECT and RESOURCE roles are both system roles. No applicati<strong>on</strong> roles<br />

are in use <str<strong>on</strong>g>for</str<strong>on</strong>g> this schema. Hence all system and object privileges will be granted<br />

directly <strong>to</strong> the user. If you want <strong>to</strong> introduce roles in <strong>SQL</strong> <strong>Server</strong>, it should be<br />

per<str<strong>on</strong>g>for</str<strong>on</strong>g>med at this point.<br />

Grant privileges and/or roles <strong>to</strong> the user.<br />

The roles that were identified in Step 2 are granted here.<br />

The CONNECT role gives the user the capability <strong>to</strong> c<strong>on</strong>nect <strong>to</strong> the <str<strong>on</strong>g>Oracle</str<strong>on</strong>g><br />

database. In <strong>SQL</strong> <strong>Server</strong>, the same privileges are inherently granted when the<br />

login and user accounts are created. The RESOURCE role gives the capability <strong>to</strong><br />

create objects in the database. There<br />

is no role in <strong>SQL</strong> <strong>Server</strong> that provides the


150 Developing: Databases — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> the Database Users<br />

same level of privileges as RESOURCE. As a result, the following privileges are<br />

granted.<br />

GRANT CREATE FUNCTION TO OE<br />

GRANT CREATE PROCEDURE TO OE<br />

GRANT CREATE TABLE TO OE<br />

GRANT CREATE VIEW TO OE<br />

The following statement is used <strong>to</strong> retrieve<br />

the OE user:<br />

system and object privileges granted <strong>to</strong><br />

SELECT do.object_type Lvl, dtp.privilege, dtp.grantable, dtp.owner,<br />

dtp.table_name, NULL column_name<br />

FROM dba_tab_privs dtp, dba_objects do<br />

WHERE dtp.owner = do.owner<br />

AND dtp.table_name = do.object_name<br />

AND grantee = 'OE'<br />

UNION<br />

SELECT 'Column', privilege, grantable, owner, table_name, column_name<br />

FROM dba_col_privs<br />

WHERE grantee = 'OE'<br />

UNION<br />

SELECT 'Sys Priv', privilege, admin_opti<strong>on</strong>, NULL, NULL, NULL<br />

FROM dba_sys_privs<br />

WHERE grantee = 'OE'<br />

ORDER BY privilege, grantable,<br />

owner, table name, column name<br />

The following output is returned <str<strong>on</strong>g>for</str<strong>on</strong>g> the OE user:<br />

LVL PRIVILEGE GRANTABLE<br />

OWNER TABLE_NAME COLUMN_NAME<br />

Sys Priv CREATE SNAPSHOT NO<br />

Sys Priv QUERY REWRITE<br />

NO<br />

Sys Priv UNLIMITED TABLESPACE<br />

NO<br />

Table EXECUTE NO SYS DBMS_STATS<br />

Table REFERENCES NO HR COUNTRIES<br />

Table REFERENCES NO HR EMPLOYEES<br />

Table REFERENCES NO HR LOCATIONS<br />

Table SELECT NO HR COUNTRIES<br />

Table SELECT NO HR DEPARTMENTS<br />

Table SELECT NO HR EMPLOYEES<br />

Table SELECT NO<br />

HR JOBS<br />

Table SELECT NO<br />

HR JOB_HISTORY<br />

Table SELECT NO<br />

HR LOCATIONS<br />

Based <strong>on</strong> the preceding output, grant statements can be devised as follows:<br />

GRANT SELECT ON countries <strong>to</strong> OE;<br />

GRANT SELECT ON departments <strong>to</strong> OE;<br />

GRANT SELECT ON employees <strong>to</strong> OE;<br />

GRANT SELECT ON jobs <strong>to</strong> OE;<br />

GRANT SELECT ON job_his<strong>to</strong>ry <strong>to</strong> OE;<br />

GRANT SELECT ON locati<strong>on</strong>s <strong>to</strong> OE;<br />

<strong>SQL</strong> <strong>Server</strong> does not c<strong>on</strong>tain equivalents <str<strong>on</strong>g>for</str<strong>on</strong>g> CREATE SNAPSHOT, QUERY<br />

REWRITE, REFERENCES, and UNLIMITED TABLESPACE privileges.<br />

The CREATE SNAPSHOT privilege is related <strong>to</strong> replicati<strong>on</strong>, and the QUERY<br />

REWRITE privilege is related<br />

<strong>to</strong> data warehousing, and both are bey<strong>on</strong>d the scope


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 151<br />

of this guide. The REFERENCES privilege is <str<strong>on</strong>g>for</str<strong>on</strong>g> creating <str<strong>on</strong>g>for</str<strong>on</strong>g>eign key c<strong>on</strong>straints<br />

across schemas which are not allowed in <strong>SQL</strong> <strong>Server</strong>. <strong>SQL</strong> <strong>Server</strong> does not<br />

impose s<strong>to</strong>rage quotas <strong>on</strong> schemas; an equivalent <str<strong>on</strong>g>for</str<strong>on</strong>g> REFERENCES is not<br />

needed in <strong>SQL</strong> <strong>Server</strong>.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 153<br />

8<br />

Developing: Databases —<br />

<str<strong>on</strong>g>Migrating</str<strong>on</strong>g> the Data<br />

Introducti<strong>on</strong> and Goals<br />

Migrati<strong>on</strong> of the data represents the final task in the migrati<strong>on</strong> of an <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> database <strong>to</strong><br />

Microsoft® <strong>SQL</strong> <strong>Server</strong>. Even though <strong>SQL</strong> <strong>Server</strong> offers several <strong>to</strong>ols that make the<br />

bulk transfer of data from an external source easier, aspects of the migrati<strong>on</strong> that cannot<br />

be au<strong>to</strong>mated, such as planning the migrati<strong>on</strong> and validating that the data has been<br />

moved completely and without error, should be prioritized.<br />

The data migrati<strong>on</strong> task can be broken up in<strong>to</strong> the following three subtasks:<br />

1. Planning. It is important <strong>to</strong> understand the migrati<strong>on</strong> opti<strong>on</strong>s, evaluate the<br />

characteristics of the source data, and evaluate envir<strong>on</strong>mental and business<br />

c<strong>on</strong>straints.<br />

2. Executi<strong>on</strong>. This subtask involves preparing the database and transferring the<br />

data.<br />

3. Validati<strong>on</strong>. This subtask accounts <str<strong>on</strong>g>for</str<strong>on</strong>g> all the data and verifies data integrity.<br />

Planning the Data Migrati<strong>on</strong><br />

There are two planning prerequisites. Be<str<strong>on</strong>g>for</str<strong>on</strong>g>e making any decisi<strong>on</strong>s, you should first fully<br />

understand the various opti<strong>on</strong>s available <str<strong>on</strong>g>for</str<strong>on</strong>g> transferring the data from an <str<strong>on</strong>g>Oracle</str<strong>on</strong>g><br />

database <strong>to</strong> a <strong>SQL</strong> <strong>Server</strong> database, particularly the advantages and limitati<strong>on</strong>s of each<br />

of the opti<strong>on</strong>s. The sec<strong>on</strong>d prerequisite is <strong>to</strong> document all the fac<strong>to</strong>rs or characteristics of<br />

the original envir<strong>on</strong>ment that could influence your decisi<strong>on</strong> making from the available<br />

opti<strong>on</strong>s. These prerequisites are discussed in detail under the following headings.<br />

Opti<strong>on</strong>s <str<strong>on</strong>g>for</str<strong>on</strong>g> Migrati<strong>on</strong><br />

In an <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> migrati<strong>on</strong> scenario, the two avenues <str<strong>on</strong>g>for</str<strong>on</strong>g> migrating data are <strong>to</strong><br />

either push the data from <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong>, or <strong>to</strong> pull the data from <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> in<strong>to</strong><br />

<strong>SQL</strong> <strong>Server</strong>.<br />

Even though <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> can communicate with heterogeneous databases, the operati<strong>on</strong> is<br />

<strong>on</strong>ly at a transacti<strong>on</strong>al level and cannot be taken advantage of <str<strong>on</strong>g>for</str<strong>on</strong>g> bulk data operati<strong>on</strong>s as<br />

needed in a migrati<strong>on</strong> situati<strong>on</strong>. The <strong>on</strong>ly specialized utility <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> provides <str<strong>on</strong>g>for</str<strong>on</strong>g> exporting<br />

data out of the database is the export utility exp. This utility can <strong>on</strong>ly create dumps in<br />

binary <str<strong>on</strong>g>for</str<strong>on</strong>g>mat that cannot be used <str<strong>on</strong>g>for</str<strong>on</strong>g> importing in<strong>to</strong> a n<strong>on</strong>-<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> database.


154 Developing: Databases — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> the Data<br />

<strong>SQL</strong> <strong>Server</strong> is built <str<strong>on</strong>g>for</str<strong>on</strong>g> bulk copying of data, with specialized features and interfaces <strong>to</strong> a<br />

larg e host of data sources. Figure 8.1 shows the various paths that offer bulk copy<br />

functi<strong>on</strong>s <str<strong>on</strong>g>for</str<strong>on</strong>g> moving data from <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>.<br />

Figure 8.1<br />

Paths <str<strong>on</strong>g>for</str<strong>on</strong>g> accessing an <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> database from <strong>SQL</strong> <strong>Server</strong><br />

Data can be migrated from <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> using <strong>on</strong>e of the following opti<strong>on</strong>s:<br />

● Bulk Copy Program (bcp). bcp is a command line utility that uses the ODBC bulk<br />

copy API in <strong>SQL</strong> <strong>Server</strong>. bcp cannot c<strong>on</strong>nect <strong>to</strong> an <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> database and, when<br />

employed <str<strong>on</strong>g>for</str<strong>on</strong>g> moving data from <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong>, the data has <strong>to</strong> be an ASCII<br />

text file. Multiple copies of bcp can be run in parallel while working <strong>on</strong> the same<br />

target table. The number of parallel sessi<strong>on</strong>s is limited by the number of CPUs <strong>on</strong><br />

the server.<br />

For in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> about using the bcp utility with Microsoft <strong>SQL</strong> <strong>Server</strong>, refer <strong>to</strong> the<br />

"bcp Utility" article available at<br />

http://msdn.microsoft.com/library/default.asp? url=/library/enus/coprompt/cp_bcp_61et.asp.<br />

● BULK INSERT. BULK INSERT is a T-<strong>SQL</strong> statement. This statement has the<br />

same kind of functi<strong>on</strong>ality as bcp and can be used <strong>to</strong> import <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> data that has<br />

been captured in a text file. This operati<strong>on</strong> scales linearly with the number of<br />

CPUs, but it is limited <strong>to</strong> <strong>on</strong>e thread per CPU.<br />

For in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <strong>on</strong> the complete BULK INSERT T-<strong>SQL</strong> statement and its usage,<br />

refer <strong>to</strong> http://msdn.microsoft.com/library/default.asp?url=/library/enus/tsqlref/ts_ba-bz_4fec.asp.<br />

● Data Trans<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> Service (DTS). DTS is a powerful set of GUI <strong>to</strong>ols that can<br />

be used <strong>to</strong> extract, trans<str<strong>on</strong>g>for</str<strong>on</strong>g>m, and populate <strong>SQL</strong> <strong>Server</strong> databases from <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 155<br />

E ven though the functi<strong>on</strong>ality <strong>to</strong> trans<str<strong>on</strong>g>for</str<strong>on</strong>g>m data during the migrati<strong>on</strong> exists, an<br />

assumpti<strong>on</strong> made during this discussi<strong>on</strong> is that no trans<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> of the source data is<br />

required. The BULK INSERT T-<strong>SQL</strong> statement has been documented in <strong>SQL</strong> <strong>Server</strong><br />

Books Online as the fastest bulk copy method because it executes with the <strong>SQL</strong> <strong>Server</strong><br />

process. In c<strong>on</strong>trast, bcp and DTS are external utilities that are running as their own<br />

processes. As a result, they have the overhead of having <strong>to</strong> communicate with<br />

S QL <strong>Server</strong> (using IPC) and pass it data from the source. When bcp and DTS are run <strong>on</strong><br />

a client computer, there is network overhead as well.<br />

bcp is faster than DTS when importing very large quantities of data in<strong>to</strong> <strong>SQL</strong> <strong>Server</strong>, but<br />

it lacks some of the features of DTS. Studies have ranked bcp first in speed, followed by<br />

BULK INSERT, and then DTS. Refer <strong>to</strong> the <strong>SQL</strong> <strong>Server</strong> Magazine article "Showdown—<br />

bc p vs. DTS" available at http://www.winnetmag.com/Articles/Print.cfm?ArticleID =19760.<br />

Other fac<strong>to</strong>rs must be c<strong>on</strong>sidered in making a migrati<strong>on</strong> strategy decisi<strong>on</strong>. These fac<strong>to</strong>rs<br />

are discussed under the following heading.<br />

The Microsoft <strong>SQL</strong> <strong>Server</strong> Migrati<strong>on</strong> Assistant (SSMA) provides the Schema and Data<br />

Mig ra<strong>to</strong>r <strong>to</strong>ol, which can migrate the schema and also move the data. The data is<br />

migrated using the <strong>SQL</strong> <strong>Server</strong> Linked <strong>Server</strong> feature <strong>to</strong> c<strong>on</strong>nect directly <strong>to</strong> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g><br />

through the <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Gateway. For more in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <strong>on</strong> the Schema and Data Migra<strong>to</strong>r and<br />

<strong>to</strong> download the <strong>to</strong>ol refer <strong>to</strong> http://www.microsoft.com/sq l/migrati<strong>on</strong>. The beta versi<strong>on</strong> of<br />

this <strong>to</strong>ol is available as of the date of publishing this soluti<strong>on</strong>. Versi<strong>on</strong> 1.0 of the <strong>to</strong>ol is<br />

slated <strong>to</strong> be available in June 2005.<br />

Fac<strong>to</strong>rs in Migrati<strong>on</strong><br />

databases. DTS wizards make the entire process of defining and per<str<strong>on</strong>g>for</str<strong>on</strong>g>ming the<br />

import very easy. DTS provides access <strong>to</strong> the BULK INSERT statement in the DTS<br />

Bulk Insert task. In additi<strong>on</strong> <strong>to</strong> working with text files, DTS can use OLE DB and<br />

ODBC providers <strong>to</strong> c<strong>on</strong>nect <strong>to</strong> an <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> database. The direct c<strong>on</strong>nectivity <strong>to</strong><br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> provides the capability <strong>to</strong> work with binary large objects (BLOBs).<br />

For an overview of DTS, refer <strong>to</strong><br />

http://msdn.microsoft.com/<strong>SQL</strong>/sqlwarehouse/DTS/default.aspx?pull=/library/en-<br />

us/dnsql2k/html/dts_overview.asp.<br />

Given the various opti<strong>on</strong>s <str<strong>on</strong>g>for</str<strong>on</strong>g> migrating data from <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong>, the choice is<br />

influenced by several business and envir<strong>on</strong>ment fac<strong>to</strong>rs. Some of the important fac<strong>to</strong>rs<br />

(the more critical <strong>on</strong>es stated first) are:<br />

● Volume of data. The amount of data that has <strong>to</strong> be migrated is the number <strong>on</strong>e<br />

fac<strong>to</strong>r. High volumes of data require more s<strong>to</strong>rage, more processing power, larger<br />

network bandwidth, larger migrati<strong>on</strong> window, and increased risk of failure.<br />

For more in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <strong>on</strong> how <strong>to</strong> optimize large data imports in <strong>SQL</strong> <strong>Server</strong>, refer <strong>to</strong><br />

http://msdn.microsoft.com/library/default.asp?url=/library/enus/optimsql/odp_tun_1a_5gyt.asp.<br />

● Migrati<strong>on</strong> window. The time window available <str<strong>on</strong>g>for</str<strong>on</strong>g> migrati<strong>on</strong> may necessitate<br />

multiple parallel sessi<strong>on</strong>s, more resources, and staging of data.<br />

● Type of data. The existence of BLOBs can be handled <strong>on</strong>ly by DTS.<br />

● <strong>Server</strong> processing capacity. Running bcp <strong>on</strong> the same server as the database<br />

reduces network overhead of bcp talking <strong>to</strong> <strong>SQL</strong> <strong>Server</strong>, but it c<strong>on</strong>sumes CPU <strong>on</strong><br />

the server.<br />

● S<strong>to</strong>rage availability. The amount of s<strong>to</strong>rage available in both the source and<br />

target envir<strong>on</strong>ment influences the choice of migrati<strong>on</strong> method and strategy. For<br />

example, moving the text files <strong>on</strong> <strong>to</strong> the target server reduces network overhead.


156 Developing: Databases — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> the Data<br />

●<br />

●<br />

●<br />

●<br />

The c<strong>on</strong>figurati<strong>on</strong> of s<strong>to</strong>rage also affects the speed of migrati<strong>on</strong>, such as putting<br />

the source text file and the database files <strong>on</strong> separate disks or devices.<br />

Data source. The capability <strong>to</strong> create flat files in the source envir<strong>on</strong>ment affects<br />

the choice of migrati<strong>on</strong> method. A fixed-field <str<strong>on</strong>g>for</str<strong>on</strong>g>mat source file takes a lot more<br />

s<strong>to</strong>rage and is c<strong>on</strong>siderably slower. Delimited <str<strong>on</strong>g>for</str<strong>on</strong>g>mat is recommended.<br />

Type of database. Batch, OLTP, or DSS database type defines the type of<br />

schema objects and their characteristics.<br />

Recovery Model. Database recovery models should be set <strong>to</strong> simple or bulk-<br />

Use proven methods. Only use methods and opti<strong>on</strong>s that have proven <strong>to</strong> work by<br />

logged <strong>to</strong> minimize logging of BULK INSERT. The capability <strong>to</strong> do so can be<br />

affected if there are databases being shared by other applicati<strong>on</strong>s that are in use<br />

during the migrati<strong>on</strong>.<br />

the industry and <str<strong>on</strong>g>for</str<strong>on</strong>g> the envir<strong>on</strong>ment. For example, OLE DB has been proven <strong>to</strong> be<br />

faster than ODBC while providing all of the same features.<br />

Migrati<strong>on</strong> Strategy<br />

The following are some of the fac<strong>to</strong>rs that can c<strong>on</strong>tribute <strong>to</strong> the creati<strong>on</strong> of a robust<br />

migrati<strong>on</strong> strategy:<br />

● Minimize logging. The acti<strong>on</strong>s that should be taken <strong>to</strong> minimize logging are:<br />

● Set the database recovery model <strong>to</strong> bulk-logged or simple.<br />

● Use TABLOCK hint during bulk loading.<br />

● The target table should either be empty or no indexes should be defined <strong>on</strong> it.<br />

● Disable or drop all triggers <strong>on</strong> the target table.<br />

● Drop replicati<strong>on</strong> <strong>on</strong> the target table.<br />

●<br />

●<br />

●<br />

●<br />

●<br />

●<br />

●<br />

Reduce operati<strong>on</strong>s overhead. You should drop indexes, c<strong>on</strong>straints, defaults,<br />

and identity operati<strong>on</strong>s. When a clustered index is planned <str<strong>on</strong>g>for</str<strong>on</strong>g> a table, order the<br />

data while creating the output file from <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>. The BULK INSERT statement<br />

accepts the ORDER clause and the bcp utility accepts the ORDER hint <strong>to</strong> specify<br />

the sort of the data files. Avoid c<strong>on</strong>current access by other users <strong>to</strong> the tables<br />

being loaded. The TABLOCK hint can be used while per<str<strong>on</strong>g>for</str<strong>on</strong>g>ming BULK INSERT or<br />

bcp.<br />

Improve parallelism. With a large amount of data (which is the assumpti<strong>on</strong> made<br />

throughout this secti<strong>on</strong>), the best per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance can <strong>on</strong>ly be achieved by per<str<strong>on</strong>g>for</str<strong>on</strong>g>ming<br />

loads in parallel. The parallelism can be inter-table or intra-table.<br />

Avoid side effects. Turn off triggers, bypass identity, bypass default column<br />

setting, and drop replicati<strong>on</strong>.<br />

Reduce complexity. When the source database has a large number of tables,<br />

break it down in<strong>to</strong> logical subsets and stage data, if necessary. Importing static and<br />

his<strong>to</strong>rical data can be per<str<strong>on</strong>g>for</str<strong>on</strong>g>med in advance.<br />

Reduce risk. Break down larger source data text files using either an edi<strong>to</strong>r or by<br />

specifying ranges in the <strong>SQL</strong> queries that are used <str<strong>on</strong>g>for</str<strong>on</strong>g> exporting the data in<strong>to</strong> spool<br />

files. Any failures that occur when dealing with large files waste time and<br />

resources. In a migrati<strong>on</strong> c<strong>on</strong>taining very volatile data, the migrati<strong>on</strong> should be<br />

completed in a single stage instead of multiple stages.<br />

Commit more resources. Additi<strong>on</strong>al CPU, memory, and s<strong>to</strong>rage should be<br />

acquired <str<strong>on</strong>g>for</str<strong>on</strong>g> the migrati<strong>on</strong>.<br />

Auditing. Include audit steps during the process. This enables trapping of errors<br />

as they occur<br />

during the transfer of data.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 157<br />

Table 8.1 details the suitable method of data porting <str<strong>on</strong>g>for</str<strong>on</strong>g> different migrati<strong>on</strong> envir<strong>on</strong>ments.<br />

Table 8.1: Data Migrati<strong>on</strong> Opti<strong>on</strong>s<br />

Scenario<br />

Data migrati<strong>on</strong> envir<strong>on</strong>ments that have high per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance<br />

req uirements and have huge volumes of data <strong>to</strong> be<br />

transferred<br />

Methods of data migrati<strong>on</strong> that use a small amount of scripts bcp<br />

Applicati<strong>on</strong>s that need <strong>to</strong> use scripts <strong>on</strong> the data transfer<br />

process<br />

Ap plicati<strong>on</strong>s that require high-powered trans<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> of<br />

moderate volumes of data<br />

Tab les c<strong>on</strong>tain large objects (LOB) such as RAW, LONG,<br />

BLOB, and CLOB<br />

Recommended method<br />

bcp or BULK INSERT<br />

BULK INSERT<br />

Here are some additi<strong>on</strong>al c<strong>on</strong>siderati<strong>on</strong>s <str<strong>on</strong>g>for</str<strong>on</strong>g> planning the migrati<strong>on</strong>:<br />

● The final strategy should be based <strong>on</strong> the amount of time available <str<strong>on</strong>g>for</str<strong>on</strong>g> the actual<br />

deployment and cu<strong>to</strong>ver.<br />

● The per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance of the load operati<strong>on</strong> should be dependent <strong>on</strong> the chosen<br />

strategy.<br />

● Instead of sticking <strong>to</strong> a single method, a combinati<strong>on</strong> of methods can be employed<br />

based <strong>on</strong> the strengths and weaknesses of the individual methods. For example,<br />

DTS need not be used as the migrati<strong>on</strong> method just because there are LOB<br />

columns.<br />

● The tables in the migrati<strong>on</strong> can be broken up and a combinati<strong>on</strong> of methods could<br />

be used, taking advantage of the strengths of each.<br />

● Parallel operati<strong>on</strong> should be applied <strong>on</strong> large tables.<br />

● The per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance of bcp versus BULK INSERT has been found <strong>to</strong> vary. Test both<br />

these approaches in your scenario be<str<strong>on</strong>g>for</str<strong>on</strong>g>e making a decisi<strong>on</strong>.<br />

● Test data files should be created and the per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance of the various methods<br />

measured in the target envir<strong>on</strong>ment.<br />

● A pro<strong>to</strong>type of the final strategy should be created and the process should be<br />

practiced and perfected be<str<strong>on</strong>g>for</str<strong>on</strong>g>e deployment.<br />

DTS<br />

DTS<br />

Executing the Data Migrati<strong>on</strong><br />

This secti<strong>on</strong> details the steps <strong>to</strong> be per<str<strong>on</strong>g>for</str<strong>on</strong>g>med <str<strong>on</strong>g>for</str<strong>on</strong>g> migrating data. The secti<strong>on</strong> has been<br />

broken in<strong>to</strong> three tasks:<br />

1. Pre-implementati<strong>on</strong><br />

2. Implementati<strong>on</strong><br />

3. Post-implementati<strong>on</strong><br />

Each of these tasks is discussed in detail under the following headings.


158 Developing: Databases — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> the Data<br />

Pre-Implementati<strong>on</strong> Tasks<br />

The following tasks have <strong>to</strong> be completed be<str<strong>on</strong>g>for</str<strong>on</strong>g>e per<str<strong>on</strong>g>for</str<strong>on</strong>g>ming the migrati<strong>on</strong>:<br />

1. Back up the database.<br />

Delete any test data from the target database and create a full backup of the empty<br />

database. Res<strong>to</strong>ring the backup will be faster than the work involved in rolling back<br />

a failed or incomplete migrati<strong>on</strong>.<br />

2.<br />

Export <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> data in<strong>to</strong> text files.<br />

Data from each table that has <strong>to</strong> be migrated is exported in<strong>to</strong> comma-delimited<br />

ASCII text files.<br />

Note The string data should be opti<strong>on</strong>ally enclosed in double quotati<strong>on</strong> marks (")<br />

in case there are commas in the column data. The date fields can be exported in<br />

the desired <str<strong>on</strong>g>for</str<strong>on</strong>g>mat using the TO_CHAR functi<strong>on</strong>.<br />

Sample:<br />

In <strong>SQL</strong>*Plus, c<strong>on</strong>nect <strong>to</strong> the schema and execute the following command:<br />

desc countries<br />

The output is:<br />

Name Null? Type<br />

----------------------------------------- -------- -----------------<br />

COUNTRY_ID<br />

COUNTRY_NAME<br />

REGION_ID<br />

NOT NULL CHAR(2)<br />

VARCHAR2(40)<br />

NUMBER<br />

Create a .sql file (example countries.sql) with the following c<strong>on</strong>tent:<br />

set pages 0<br />

set lines 10000<br />

set trimspool <strong>on</strong><br />

set feedback off<br />

spool /data/dump/countries.csv<br />

select country_id||','||country_name||','||regi<strong>on</strong>_id<br />

from countries;<br />

spool off<br />

Executing this file using <strong>SQL</strong>*Plus produces the following text file that can be<br />

imported in<strong>to</strong> <strong>SQL</strong> <strong>Server</strong>.<br />

Note If these commands are typed at the command prompt inside the <strong>SQL</strong>*Plus<br />

utility in Microsoft Windows®, the output file will c<strong>on</strong>tain extraneous prompt<br />

commands at the beginning and end of the file. This does not occur if the<br />

commands are executed from a file.<br />

AR,Argentina,2<br />

AU,Australia,3<br />

BE,Belgium,1<br />

BR,Brazil,2<br />

CA,Canada,2<br />

CH,Switzerland,1<br />

CN,China,3<br />

DE,Germany,1


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 159<br />

DK,Denmark,1<br />

EG,Egypt,4<br />

FR,France,1<br />

HK,H<strong>on</strong>gK<strong>on</strong>g,3<br />

IL,Israel,4<br />

IN,India,3<br />

IT,Italy,1<br />

JP,Japan,3<br />

KW,Kuwait,4<br />

MX,Mexico,2<br />

NG,Nigeria,4<br />

NL,<strong>Net</strong>herlands,1<br />

SG,Singapore,3<br />

UK,United Kingdom,1<br />

US,United States of America,2<br />

ZM,Zambia,4<br />

ZW,Zimbabwe,4<br />

Note Using <strong>SQL</strong>*Plus and the spool command is the best way <strong>to</strong> create commaseparated<br />

(CSV) exports of <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> table data. Other soluti<strong>on</strong>s available based <strong>on</strong><br />

the functi<strong>on</strong>ality currently available in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> are DBMS_OUTPUT, UTL_FILE, and<br />

Pro*C. For details <strong>on</strong> the various methods, refer <strong>to</strong><br />

http://ask<strong>to</strong>m.oracle.com/~tkyte/flat/index.html<br />

However, these opti<strong>on</strong>s should be employed <strong>on</strong>ly if the data is being manipulated<br />

during the output process because there are per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance overheads in their use.<br />

3. Set the recovery model of the <strong>SQL</strong> <strong>Server</strong> database.<br />

Change the recovery model of the target <strong>SQL</strong> <strong>Server</strong> database <strong>to</strong> bulk-logged or<br />

simple. Bulk-logged mode is preferred.<br />

The following command sets the recovery model of a database <strong>to</strong> bulk-logged:<br />

ALTER DATABASE database_name<br />

SET RECOVERY BULK_LOGGED<br />

where database_name is the name of the database whose recovery model has <strong>to</strong> be<br />

set.<br />

4. Disable all c<strong>on</strong>straints.<br />

Identify and disable all c<strong>on</strong>straints, including CHECK, PRIMARY KEY, FOREIGN<br />

KEY, and UNIQUE. Create scripts <strong>to</strong> res<strong>to</strong>re them.<br />

In <strong>SQL</strong> <strong>Server</strong>, <strong>on</strong>ly FOREIGN KEY and CHECK c<strong>on</strong>straints can be disabled.<br />

The following command can be used <strong>to</strong> disable FOREIGN KEY and CHECK<br />

c<strong>on</strong>straints of a <strong>SQL</strong> <strong>Server</strong> table:<br />

ALTER TABLE table_name NOCHECK CONSTRAINT ALL<br />

where table_name is the name of the table whose c<strong>on</strong>straints have <strong>to</strong> be disabled.<br />

PRIMARY KEY and UNIQUE c<strong>on</strong>straints have <strong>to</strong> be dropped.<br />

The following command can be used <strong>to</strong> drop PRIMARY and UNIQUE by specifying<br />

their name:<br />

ALTER TABLE table_name DROP CONSTRAINT c<strong>on</strong>straint_name<br />

where c<strong>on</strong>straint_name is the name of the c<strong>on</strong>straint and table_name is the name of<br />

the table in which the c<strong>on</strong>straint exists.


160 Developing: Databases — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> the Data<br />

Note By default, c<strong>on</strong>straints are not checked when using bcp.<br />

5. Disable all triggers.<br />

Disable triggers <strong>on</strong> all tables in<strong>to</strong> which data will be loaded.<br />

The following command can be used <strong>to</strong> disable all triggers <strong>on</strong> a table.<br />

ALTER TABLE table_name DISABLE TRIGGER ALL<br />

where table_name is the name of the table <strong>on</strong> which the triggers have <strong>to</strong> be<br />

disabled.<br />

6. Drop all indexes.<br />

Drop all remaining indexes using the following command after saving the script <strong>to</strong><br />

recreate them.<br />

DROP INDEX<br />

table_name.index_name<br />

where index_name is the name of the index <strong>to</strong> be dropped and table_name is the<br />

table <strong>on</strong> which the index exists.<br />

7. Handle IDENTITY column inserts.<br />

Let explicit values be copied in<strong>to</strong> columns of a table with the Identity property.<br />

SET IDENTITY_INSERT table_name ON<br />

This setting can be used <strong>on</strong>ly <strong>on</strong> a single table at a time. So ensure that this is set<br />

be<str<strong>on</strong>g>for</str<strong>on</strong>g>e importing a table, or use the functi<strong>on</strong>ality in the method being used. In bcp,<br />

the same thing can be achieved using the -E switch. In BULK INSERT, use the<br />

KEEPIDENTITY argument.<br />

BULK INSERT 'table_name' FROM 'data file' WITH KEEPIDENTITY<br />

8. Back up the database.<br />

Create a full backup after the data migrati<strong>on</strong> be<str<strong>on</strong>g>for</str<strong>on</strong>g>e per<str<strong>on</strong>g>for</str<strong>on</strong>g>ming any validati<strong>on</strong> or<br />

testing.<br />

Implementati<strong>on</strong> Tasks<br />

The implementati<strong>on</strong> is the actual transfer of data from the source <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> database <strong>to</strong> the<br />

target <strong>SQL</strong> <strong>Server</strong> database. The implementati<strong>on</strong> can be per<str<strong>on</strong>g>for</str<strong>on</strong>g>med in <strong>on</strong>e step or in two<br />

steps. In the single step, implementati<strong>on</strong> data is streamed directly from the <str<strong>on</strong>g>Oracle</str<strong>on</strong>g><br />

database <strong>to</strong> the <strong>SQL</strong> <strong>Server</strong> database. In the two step process, data is extracted from the<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> database in<strong>to</strong> files and then loaded in<strong>to</strong> the <strong>SQL</strong> <strong>Server</strong> database.<br />

S QL <strong>Server</strong> provides the following three <strong>to</strong> ols <str<strong>on</strong>g>for</str<strong>on</strong>g> loading data in<strong>to</strong> a database:<br />

● The bulk copy program (bcp)<br />

● The BULK INSERT statement<br />

● Data Trans<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> Services (DTS)<br />

The use of these three <strong>to</strong>ols in transferring data in<strong>to</strong> <strong>SQL</strong> <strong>Server</strong> is discussed under the<br />

following headings.<br />

Using bcp<br />

The bcp utility can be accessed from the command prompt. The syntax <str<strong>on</strong>g>for</str<strong>on</strong>g> use is<br />

provided here:<br />

bcp database_name.owner.table_name in data_file –t field_termina<strong>to</strong>r –S<br />

server_name\instance_name<br />

–U username –P password –c –t ,


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 161<br />

where database_name.owner.<br />

table_name is the fully qualified name of the table in<strong>to</strong> which<br />

the data is <strong>to</strong> be loaded, data_file is the name of the text file c<strong>on</strong>taining the data,<br />

field_termina<strong>to</strong>r is the character that is used <strong>to</strong> delimit columns in a row,<br />

server_name\instance_name is the <strong>SQL</strong> <strong>Server</strong> instance, username is the login name, and<br />

password is the password <str<strong>on</strong>g>for</str<strong>on</strong>g> the user login.<br />

-c specifies that the data in the file is in the character data type<br />

-t specifies the field termina<strong>to</strong>r<br />

Figure 8.2 shows the results of executing this command at the Windows command<br />

prompt.<br />

Figure 8.2<br />

Importing data from a text file using bcp<br />

To make the bcp process repeatable, a <str<strong>on</strong>g>for</str<strong>on</strong>g>mat file should be created. The <str<strong>on</strong>g>for</str<strong>on</strong>g>mat file can<br />

be created interactively by executing the b cp command, as shown in Figure 8.3.<br />

Figure 8.3<br />

Creating a <str<strong>on</strong>g>for</str<strong>on</strong>g>mat file <str<strong>on</strong>g>for</str<strong>on</strong>g> use with bcp imports


162 Developing: Databases — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> the Data<br />

The <str<strong>on</strong>g>for</str<strong>on</strong>g>mat file looks like this:<br />

8.0<br />

3<br />

1 <strong>SQL</strong>CHAR 0 2 "," 1 COUNTRY_ID <strong>SQL</strong>_Latin1_General_CP1_CI_AS<br />

2 SQ LCHAR 0 40 "," 2 COUNTRY_NAME <strong>SQL</strong>_Latin1_General_CP1_CI_AS<br />

3 <strong>SQL</strong>NUMERIC 0 19 "\r\n" 3 REGION_ID ""<br />

Refer <strong>to</strong> the <strong>to</strong>pic "Using Format Files" in <strong>SQL</strong> <strong>Server</strong> Books Online <str<strong>on</strong>g>for</str<strong>on</strong>g> more in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong><br />

about <str<strong>on</strong>g>for</str<strong>on</strong>g>mat files.<br />

Note The <str<strong>on</strong>g>for</str<strong>on</strong>g>mat file will have <strong>to</strong> be modified <strong>to</strong> handle text files that c<strong>on</strong>tain column<br />

data values and which are enclosed by quotati<strong>on</strong> marks (").<br />

The <str<strong>on</strong>g>for</str<strong>on</strong>g>mat file can be used <str<strong>on</strong>g>for</str<strong>on</strong>g> future imports in<strong>to</strong> the same table by using the -f switch.<br />

This is illustrated in Figure 8.4. In the example, the <str<strong>on</strong>g>for</str<strong>on</strong>g>mat file is assumed <strong>to</strong> have been<br />

copied <strong>to</strong> C:.<br />

Figure 8.4<br />

Importing data from a text file using bcp <str<strong>on</strong>g>for</str<strong>on</strong>g>mat file<br />

Table 8.2 c<strong>on</strong>tains the additi<strong>on</strong>al arguments that are relevant while importing large<br />

volumes of data from <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>.<br />

Table 8.2: Additi<strong>on</strong>al Arguments of the bcp Utility<br />

Argument (or opti<strong>on</strong>)<br />

Descripti<strong>on</strong><br />

-k bypasses DEFAULT definiti<strong>on</strong><br />

-h "hints" bulk copy hints<br />

-E allows Identity insert<br />

-a network packets size 512 <strong>to</strong> 65536 (default<br />

4096)<br />

-e error_file logs errors during the import<br />

-b batch_size uses default, which is all rows in the file<br />

Note Hidden characters in text files can cause problems such as the "unexpected null<br />

found" error. Care has <strong>to</strong> be taken when opening and manipulating text files c<strong>on</strong>taining<br />

data.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 163<br />

Using BULK INSERT<br />

The BULK INSERT T-<strong>SQL</strong> statement provides the same functi<strong>on</strong>ality as the bcp utility.<br />

The major difference is that this functi<strong>on</strong>ality is from within a database sessi<strong>on</strong>.<br />

The following statement achieves the same work as was dem<strong>on</strong>strated with bcp:<br />

BULK INSERT hrdata.hr.countries FROM 'c:\countries.csv'<br />

WITH (<br />

DATAFILETYPE = 'char',<br />

FIELDTERMINATOR = ',',<br />

ROWTERMINATOR = '\n'<br />

)<br />

Note Only members of the sysadmin role can use BULK INSERT.<br />

Table 8.3 c<strong>on</strong>tains additi<strong>on</strong>al arguments that need <strong>to</strong> be used while importing large<br />

amounts of <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> data.<br />

Table 8.3: Additi<strong>on</strong>al Arguments Available with the BULK INSERT Command<br />

Argument (or opti<strong>on</strong>)<br />

Descripti<strong>on</strong><br />

-k bypasses DEFAULT definiti<strong>on</strong><br />

TABLOCK<br />

locks<br />

KEEPIDENTITY<br />

allows values <strong>to</strong> be specified <str<strong>on</strong>g>for</str<strong>on</strong>g> identity<br />

column<br />

FIRE_TRIGGERS trigger executi<strong>on</strong> is not suppressed<br />

CHECK_CONSTRAINTS<br />

c<strong>on</strong>straints <strong>on</strong> table have <strong>to</strong> be checked<br />

BATCHSIZE<br />

use default, which is all rows in the file<br />

Note For more in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> about the bulk copy operati<strong>on</strong>s and <strong>on</strong> improving its<br />

per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance, refer <strong>to</strong> "Optimizing Bulk Copy Per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance" at<br />

http://msdn.microsoft.com/library/en-us/optimsql/od p_tun_1a_5gyt.asp?frame=true,<br />

and "Bulk Copy Per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance C<strong>on</strong>siderati<strong>on</strong>s" at http://msdn.microsoft.com/library/en-<br />

us/adminsql/ad_impt_bcp_5zqd.asp.<br />

For in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <strong>on</strong> different switches available with Bulk Insert, refer <strong>to</strong><br />

http ://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_ba-<br />

bz_4fec.asp.<br />

Using DTS<br />

This secti<strong>on</strong> is used <strong>to</strong> dem<strong>on</strong>strate how DTS wizards can be used <strong>to</strong> import data in<strong>to</strong><br />

<strong>SQL</strong> <strong>Server</strong> tables from text files and directly from an <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> database.<br />

The DTS Import/Export Wizard can be launched from Enterprise Manager<br />

using the following steps or using the DTS Import Wizard:<br />

1. Expand <strong>Server</strong>.<br />

2. Right-click Databases, click All Tasks, and then click Import Data.<br />

3. Click the Next butt<strong>on</strong> <strong>on</strong> the wizard's Welcome screen.<br />

4. The next window presented is <str<strong>on</strong>g>for</str<strong>on</strong>g> choosing the data source. In the Data<br />

Source drop-down list choose Text File. Pick the file c<strong>on</strong>taining <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> table<br />

data in the File name text box.


164 Developing: Databases — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> the Data<br />

5. The file <str<strong>on</strong>g>for</str<strong>on</strong>g>mat characteristics are chosen in the next window. The file type<br />

should be ANSI, and the row delimiter should be {CR}{LF}. If column data<br />

values are quoted, it can be specified in the Text qualifier field. The delimiter<br />

character, which is a comma (,), is specified in the next screen.<br />

6. The Microsoft OLE DB Provider <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>SQL</strong> <strong>Server</strong> should be chosen as the<br />

destinati<strong>on</strong> and the server and login in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> provided <str<strong>on</strong>g>for</str<strong>on</strong>g> the target<br />

<strong>SQL</strong> <strong>Server</strong> instance.<br />

DTS offers the opti<strong>on</strong> of executing the import, saving it <strong>to</strong> a DTS package and<br />

scheduling. For in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <strong>on</strong> how <strong>to</strong> schedule DTS packages, refer <strong>to</strong><br />

http://msdn.microsoft.com/library/default.asp?url=/library/en-<br />

us/dtssql/dts_pkgmng_4hm6.asp.<br />

DTS from <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Database<br />

The steps in creating a DTS package <strong>to</strong> c<strong>on</strong>nect and import data directly from the <str<strong>on</strong>g>Oracle</str<strong>on</strong>g><br />

database is very similar <strong>to</strong> the process described in the previous secti<strong>on</strong>. Instead of<br />

pointing the source <strong>to</strong> a file, an <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> database is specified through an OLE DB or<br />

ODBC provider <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>.<br />

The DTS Import/Export Wizard can be launched from Enterprise Manager<br />

using the following steps or using the DTS Import Wizard:<br />

1. Expand <strong>Server</strong>.<br />

2. Right-click Databases, click All Tasks, and then click Import Data.<br />

3. Click the Next butt<strong>on</strong> <strong>on</strong> the wizard's Welcome screen.<br />

4. The next window presented is <str<strong>on</strong>g>for</str<strong>on</strong>g> choosing the data source. In the Data Source<br />

drop-down list, choose the Microsoft ODBC Driver <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>. Enter the <str<strong>on</strong>g>Oracle</str<strong>on</strong>g><br />

database alias and login in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong>.<br />

5. The Microsoft OLE DB Provider <str<strong>on</strong>g>for</str<strong>on</strong>g> SL <strong>Server</strong> should be chosen as the destinati<strong>on</strong><br />

and the server and login in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> provided <str<strong>on</strong>g>for</str<strong>on</strong>g> the target <strong>SQL</strong> <strong>Server</strong> instance.<br />

6. The next screen offers the opti<strong>on</strong> of copying data from a table (or view) or using a<br />

query.<br />

7. If the table or view opti<strong>on</strong> is chosen, the next screen provides a list of tables and<br />

views available <str<strong>on</strong>g>for</str<strong>on</strong>g> import. The destinati<strong>on</strong> table name and trans<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong><br />

in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> has <strong>to</strong> be provided al<strong>on</strong>g with the source table/view.<br />

8. If query opti<strong>on</strong> is chosen, the next screen provides a window <str<strong>on</strong>g>for</str<strong>on</strong>g> entering the query<br />

statement. The destinati<strong>on</strong> table and trans<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> can be entered in the next<br />

screen.<br />

9. The executi<strong>on</strong> of the import can be d<strong>on</strong>e immediately or scheduled <str<strong>on</strong>g>for</str<strong>on</strong>g> a later time.<br />

Note DTS has the capability of reading the table descripti<strong>on</strong> from the <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> database<br />

and creating tables in <strong>SQL</strong> <strong>Server</strong>. The wizard has been found <strong>to</strong> be faulty in its choice<br />

of equivalent data types <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>SQL</strong> <strong>Server</strong> tables.<br />

Data can be migrated directly out of the database instead of through an intermediary file<br />

if the interc<strong>on</strong>nect between the servers hosting the two databases is very fast. Also, no<br />

additi<strong>on</strong>al s<strong>to</strong>rage is required <str<strong>on</strong>g>for</str<strong>on</strong>g> the data files <strong>on</strong> the two servers. Use of files can reduce<br />

the deployment time if the data export can be d<strong>on</strong>e in advance and staged <str<strong>on</strong>g>for</str<strong>on</strong>g> import.<br />

For a case study <strong>on</strong> incrementally loading tables using the <strong>SQL</strong> <strong>Server</strong> bulk load opti<strong>on</strong>s,<br />

refer <strong>to</strong><br />

http://www.microsoft.com/technet/prodtechnol/sql/2000/maintain/incbulkload.mspx.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 165<br />

Post-Implementati<strong>on</strong> Tasks<br />

The following tasks have <strong>to</strong> be per<str<strong>on</strong>g>for</str<strong>on</strong>g>med <strong>to</strong> ensure the success of the data transfer. The<br />

tasks per<str<strong>on</strong>g>for</str<strong>on</strong>g>med here undo the changes that were made <strong>to</strong> the schema <str<strong>on</strong>g>for</str<strong>on</strong>g> affecting the<br />

data transfer, such as disabling of c<strong>on</strong>straints and triggers. Chapter 9, "Developing:<br />

Databases — Unit Testing the Migrati<strong>on</strong>" has a more detailed discussi<strong>on</strong> of per<str<strong>on</strong>g>for</str<strong>on</strong>g>ming the<br />

first two tasks as a part of testing the migrated database.<br />

1. Validate the data migrati<strong>on</strong>.<br />

Th e validati<strong>on</strong> tasks are discussed in detail in the "Validating the Data Migrati<strong>on</strong>"<br />

secti<strong>on</strong> later in this chapter.<br />

2. Re-enable the c<strong>on</strong>straints.<br />

Enable all c<strong>on</strong>straints, including CHECK, PRIMARY KEY, FOREIGN KEY, and<br />

UNIQUE. Use the scripts that were created while disabling the c<strong>on</strong>straints.<br />

FOREIGN KEY and CHECK c<strong>on</strong>straints can be enabled using the following syntax:<br />

ALTER TABLE table_name CHECK CONSTRAINT ALL<br />

where table_name is the table <strong>on</strong> which the CHECK c<strong>on</strong>straints have <strong>to</strong> be enabled.<br />

PRIMARY KEY and UNIQUE c<strong>on</strong>straints will have <strong>to</strong> be recreated using the<br />

original DDL. <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> allows multiple rows where all columns (nullable) of a<br />

UNIQUE c<strong>on</strong>straint have NULL values. <strong>SQL</strong> <strong>Server</strong> treats NULL as duplicates<br />

(instead of an unknown value) <str<strong>on</strong>g>for</str<strong>on</strong>g> the purpose of uniqueness. Hence creating a<br />

UNIQUE c<strong>on</strong>straint would return an error if such a c<strong>on</strong>diti<strong>on</strong> exists. Because it<br />

would be difficult <strong>to</strong> create values, the best way <strong>to</strong> maintain the status quo would<br />

be <strong>to</strong> replace the UNIQUE c<strong>on</strong>straint with a trigger that accomplishes the same<br />

thing.<br />

3. Recreate the indexes.<br />

The c<strong>on</strong>straint indexes can be recreated using the saved scripts. Multiple indexes<br />

<strong>on</strong> a single table can be created in parallel using different client sessi<strong>on</strong>s.<br />

4. Enable the triggers.<br />

Identify and enable all triggers by using the following syntax:<br />

ALTER TABLE table_name ENABLE TRIGGER ALL<br />

where table_name is the table <strong>on</strong> which the triggers are <strong>to</strong> be enabled.<br />

5. Set the recovery model.<br />

Res<strong>to</strong>re the recovery model of the <strong>SQL</strong> <strong>Server</strong> database <strong>to</strong> the original setting<br />

(normally full) by using the following syntax:<br />

ALTER DATABASE database_name<br />

SET RECOVERY FULL<br />

6. Capture data statistics.<br />

Per<str<strong>on</strong>g>for</str<strong>on</strong>g>m the steps necessary <strong>to</strong> capture data statistics required by the optimizer.<br />

7. Back up the database.<br />

Create a full backup of the entire server, including the user databases. This is the<br />

first valid backup of the migrated database.<br />

Validating the Data Migrati<strong>on</strong><br />

The following major tasks have <strong>to</strong> be per<str<strong>on</strong>g>for</str<strong>on</strong>g>med <strong>to</strong> validate the migrated data:<br />

1. Verify the data transfer.<br />

The logs or audit files <str<strong>on</strong>g>for</str<strong>on</strong>g> the data transfers should be checked <str<strong>on</strong>g>for</str<strong>on</strong>g> errors or<br />

failures. After this process<br />

is complete, row counts of every table in the destinati<strong>on</strong><br />

<strong>SQL</strong> <strong>Server</strong> database should be matched <strong>to</strong> the source <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> database. If any


166 Developing: Databases — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> the Data<br />

2.<br />

discrepancy is found in the counts, troubleshooting should include identifying the<br />

missing records and viewing the logs and audit files <str<strong>on</strong>g>for</str<strong>on</strong>g> error messages that can<br />

provide reas<strong>on</strong>s <str<strong>on</strong>g>for</str<strong>on</strong>g> the failure. The data transfer process should take in<strong>to</strong><br />

c<strong>on</strong>siderati<strong>on</strong> any changes in the logical model between the source <str<strong>on</strong>g>Oracle</str<strong>on</strong>g><br />

database and <strong>SQL</strong> <strong>Server</strong>. A more stringent check is difficult <str<strong>on</strong>g>for</str<strong>on</strong>g> large databases.<br />

More validati<strong>on</strong> of the data transfer occurs in the next step as part of the data<br />

integrity checks.<br />

Validate the data integrity.<br />

Integrity is au<strong>to</strong>matically checked when creating or enabling c<strong>on</strong>straints. The WITH<br />

CHECK clause has <strong>to</strong> be used when adding c<strong>on</strong>straints. Data integrity checking is<br />

threatened when migrating databases which lack proper primary key c<strong>on</strong>straints<br />

and <str<strong>on</strong>g>for</str<strong>on</strong>g>eign key c<strong>on</strong>straints. For more in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <strong>on</strong> the functi<strong>on</strong>ality available with<br />

check c<strong>on</strong>straints, refer <strong>to</strong><br />

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_aa-<br />

az_3ied.asp.<br />

In many cases, there are no strict equivalents of <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> datatypes in <strong>SQL</strong> <strong>Server</strong>.<br />

Hence the integrity of such data has <strong>to</strong> be tested <strong>to</strong> ensure that there is no<br />

rounding or truncati<strong>on</strong>, and that the exact value is s<strong>to</strong>red.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 167<br />

9<br />

Developing: Databases — Unit<br />

Testing the Migrati<strong>on</strong><br />

Introducti<strong>on</strong> and Goals<br />

The final task <strong>to</strong> be per<str<strong>on</strong>g>for</str<strong>on</strong>g>med in the Developing Phase is <strong>to</strong> test the database. Because<br />

everything except the core database design has been trans<str<strong>on</strong>g>for</str<strong>on</strong>g>med, it is very important <strong>to</strong><br />

thoroughly test every aspect of the Microsoft® <strong>SQL</strong> <strong>Server</strong> database be<str<strong>on</strong>g>for</str<strong>on</strong>g>e release <strong>to</strong><br />

the producti<strong>on</strong> envir<strong>on</strong>ment. Testing should cover the hardware, the <strong>SQL</strong> <strong>Server</strong><br />

installati<strong>on</strong>, security, database objects, data, and per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance.<br />

The descripti<strong>on</strong>s of the testing process <str<strong>on</strong>g>for</str<strong>on</strong>g> databases and applicati<strong>on</strong>s is divided in<strong>to</strong><br />

smaller pieces and spread out between the Developing and Stabilizing Phases. Testing<br />

<str<strong>on</strong>g>for</str<strong>on</strong>g> integrity and functi<strong>on</strong>ality of the migrated database is covered in this chapter.<br />

Additi<strong>on</strong>al applicati<strong>on</strong>-based testing of the database is per<str<strong>on</strong>g>for</str<strong>on</strong>g>med as part of testing the<br />

applicati<strong>on</strong>. Per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance can be verified <strong>on</strong>ly through the benchmarking and piloting that<br />

is per<str<strong>on</strong>g>for</str<strong>on</strong>g>med in the Stabilizing Phase.<br />

Objectives of Testing<br />

The following areas should be tested:<br />

● Physical architecture of the database. Have the data files, transacti<strong>on</strong> log,<br />

tablespaces, and other items that comprise the database been created correctly?<br />

Has the <strong>SQL</strong> <strong>Server</strong> instance been properly c<strong>on</strong>figured?<br />

● Security. Have the logins and users been correctly created? Have the appropriate<br />

permissi<strong>on</strong>s been assigned? Is the database physically secure?<br />

● Logical architecture of the database. Have the tables, views, s<strong>to</strong>red procedures,<br />

triggers, and other database objects been created successfully?<br />

● Data. Have the c<strong>on</strong>tents of the tables been transferred correctly? Do tables c<strong>on</strong>tain<br />

the correct numbers of rows? Is the data valid?<br />

● Functi<strong>on</strong>ality. Do the s<strong>to</strong>red procedures, triggers, views, and other items<br />

comprising Transact-<strong>SQL</strong> code operate in the same manner as the original <str<strong>on</strong>g>Oracle</str<strong>on</strong>g><br />

objects?<br />

● Per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance. Does resp<strong>on</strong>se time and throughput meet requirements and match<br />

user expectati<strong>on</strong>s?


168 Developing: Databases — Unit Testing the Migrati<strong>on</strong><br />

The<br />

Testing Process<br />

The database is tested in three different stages of the migrati<strong>on</strong>:<br />

●<br />

●<br />

●<br />

Developing Phase — Database<br />

In this stage, the database is unit tested <str<strong>on</strong>g>for</str<strong>on</strong>g> all the comp<strong>on</strong>ents that have been<br />

migrated, which includes the database architecture, the schema, the users, and<br />

the data. This type of testing is covered in the rest of this secti<strong>on</strong>.<br />

Developing Phase — Applicati<strong>on</strong><br />

In this phase, the database is tested with respect <strong>to</strong> the applicati<strong>on</strong> support. This<br />

primarily tests that all the objects required by the applicati<strong>on</strong> are present and<br />

per<str<strong>on</strong>g>for</str<strong>on</strong>g>m as expected. The applicati<strong>on</strong>-related testing is covered in the applicati<strong>on</strong><br />

development Chapters 11 through 17.<br />

Stabilizing Phase<br />

In the Stabilizing Phase, more thorough tests are per<str<strong>on</strong>g>for</str<strong>on</strong>g>med <str<strong>on</strong>g>for</str<strong>on</strong>g> integrati<strong>on</strong>,<br />

per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance, stress, and scalability. This phase is described in Chapter 18.<br />

This secti<strong>on</strong> describes the testing process that is followed during the Developing Phase<br />

<str<strong>on</strong>g>for</str<strong>on</strong>g> the database. The testing is interspersed with the steps in the migrati<strong>on</strong> of the<br />

database. The procedure <str<strong>on</strong>g>for</str<strong>on</strong>g> migrati<strong>on</strong> and testing is illustrated in the flowchart in Figure<br />

9.1.<br />

Figure 9.1<br />

Data migrati<strong>on</strong> test procedure


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 169<br />

The tasks <strong>on</strong> the left half, namely, migrating the architecture, migrating the schema,<br />

migrating the users, and migrating the data, are part of the database migrati<strong>on</strong> and are<br />

covered in chapters 5 through 8. The success of these tasks is validated as database<br />

integrity testing and data validati<strong>on</strong>. Details regarding these two types of testing appear<br />

under the following headings.<br />

Test Database Integrity<br />

After the database schema has been created in the target database, an integrity test<br />

should be per<str<strong>on</strong>g>for</str<strong>on</strong>g>med be<str<strong>on</strong>g>for</str<strong>on</strong>g>e starting the data migrati<strong>on</strong>. This should cover the physical<br />

database structure, the schema, and the schema objects.<br />

There is no <strong>to</strong>ol available <str<strong>on</strong>g>for</str<strong>on</strong>g> comparing the integrity and validity of the <strong>SQL</strong> <strong>Server</strong><br />

objects as compared <strong>to</strong> the original <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> objects. Unit testing has <strong>to</strong> rely <strong>on</strong> the<br />

experience and expertise of the database designers or administra<strong>to</strong>rs who are per<str<strong>on</strong>g>for</str<strong>on</strong>g>ming<br />

the mapping. However, a true unit test would be <strong>to</strong> load data from the source objects and<br />

run <strong>SQL</strong> with identical functi<strong>on</strong>ality in the two envir<strong>on</strong>ments. Any discrepancies should be<br />

<strong>on</strong>ly as a known (explainable) c<strong>on</strong>sequence of the migrati<strong>on</strong>.<br />

The following tasks are per<str<strong>on</strong>g>for</str<strong>on</strong>g>med <strong>to</strong> ensure database integrity:<br />

● Unit test the schema objects. The type and number of each object in the original<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> database has <strong>to</strong> be compared <strong>to</strong> that in the <strong>SQL</strong> <strong>Server</strong> database. Queries<br />

can be written in the two databases (<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong>) <strong>to</strong> produce a count of<br />

each type of object. However, the counts in the two soluti<strong>on</strong>s may not match<br />

because there is no <strong>on</strong>e-<strong>to</strong>-<strong>on</strong>e equivalency <str<strong>on</strong>g>for</str<strong>on</strong>g> every object.<br />

● Verify that data elements have been created as per the mapping. The proper<br />

trans<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> of the data type and domain values of the columns — as well as any<br />

c<strong>on</strong>straints, such as NULL and CHECK c<strong>on</strong>straint <strong>on</strong> the columns — have <strong>to</strong> be<br />

verified be<str<strong>on</strong>g>for</str<strong>on</strong>g>e per<str<strong>on</strong>g>for</str<strong>on</strong>g>ming the data migrati<strong>on</strong>. A representative set of data from the<br />

original <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> database can be used <str<strong>on</strong>g>for</str<strong>on</strong>g> this purpose.<br />

● Verify that all c<strong>on</strong>straints are in place. For each table having a parent-child<br />

relati<strong>on</strong>ship, referential integrity is checked.<br />

● Functi<strong>on</strong>s, triggers, and s<strong>to</strong>red procedures have been accurately<br />

trans<str<strong>on</strong>g>for</str<strong>on</strong>g>med. S<strong>to</strong>red procedures, triggers, and views can be tested by using an<br />

identical set of representative data in the source and migrated databases.<br />

Executi<strong>on</strong> of test cases against these objects should produce identical results.<br />

● Verify the data access. Additi<strong>on</strong>al indexes may be present in <strong>SQL</strong> <strong>Server</strong> <strong>to</strong> offset<br />

features such as fast full index scans in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> that can use the n<strong>on</strong>-leading<br />

columns of indexes. It should be verified that all objects in the original <str<strong>on</strong>g>Oracle</str<strong>on</strong>g><br />

database have been successfully migrated <strong>to</strong> <strong>SQL</strong> <strong>Server</strong>. A complete set of T-<br />

<strong>SQL</strong> statements should be obtained from the applicati<strong>on</strong> development team and<br />

each of them verified <str<strong>on</strong>g>for</str<strong>on</strong>g> optimal data access paths.<br />

If the applicati<strong>on</strong> has been migrated, running a few frequently used business transacti<strong>on</strong>s<br />

would ensure whether the schema has been successfully migrated. After the correctness<br />

of the database structure and its objects is guaranteed, data migrati<strong>on</strong> can proceed.<br />

Test Security<br />

The security mechanisms available with <strong>SQL</strong> <strong>Server</strong> and Windows are significantly<br />

different from those used by <strong>UNIX</strong> and <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>. The difference in the authenticati<strong>on</strong><br />

mechanisms is especially important because it affects the user login process. For<br />

example, the requirements of password management functi<strong>on</strong>ality, such as aging,<br />

locking, and password strength will require that Windows authenticati<strong>on</strong> be used in place<br />

of database authenticati<strong>on</strong>. The system privileges available in the two databases differ


170 Developing: Databases — Unit Testing the Migrati<strong>on</strong><br />

significantly. You must verify that <strong>on</strong>ly authenticated, authorized users have access <strong>to</strong> the<br />

objects in the database. You must also verify that <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> users and roles have been<br />

correctly mapped <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> users and roles, and that all objects in the database<br />

have the appropriate access rights granted <strong>to</strong> them.<br />

Validate Data<br />

The existence of indexes and c<strong>on</strong>straints during data migrati<strong>on</strong> adversely affects the<br />

per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance of the data migrati<strong>on</strong>. The firing of triggers can corrupt the data and produce<br />

undesirable effects. There<str<strong>on</strong>g>for</str<strong>on</strong>g>e, these objects have <strong>to</strong> be disabled or dropped. A negative<br />

aspect of these acti<strong>on</strong>s is that data is not checked <str<strong>on</strong>g>for</str<strong>on</strong>g> correctness or completeness<br />

during the migrati<strong>on</strong> and has <strong>to</strong> be validated after the migrati<strong>on</strong>. No special plans are<br />

needed <str<strong>on</strong>g>for</str<strong>on</strong>g> validating data integrity. The database itself checks the integrity of the data<br />

when the c<strong>on</strong>straints are enabled using the WITH CHECK clause. For more in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong><br />

<strong>on</strong> check c<strong>on</strong>straints in <strong>SQL</strong> <strong>Server</strong>, refer <strong>to</strong><br />

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_aa-az_3ied.asp.<br />

The two types of tests that have <strong>to</strong> be per<str<strong>on</strong>g>for</str<strong>on</strong>g>med <strong>to</strong> validate the data are discussed in the<br />

"Validating the Data Migrati<strong>on</strong>" secti<strong>on</strong> in Chapter 8.<br />

Note One of the comm<strong>on</strong> risks involved in data migrati<strong>on</strong> is the lack of a proper or<br />

complete set of c<strong>on</strong>straints in the database. In many applicati<strong>on</strong>s, the c<strong>on</strong>straints are<br />

built in<strong>to</strong> the applicati<strong>on</strong>. In such cases, the development team will have <strong>to</strong> be involved<br />

in c<strong>on</strong>structing <strong>SQL</strong>-based tests <strong>to</strong> verify data integrity by identifying such rules in the<br />

applicati<strong>on</strong>.<br />

Validate the Migrati<strong>on</strong><br />

After data migrati<strong>on</strong> is complete, tests have <strong>to</strong> be per<str<strong>on</strong>g>for</str<strong>on</strong>g>med <strong>on</strong> the database as a whole.<br />

Testing should cover the database architecture, database objects, data, and users. In<br />

additi<strong>on</strong>, the database c<strong>on</strong>nectivity, security, and per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance have <strong>to</strong> be tested. For<br />

in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <strong>on</strong> client c<strong>on</strong>nectivity <strong>to</strong> the database, refer <strong>to</strong><br />

http://msdn.microsoft.com/library/default.asp?url=/library/enus/adminsql/ad_1_client_5er7.asp.<br />

A discussi<strong>on</strong> of the security architecture in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and<br />

<strong>SQL</strong> <strong>Server</strong> is available in Appendix A: "<strong>SQL</strong> <strong>Server</strong> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Professi<strong>on</strong>als." Appendix<br />

B: "Getting the Best out of <strong>SQL</strong> <strong>Server</strong> 2000 and Windows" c<strong>on</strong>tains several references<br />

<strong>on</strong> <strong>SQL</strong> <strong>Server</strong> per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance.<br />

While in smaller databases the data migrati<strong>on</strong> validati<strong>on</strong> can be exhaustive, in very large<br />

databases, some simpler tests (such as counts using various groupings) may be used.<br />

The following checks are recommended:<br />

● Develop group functi<strong>on</strong>s based <strong>on</strong> type of data.<br />

For example, a business-related check can be implemented by calculating the sum<br />

of the balances in all accounts.<br />

● Develop group functi<strong>on</strong>s based <strong>on</strong> time.<br />

● Check <str<strong>on</strong>g>for</str<strong>on</strong>g> record counts.<br />

● Use the applicati<strong>on</strong> <strong>to</strong> compare the summary reports.<br />

● Check <str<strong>on</strong>g>for</str<strong>on</strong>g> ad-hoc c<strong>on</strong>trol <strong>to</strong>tals.<br />

For example, after ledger data of a financial applicati<strong>on</strong> has been migrated, adding<br />

up the account numbers in that ledger has no business validity. However, this adhoc<br />

c<strong>on</strong>trol <strong>to</strong>tal could reveal if all the data in the row has been migrated<br />

successfully.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 171<br />

The <strong>SQL</strong> <strong>Server</strong> Migrati<strong>on</strong> Assistant offers a Migrati<strong>on</strong> Tester <strong>to</strong>ol that verifies the<br />

migrated objects (procedures, functi<strong>on</strong>s, and views) by generating its own set of test<br />

data. For more in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <strong>on</strong> the Migrati<strong>on</strong> Tester and <strong>to</strong> download it refer <strong>to</strong><br />

http://www.micro soft.com/sql/migrati<strong>on</strong>. The beta versi<strong>on</strong> of this <strong>to</strong>ol is available as of the<br />

date of publishing this soluti<strong>on</strong>. Versi<strong>on</strong> 1.0 of the <strong>to</strong>ol is slated <strong>to</strong> be available in June<br />

2005.<br />

A test that validates the entire migrati<strong>on</strong> is the running of producti<strong>on</strong> reports and<br />

applicati<strong>on</strong> with producti<strong>on</strong>-quality data. The same reports should be executed against<br />

the original database and the migrated database using a snapshot (or copy) of producti<strong>on</strong><br />

data. Per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance and other vital database statistics, such as cache per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance and<br />

locking, can be gathered.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 173<br />

10<br />

Developing: Applicati<strong>on</strong>s —<br />

Introducti<strong>on</strong><br />

Introducti<strong>on</strong> and Goals<br />

The focus of Chapters 10 through 17 is c<strong>on</strong>necting existing <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> applicati<strong>on</strong>s in the<br />

<strong>UNIX</strong> envir<strong>on</strong>ment <strong>to</strong> the migrated Microsoft® <strong>SQL</strong> <strong>Server</strong> database. This chapter<br />

serves as an introducti<strong>on</strong> <strong>to</strong> the applicati<strong>on</strong>-oriented development chapters.<br />

The following list provides an overview of the c<strong>on</strong>tent in each of the applicati<strong>on</strong>-oriented<br />

development chapters:<br />

● Chapter 11, Developing: Applicati<strong>on</strong>s — <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>SQL</strong> and PL/<strong>SQL</strong>. This chapter<br />

provides a detailed discussi<strong>on</strong> of the <strong>SQL</strong> usage differences between <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and<br />

<strong>SQL</strong> <strong>Server</strong>. Trans<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> of PL/<strong>SQL</strong> <strong>to</strong> T-<strong>SQL</strong> is also covered.<br />

● Chapter 12, Developing: Applicati<strong>on</strong>s — Perl. This chapter discusses the<br />

strategies available <str<strong>on</strong>g>for</str<strong>on</strong>g> migrating a Perl applicati<strong>on</strong> <str<strong>on</strong>g>for</str<strong>on</strong>g> use with the <strong>SQL</strong> <strong>Server</strong><br />

envir<strong>on</strong>ment.<br />

● Chapter 13, Developing: Applicati<strong>on</strong>s — PHP. This chapter discusses the<br />

strategies available <str<strong>on</strong>g>for</str<strong>on</strong>g> migrating a PHP applicati<strong>on</strong> <str<strong>on</strong>g>for</str<strong>on</strong>g> use with the <strong>SQL</strong> <strong>Server</strong><br />

envir<strong>on</strong>ment.<br />

● Chapter 14, Developing: Applicati<strong>on</strong>s — Java. This chapter discusses the<br />

strategies available <str<strong>on</strong>g>for</str<strong>on</strong>g> migrating a Java applicati<strong>on</strong> <str<strong>on</strong>g>for</str<strong>on</strong>g> use with the <strong>SQL</strong> <strong>Server</strong><br />

envir<strong>on</strong>ment.<br />

● Chapter 15, Developing: Applicati<strong>on</strong>s — Pyth<strong>on</strong>. This chapter discusses the<br />

strategies available <str<strong>on</strong>g>for</str<strong>on</strong>g> migrating a Pyth<strong>on</strong> applicati<strong>on</strong> <str<strong>on</strong>g>for</str<strong>on</strong>g> use with the <strong>SQL</strong> <strong>Server</strong><br />

envir<strong>on</strong>ment.<br />

● Chapter 16, Developing: Applicati<strong>on</strong>s — <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Pro*C. This chapter discusses the<br />

strategies available <str<strong>on</strong>g>for</str<strong>on</strong>g> migrating a Pro*C applicati<strong>on</strong> <str<strong>on</strong>g>for</str<strong>on</strong>g> use with the <strong>SQL</strong> <strong>Server</strong><br />

envir<strong>on</strong>ment.<br />

● Chapter 17, Developing: Applicati<strong>on</strong>s — <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms. This chapter discusses<br />

the strategies available <str<strong>on</strong>g>for</str<strong>on</strong>g> migrating an <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms applicati<strong>on</strong> <str<strong>on</strong>g>for</str<strong>on</strong>g> use with the<br />

<strong>SQL</strong> <strong>Server</strong> envir<strong>on</strong>ment.<br />

No applicati<strong>on</strong> migrati<strong>on</strong> will be successful without a clear understanding of the <str<strong>on</strong>g>Oracle</str<strong>on</strong>g><br />

technologies that are fac<strong>to</strong>rs during an <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> database migrati<strong>on</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong>. An<br />

overview of these basic technologies and specific migrati<strong>on</strong><br />

c<strong>on</strong>siderati<strong>on</strong>s is discussed


174 Developing: Applicati<strong>on</strong>s — Introducti<strong>on</strong><br />

in the following two secti<strong>on</strong>s. The applicati<strong>on</strong> ecosystem can be broken in<strong>to</strong> the following<br />

two tiers:<br />

● Data access<br />

● Programming language and c<strong>on</strong>nectivity tier<br />

Data access comprises the comp<strong>on</strong>ents of the applicati<strong>on</strong> that interact with the database<br />

data. <strong>SQL</strong> is the language used <str<strong>on</strong>g>for</str<strong>on</strong>g> retrieving and manipulating the database data. The<br />

applicati<strong>on</strong> developer is resp<strong>on</strong>sible <str<strong>on</strong>g>for</str<strong>on</strong>g> ensuring that applicati<strong>on</strong>s designed <str<strong>on</strong>g>for</str<strong>on</strong>g> the <str<strong>on</strong>g>Oracle</str<strong>on</strong>g><br />

source database work the same way with the migrated <strong>SQL</strong> <strong>Server</strong> target database. The<br />

changes required vary based <strong>on</strong> the programming language support and the API libraries<br />

available <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>SQL</strong> <strong>Server</strong>. The migrati<strong>on</strong> of <strong>SQL</strong> and PL/<strong>SQL</strong> comp<strong>on</strong>ents <strong>to</strong> T-<strong>SQL</strong> <str<strong>on</strong>g>for</str<strong>on</strong>g>ms<br />

a comm<strong>on</strong> requirement, irrespective of the changes <strong>to</strong> the rest of the applicati<strong>on</strong>. The<br />

migrated applicati<strong>on</strong>s then have <strong>to</strong> be tested against the migrated <strong>SQL</strong> <strong>Server</strong> database<br />

<strong>to</strong> ensure their original functi<strong>on</strong>ality.<br />

From an applicati<strong>on</strong> developer's perspective, <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong> manage data in<br />

similar ways. The internal differences between <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong> are significant, but<br />

if managed properly, these differences will have minimal impact <strong>on</strong> a migrated<br />

applicati<strong>on</strong>.<br />

Applicati<strong>on</strong> Migrati<strong>on</strong> Strategies<br />

There are four different strategies <str<strong>on</strong>g>for</str<strong>on</strong>g> applicati<strong>on</strong> migrati<strong>on</strong> that are discussed throughout<br />

the development chapters. These strategies include:<br />

● Interoperati<strong>on</strong>. The applicati<strong>on</strong> comp<strong>on</strong>ents remain in the <strong>UNIX</strong> envir<strong>on</strong>ment.<br />

● Port or rewrite the applicati<strong>on</strong> <strong>to</strong> the Microsoft .NET plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m. The applicati<strong>on</strong><br />

is migrated <strong>to</strong> run <strong>on</strong> the .NET framework.<br />

● Port or rewrite the applicati<strong>on</strong> <strong>to</strong> the Microsoft Win32® plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m. The<br />

applicati<strong>on</strong> is migrated <strong>to</strong> run <strong>on</strong> the Windows® envir<strong>on</strong>ment using the Win32 API.<br />

● Quick port using Windows Services <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>UNIX</strong> 3.5. The applicati<strong>on</strong> is ported <strong>to</strong><br />

use Interix within the Windows envir<strong>on</strong>ment.<br />

Each of the four strategies is discussed in more detail under the following headings. One,<br />

some, or all of these soluti<strong>on</strong> design strategies <str<strong>on</strong>g>for</str<strong>on</strong>g>ms the basis of the soluti<strong>on</strong> c<strong>on</strong>cept<br />

that was completed during the Envisi<strong>on</strong>ing Phase. Even when the goal is <strong>to</strong> standardize<br />

<strong>on</strong> the Windows plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m, some of these strategies may be employed as intermediary<br />

steps in a multi-phased migrati<strong>on</strong>.<br />

In general, .NET development is favored over Win32, but a number of recommendati<strong>on</strong>s<br />

in the following chapters provide guidance <strong>on</strong> migrating <strong>to</strong> a Win32 soluti<strong>on</strong>. This<br />

in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> is provided in cases where a Win32 migrati<strong>on</strong> is the most cost-effective and<br />

straight<str<strong>on</strong>g>for</str<strong>on</strong>g>ward development route.<br />

For more in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <strong>on</strong> these migrati<strong>on</strong> strategies, see "Applicati<strong>on</strong> and Database<br />

Migrati<strong>on</strong> <str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> Design Strategy" in Chapter 2, "Envisi<strong>on</strong>ing Phase."<br />

Interoperati<strong>on</strong><br />

In this strategy, the applicati<strong>on</strong> remains <strong>on</strong> the <strong>UNIX</strong> plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m, while <strong>on</strong>ly the database is<br />

migrated <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> the Windows plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m. This strategy is employed when minor<br />

changes can be made <strong>to</strong> the source code, c<strong>on</strong>necti<strong>on</strong> strings, or the c<strong>on</strong>nectivity layer <strong>to</strong><br />

allow <str<strong>on</strong>g>for</str<strong>on</strong>g> the change in the back end database.<br />

Often, an interoperati<strong>on</strong> strategy is used as an interim step in a phased migrati<strong>on</strong>. This<br />

strategy allows <str<strong>on</strong>g>for</str<strong>on</strong>g> the applicati<strong>on</strong> <strong>to</strong> be quickly c<strong>on</strong>nected <strong>to</strong> the soluti<strong>on</strong>'s <strong>SQL</strong> <strong>Server</strong>


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 175<br />

database with minimal risk or ef<str<strong>on</strong>g>for</str<strong>on</strong>g>t. However, this would not be an adequate soluti<strong>on</strong> if<br />

<strong>on</strong>e of the business requirements <str<strong>on</strong>g>for</str<strong>on</strong>g> the migrati<strong>on</strong> project is eliminati<strong>on</strong> of the <strong>UNIX</strong><br />

envir<strong>on</strong>ment.<br />

Port or Rewrite <strong>to</strong> .NET Framework<br />

The .NET framework is the next generati<strong>on</strong> plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m from Microsoft <str<strong>on</strong>g>for</str<strong>on</strong>g> building,<br />

deploying, and running Windows applicati<strong>on</strong>s. It provides a highly productive, standards-<br />

envir<strong>on</strong>ment <str<strong>on</strong>g>for</str<strong>on</strong>g> integrating existing investments with next-<br />

based, multi-language<br />

generati<strong>on</strong> applicati<strong>on</strong>s and services. When porting or rewriting, migrati<strong>on</strong> <strong>to</strong> the .NET<br />

plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m is preferred because it is the current development plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m <str<strong>on</strong>g>for</str<strong>on</strong>g> Windows<br />

applicati<strong>on</strong>s.<br />

When migrating an applicati<strong>on</strong> <strong>to</strong> the .NET framework, there are two different opti<strong>on</strong>s.<br />

One is <strong>to</strong> per<str<strong>on</strong>g>for</str<strong>on</strong>g>m a full port of the applicati<strong>on</strong>, and the other is <strong>to</strong> rewrite the applicati<strong>on</strong><br />

using the .NET applicati<strong>on</strong> programming interfaces (APIs).<br />

As of this writing, with the increased adopti<strong>on</strong> of the .NET Framework in the industry, the<br />

availability of the .NET APIs <str<strong>on</strong>g>for</str<strong>on</strong>g> applicati<strong>on</strong> porting are expanding. For some of the<br />

languages, the drivers are in beta with support being improved <strong>to</strong> include all functi<strong>on</strong>ality.<br />

Verify the stability of the library and the support <str<strong>on</strong>g>for</str<strong>on</strong>g> all the functi<strong>on</strong> calls needed <str<strong>on</strong>g>for</str<strong>on</strong>g><br />

<strong>SQL</strong> <strong>Server</strong> when picking a driver.<br />

A rewrite of the applicati<strong>on</strong> is required when there is no support <strong>on</strong> the .NET plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m <str<strong>on</strong>g>for</str<strong>on</strong>g><br />

the language in use. An example of this would be an applicati<strong>on</strong> based <strong>on</strong> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms.<br />

The best opti<strong>on</strong> in this case would be <strong>to</strong> rewrite the applicati<strong>on</strong> <strong>on</strong> Windows using Visual<br />

Basic® .NET.<br />

Rewriting an applicati<strong>on</strong> can potentially pose challenges. It can be a time-c<strong>on</strong>suming,<br />

risky, and costly opti<strong>on</strong>. The risk inherent in a rewrite is that the business logic or an<br />

important functi<strong>on</strong>ality is inadvertently changed while rewriting the code. Careful testing<br />

and stabilizing of the rewritten applicati<strong>on</strong> needs <strong>to</strong> be c<strong>on</strong>ducted <strong>to</strong> ensure proper<br />

business logic and functi<strong>on</strong>ality. The following chapters provide detailed in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <strong>on</strong><br />

database c<strong>on</strong>nectivity and the code changes needed <strong>to</strong> migrate <strong>to</strong> the <strong>SQL</strong> <strong>Server</strong><br />

soluti<strong>on</strong>. Rewriting an applicati<strong>on</strong> requires additi<strong>on</strong>al knowledge bey<strong>on</strong>d the scope of this<br />

guide. Where appropriate, this guide provides references <strong>to</strong> more in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> about<br />

rewriting.<br />

Port or Rewrite <strong>to</strong> Win32<br />

Th e Win32 API is the primary programming interface <strong>to</strong> the Windows operating system<br />

family, including Windows® 2003. The Win32 API provides functi<strong>on</strong>s <str<strong>on</strong>g>for</str<strong>on</strong>g> processes,<br />

memory management, security, windowing, and graphics.<br />

C<strong>on</strong>sidering the benefits of migrati<strong>on</strong> <strong>to</strong> the .NET Framework, the <strong>on</strong>ly reas<strong>on</strong> <strong>to</strong> migrate<br />

<strong>to</strong> the Win32 plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m is that migrati<strong>on</strong> <strong>to</strong> .NET is not technically feasible <str<strong>on</strong>g>for</str<strong>on</strong>g> your<br />

organizati<strong>on</strong>. As with the previous strategy, two migrati<strong>on</strong> opti<strong>on</strong>s are available when<br />

moving <strong>to</strong> a Win32-based plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m. The first is <strong>to</strong> per<str<strong>on</strong>g>for</str<strong>on</strong>g>m a port of the applicati<strong>on</strong>, and<br />

the other is <strong>to</strong> rewrite the applicati<strong>on</strong> using the Win32 APIs.<br />

A port can be used <str<strong>on</strong>g>for</str<strong>on</strong>g> most applicati<strong>on</strong>s that have been developed in Java, Perl, PHP, or<br />

Pyth<strong>on</strong>, which are available <strong>on</strong> both the <strong>UNIX</strong> and Windows plat<str<strong>on</strong>g>for</str<strong>on</strong>g>ms. APIs are available<br />

<str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>SQL</strong> <strong>Server</strong> in a majority of cases. A port requires minimum changes <strong>to</strong> be d<strong>on</strong>e <strong>to</strong><br />

the source code, and a port uses <strong>UNIX</strong>-standard compatible libraries and utilities that<br />

exist <strong>on</strong> the Windows plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m. Compared <strong>to</strong> a port, the source code in a rewrite requires<br />

c<strong>on</strong>siderable changes <strong>to</strong> operate in the new envir<strong>on</strong>ment. When possible, c<strong>on</strong>sider<br />

rewriting the applicati<strong>on</strong> using .NET instead of Win32.


176 Developing: Applicati<strong>on</strong>s — Introducti<strong>on</strong><br />

Quick Port Using Windows Services <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>UNIX</strong><br />

Applicati<strong>on</strong>s <strong>on</strong> <strong>UNIX</strong> can be rehosted <strong>to</strong> an envir<strong>on</strong>ment <strong>on</strong> Windows (Interix) that is<br />

similar <strong>to</strong> <strong>UNIX</strong>. Interix is a complete, POSIX-compliant (Portable Operating System<br />

Interface) development envir<strong>on</strong>ment that is tightly integrated with the Windows kernel. It<br />

is a part of the Windows Services <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>UNIX</strong> 3.5 product suite from Microsoft.<br />

One of the quickest migrati<strong>on</strong> paths possible is <strong>to</strong> port the code directly <strong>to</strong><br />

Windows Services <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>UNIX</strong>. Interix allows native <strong>UNIX</strong> applicati<strong>on</strong>s and scripts <strong>to</strong> work<br />

al<strong>on</strong>gside Windows applicati<strong>on</strong>s. The best way <strong>to</strong> view Interix is <strong>to</strong> understand it as a<br />

POSIX-compliant versi<strong>on</strong> of <strong>UNIX</strong> built <strong>on</strong> <strong>to</strong>p of the Windows kernel. Importantly, Interix<br />

is not an emulati<strong>on</strong> of the <strong>UNIX</strong> envir<strong>on</strong>ment <strong>on</strong> the Windows APIs. Migrati<strong>on</strong> using<br />

Windows Services <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>UNIX</strong> involves obtaining the source code, installing it in the Interix<br />

development envir<strong>on</strong>ment, modifying the c<strong>on</strong>figurati<strong>on</strong> scripts and makefiles, and<br />

recompiling the applicati<strong>on</strong>. This strategy is referred <strong>to</strong> as a quick port. As with any other<br />

migrati<strong>on</strong> strategies, the data access (<strong>SQL</strong>, PL/<strong>SQL</strong>) has <strong>to</strong> be migrated <strong>to</strong> target a<br />

<strong>SQL</strong> <strong>Server</strong> database. A quick port is preferred if the client applicati<strong>on</strong> is closely tied <strong>to</strong><br />

<strong>UNIX</strong> utilities that are not available <strong>on</strong> Windows. This approach cannot rely <strong>on</strong> special<br />

libraries <str<strong>on</strong>g>for</str<strong>on</strong>g> which the source code is not available. Also, quick ports using<br />

Windows Services <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>UNIX</strong> cannot take advantage of most standard Windows<br />

functi<strong>on</strong>ality.<br />

The ported applicati<strong>on</strong> may be successful immediately, or it may require modificati<strong>on</strong>s <strong>to</strong><br />

account <str<strong>on</strong>g>for</str<strong>on</strong>g> the new hardware plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m, the target operating systems, and local<br />

c<strong>on</strong>figurati<strong>on</strong> in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong>. It may not be possible <strong>to</strong> determine whether a quick port is<br />

possible without actually c<strong>on</strong>ducting the port. Extensive testing of the applicati<strong>on</strong> is<br />

essential after the port <strong>to</strong> ensure that all features have been migrated successfully.<br />

Scenarios and Cases<br />

In the following chapters, these migrati<strong>on</strong> strategies are discussed in relati<strong>on</strong> <strong>to</strong> comm<strong>on</strong><br />

applicati<strong>on</strong> languages. All four strategies may not be available, feasible, or desirable <str<strong>on</strong>g>for</str<strong>on</strong>g><br />

each of the languages. For example, per<str<strong>on</strong>g>for</str<strong>on</strong>g>ming a quick port using<br />

Windows Services <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>UNIX</strong> is not discussed in the Perl chapter because Perl can run<br />

natively <strong>on</strong> the Windows plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m. Because the facilities available <strong>to</strong> Perl <strong>on</strong> Windows are<br />

much richer (including .NET) than those available <strong>to</strong> Perl <strong>on</strong> Windows Services <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>UNIX</strong>,<br />

migrating Perl applicati<strong>on</strong>s <strong>to</strong> a Windows envir<strong>on</strong>ment is preferred.<br />

Throughout Chapters 11 through 17, the migrati<strong>on</strong> strategies are divided in<strong>to</strong> specific<br />

scenarios that may be similar <strong>to</strong> existing situati<strong>on</strong>s that you will encounter. Each scenario<br />

may be split in<strong>to</strong> individual cases that detail the various opti<strong>on</strong>s available <str<strong>on</strong>g>for</str<strong>on</strong>g> a given<br />

scenario. For example, the migrati<strong>on</strong> strategy of porting may best apply <strong>to</strong> your situati<strong>on</strong>.<br />

In porting PHP applicati<strong>on</strong>s <strong>to</strong> run in the Windows envir<strong>on</strong>ment scenario, there are three<br />

cases that are discussed based <strong>on</strong> the database driver being utilized. These individual<br />

cases include detailed in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> regarding the use of ORA, OCI8, or ODBC database<br />

drivers <strong>to</strong> maintain c<strong>on</strong>nectivity in the soluti<strong>on</strong>.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 177<br />

11<br />

Developing: Applicati<strong>on</strong>s —<br />

<str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>SQL</strong><br />

and<br />

PL/<strong>SQL</strong><br />

Introducti<strong>on</strong><br />

A lthough <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and Microsoft® <strong>SQL</strong> <strong>Server</strong> both use the ANSI <strong>SQL</strong> language, each<br />

uses proprietary extensi<strong>on</strong>s <strong>to</strong> add functi<strong>on</strong>ality. <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> uses PL/<strong>SQL</strong>, while <strong>SQL</strong> <strong>Server</strong><br />

uses Transact <strong>SQL</strong>. This cha pter focuses <strong>on</strong> applicati<strong>on</strong> code that may need <strong>to</strong> be<br />

modified <str<strong>on</strong>g>for</str<strong>on</strong>g> use with <strong>SQL</strong> <strong>Server</strong> because of these extensi<strong>on</strong>s.<br />

This chapter should be used in c<strong>on</strong>juncti<strong>on</strong> with Chapters 12 through 17. These chapters<br />

provide in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <str<strong>on</strong>g>for</str<strong>on</strong>g> applicati<strong>on</strong>-specific languages, including Perl, PHP, Java, Pyth<strong>on</strong>,<br />

Pro*C, and <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms.<br />

No applicati<strong>on</strong> migrati<strong>on</strong> will be successful without a cle ar understanding of the <str<strong>on</strong>g>Oracle</str<strong>on</strong>g><br />

technologies that come in<strong>to</strong> play during an <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> database migrati<strong>on</strong> <strong>to</strong> the <strong>SQL</strong> <strong>Server</strong><br />

plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m. The strategy <str<strong>on</strong>g>for</str<strong>on</strong>g> applicati<strong>on</strong> c<strong>on</strong>versi<strong>on</strong> is broken down in<strong>to</strong> the following two<br />

segments:<br />

● Data access, which is discussed in this chapter.<br />

● Programming language a nd c<strong>on</strong>nectivity tier, which are discussed in Chapters 12<br />

through 17.<br />

<str<strong>on</strong>g>Migrating</str<strong>on</strong>g> Data Access<br />

The applicati<strong>on</strong> c<strong>on</strong>versi<strong>on</strong> development team is resp<strong>on</strong>sible <str<strong>on</strong>g>for</str<strong>on</strong>g> ensuring that<br />

applicati<strong>on</strong>s designed <str<strong>on</strong>g>for</str<strong>on</strong>g> the <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> source database work the same way with the<br />

migrated <strong>SQL</strong> <strong>Server</strong> target database.<br />

The applicati<strong>on</strong> migrati<strong>on</strong> process may appear<br />

complicated. Be<str<strong>on</strong>g>for</str<strong>on</strong>g>e doing the migrati<strong>on</strong> of<br />

the <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> producti<strong>on</strong> database, the DBA or applicati<strong>on</strong> developer should install a<br />

<strong>SQL</strong> <strong>Server</strong> test database. Applicati<strong>on</strong>s can then be modified and tested, if necessary, <strong>to</strong><br />

ensure their original functi<strong>on</strong>ality with the <strong>SQL</strong> <strong>Server</strong> database. Testing is necessary<br />

because of the core differences between <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong>.<br />

There are some architectural differences between each RDBMS. The terminology used<br />

<strong>to</strong> describe <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> architecture often has a completely different meaning in Microsoft<br />

<strong>SQL</strong> <strong>Server</strong>; <str<strong>on</strong>g>for</str<strong>on</strong>g> example, the term database has a different meaning. Additi<strong>on</strong>ally, both


178 Developing: Applicati<strong>on</strong>s — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>SQL</strong> and PL/<strong>SQL</strong><br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong> have made many proprietary extensi<strong>on</strong>s <strong>to</strong> the <strong>SQL</strong>-92 standard.<br />

These extensi<strong>on</strong>s are discussed throughout this chapter.<br />

F rom an applicati<strong>on</strong> develope r's perspective , <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong> manage data in<br />

similar ways. The internal differences between <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong> are significant, but<br />

if managed properly, have mi nimal impact <strong>on</strong> a migrated applicati<strong>on</strong>.<br />

The most signif icant migrati<strong>on</strong> issue that c<strong>on</strong>fr<strong>on</strong>ts the developer is the implementati<strong>on</strong> of<br />

the <strong>SQL</strong>-92 <strong>SQL</strong> language standard and the extensi<strong>on</strong>s that each RDBMS has <strong>to</strong> offer.<br />

Some developers use <strong>on</strong>ly st andard <strong>SQL</strong> language statements, preferring <strong>to</strong> keep their<br />

program code as generic as possible. Generally, this means restricting program code <strong>to</strong><br />

the entry-level <strong>SQL</strong>-92 standard, which is implemented c<strong>on</strong>sistently across many<br />

database products, including <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong>.<br />

Using RDBMS-specific extensi<strong>on</strong>s might produce unneeded complexity in the program<br />

code during the migrati<strong>on</strong>. For example, <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>'s DECODE functi<strong>on</strong> is a n<strong>on</strong>standard<br />

<strong>SQL</strong> extensi<strong>on</strong> specific <strong>to</strong> Ora cle. The CASE expressi<strong>on</strong> in <strong>SQL</strong> <strong>Server</strong> is not<br />

implemented in all database products.<br />

B oth the <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> DECODE and the <strong>SQL</strong> <strong>Server</strong> CASE expressi<strong>on</strong>s can per<str<strong>on</strong>g>for</str<strong>on</strong>g>m<br />

sophisticated c<strong>on</strong>diti<strong>on</strong>al evaluati<strong>on</strong>s from within a query. The alternative <strong>to</strong> using these<br />

functi<strong>on</strong>s is <strong>to</strong> per<str<strong>on</strong>g>for</str<strong>on</strong>g>m the functi<strong>on</strong> programmatically, which could require substantially<br />

more data be retrieved from the RDBMS.<br />

<strong>SQL</strong> has seen several sets of standards implemented and embraced by American<br />

Nati<strong>on</strong>al Standards Institute ( ANSI) and Internati<strong>on</strong>al Standards Organizati<strong>on</strong> (ISO).<br />

Although there are several enhancement releases of each standard set, the major<br />

releases are S QL-86, <strong>SQL</strong>-89 (also called <strong>SQL</strong>1), <strong>SQL</strong>-92 (also called <strong>SQL</strong>2) and <strong>SQL</strong>-<br />

99 (also called <strong>SQL</strong>3), with <strong>SQL</strong>-99 merging ANSI and ISO standards in<strong>to</strong> <strong>on</strong>e set.<br />

There are four levels or sets of features in <strong>SQL</strong>-92: entry-level, transiti<strong>on</strong>al, intermediate,<br />

and full. <strong>SQL</strong> <strong>Server</strong> 2000 Transact-<strong>SQL</strong> complies with the entry level of the <strong>SQL</strong>-92<br />

standard, and it supports many additi<strong>on</strong>al features from the intermediate and full levels of<br />

the standard.<br />

<strong>SQL</strong>-99 has two sets of features: core and n<strong>on</strong>-core. <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> 9i fully supports a majority of<br />

the core <strong>SQL</strong>-99 features, and it partially supports the n <strong>on</strong>-core features.<br />

T he <strong>SQL</strong>-92 entry-level feature set is very similar <strong>to</strong> the <strong>SQL</strong>-99 core feature set, which<br />

m eans <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> 9i supports entry level feature s of <strong>SQL</strong>-92 entry level. Even though both<br />

support many of t he standard features, <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong> do not use the same<br />

syntax. In additi<strong>on</strong>, each RDBMS has its own unique functi<strong>on</strong>ality and extensi<strong>on</strong>s.<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>SQL</strong> statements and Microsoft <strong>SQL</strong> <strong>Server</strong> T-<strong>SQL</strong> are compatible with each other<br />

in several areas with minimal changes in the syntax. All the basic and advanced<br />

functi<strong>on</strong>ality furnished by <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> can be achieved in <strong>SQL</strong> <strong>Server</strong> with ease.<br />

Though both these RDBMSs can be used <strong>to</strong> build robust and efficient systems, they differ<br />

r adically in the administrative functi<strong>on</strong>s and plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m dependence.<br />

This secti<strong>on</strong> shows how <strong>to</strong> arrive at T-<strong>SQL</strong> equivalents <str<strong>on</strong>g>for</str<strong>on</strong>g> the most comm<strong>on</strong> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>SQL</strong><br />

u sages, and it includes comprehensive coverage of all a spects of the <strong>SQL</strong> language<br />

i mplementati<strong>on</strong>.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 179<br />

Sample Tables<br />

The following tables are used in all the exa mples in this chapter.<br />

Table 11.1: Category Table<br />

COLUMN_NAME DATATYPE CONSTRAINT<br />

CATEGORYID VARCHAR(10) Primary Key<br />

CATEGORYNAME<br />

DESCRIPTION<br />

Table 11.2: Cus<strong>to</strong>mer Table<br />

VARCHAR(40)<br />

VARCHAR(50)<br />

COLUMN_NAME DATATYPE CONSTRAINT<br />

CUSTOMERID VARCHAR(10) Primary Key<br />

COMPANYNAME<br />

CONTACTNAME<br />

CONTACTTITLE<br />

ADDRESS<br />

CITY<br />

REGION<br />

POSTALCODE<br />

COUNTRY<br />

PHONE<br />

FAX<br />

Table 11.3: Employee Table<br />

VARCHAR(40)<br />

VARCHAR(40)<br />

VARCHAR(40)<br />

VARCHAR(50)<br />

VARCHAR(30)<br />

VARCHAR(30)<br />

VARCHAR(10)<br />

VARCHAR(30)<br />

NUMERIC(10.0)<br />

NUMERIC(10.0)<br />

COLUMN_NAME DATATYPE CONSTRAINT<br />

EMPLOYEEID VARCHAR(10) Primary Key<br />

LASTNAME<br />

FIRSTNAME<br />

TITLE<br />

TITLEOFCOURTESY<br />

BIRTHDATE<br />

HIREDATE<br />

ADDRESS<br />

CITY<br />

POSTALCODE<br />

COUNTRY<br />

VARCHAR(40)<br />

VARCHAR(40)<br />

VARCHAR(40)<br />

VARCHAR(50)<br />

DATETIME<br />

DATETIME<br />

VARCHAR(40)<br />

VARCHAR(30)<br />

NUMERIC(10.0)<br />

VARCHAR(10)<br />

REPORTINGTO VARCHAR(10) Foreign Key


180 Developing: Applicati<strong>on</strong>s — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>SQL</strong> and PL/<strong>SQL</strong><br />

Table 11.4: OrderMaster Table<br />

COLUMN_NAME DATATYPE CONSTRAINT<br />

ORDERID VARCHAR(10) Primary Key<br />

CUSTOMERID VARCHAR(10) Foreign Key<br />

EMPLOYEEID VARCHAR(10) Foreign Key<br />

ORDERDATE<br />

REQUIREDDATE<br />

SHIPPEDDATE<br />

SHIPVIA<br />

FREIGHT<br />

DATETIME<br />

DATETIME<br />

DATETIME<br />

VARCHAR(30)<br />

NUMERIC(10.0)<br />

SHIPNAME<br />

VARCHAR( 30)<br />

SHIPADDRESS<br />

SHIPCITY<br />

SHIPREGION<br />

SHIPPOSTALCODE<br />

Table 11.5: OrderDetails Table<br />

VARCHAR(30)<br />

VARCHAR(10)<br />

VARCHAR(30)<br />

VARCHAR(10)<br />

COLUMN_NAME DATATYPE CONSTRAINT<br />

ORDERID VARCHAR(10) Foreign Key<br />

PRODUCTID VARCHAR(10) Foreign Key<br />

UNITPRICE<br />

QUANTITY<br />

DISCOUNT<br />

Table 11.6: OrderPrice Table<br />

NUMERIC(10.2)<br />

NUMERIC(10.0)<br />

NUMERIC(10.0)<br />

COLUMN_NAME DATATYPE CONSTRAINT<br />

ORDERID VARCHAR(10) Foreign Key<br />

PRODUCTID VARCHAR(10) Foreign Key<br />

REVISEDPRICE<br />

REVISEDON<br />

Table 11.7: Product Table<br />

NUMERIC(10.2)<br />

DATETIME<br />

COLUMN_NAME DATATYPE CONSTRAINT<br />

PRODUCTID VARCHAR(10) Primary Key<br />

PRODUCTNAME<br />

VARCHAR(30)<br />

SUPPLIERID VARCHAR(30) Foreign Key<br />

CATEGORYID VARCHAR(10) Foreign Key<br />

QUANTITYPERUNIT<br />

UNITPRICE<br />

NUMERIC(10.0)<br />

NUMERIC(10.2)<br />

UNITINSTOCK NUMERIC(10.0)<br />

UNITSONORDER<br />

REORDERLEVEL<br />

DISCONTINUED<br />

NUMERIC(10.0)<br />

NUMERIC(10.0)<br />

NUMERIC(10.0)


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 181<br />

Table 11.8: Shippers Table<br />

COLUMN_NAME DATATYPE CONSTRAINT<br />

SHIPPERID VARCHAR(10) Primary Key<br />

COMPANYNAME<br />

VARCHAR(30)<br />

PHONE<br />

NUMERIC(10.0)<br />

Table 11.9: Suppliers Table<br />

COLUMN_NAME DATATYPE CONSTRAINT<br />

SUPPLIERID INT DENTITY Primary Key<br />

COMPANYNAME<br />

VARCHAR(30)<br />

CONTACTNAME<br />

VARCHAR(30)<br />

CONTACTTITLE<br />

VARCHAR(40)<br />

ADDRESS<br />

VARCHAR(40)<br />

CITY<br />

VARCHAR(30)<br />

POSTALCODE<br />

NUMERIC(10.0)<br />

COUNTRY<br />

VARCHAR(40)<br />

PHONE<br />

NUMERIC(10)<br />

FAX<br />

NUMERIC(10)<br />

Table 11.10: ShippedOrders Table<br />

COLUMN_NAME DATATYPE CONSTRAINT<br />

ORDERID VARCHAR(10) Foreign Key<br />

CUSTOMERID VARCHAR(10) Foreign Key<br />

EMPLOYEEID VARCHAR(10) Foreign Key<br />

ORDERDATE<br />

DATETIME<br />

REQUIREDDATE<br />

DATETIME<br />

SHIPPEDDATE<br />

DATETIME<br />

SHIPVIA<br />

VARCHAR(30)<br />

FREIGHT<br />

NUMERIC(10.0)<br />

SHIPNAME<br />

VARCHAR(30)<br />

SHIPADDRESS<br />

VARCHAR(30)<br />

SHIPCITY<br />

VARCHAR(10)<br />

SHIPREGION<br />

VARCHAR(30)<br />

SHIPPOSTALCODE VARCHAR(10)<br />

Migrati<strong>on</strong> Process Overview<br />

Recommended high-level steps <str<strong>on</strong>g>for</str<strong>on</strong>g> the migrati<strong>on</strong> process include:<br />

1. Extracti<strong>on</strong> of data access. Identify the <strong>SQL</strong> statements used in the applicati<strong>on</strong><br />

and make sure it will work with <strong>SQL</strong> <strong>Server</strong>. If some <strong>SQL</strong> statements are database-<br />

specific, rewrite them <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>SQL</strong> <strong>Server</strong>.<br />

2. Transacti<strong>on</strong> management. Accommodate changes in the transacti<strong>on</strong> because of<br />

the migrati<strong>on</strong>.


182 Developing: Applicati<strong>on</strong>s — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>SQL</strong> and PL/<strong>SQL</strong><br />

3. Fetch strategy. Pay special attenti<strong>on</strong> <strong>to</strong> cursor management and rewrite it in<br />

easier way by making use of effective cursor management available in<br />

<strong>SQL</strong> <strong>Server</strong> 2000. Try <strong>to</strong> avoid cursors being used by <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> applicati<strong>on</strong> if<br />

possible.<br />

4. Subprograms c<strong>on</strong>versi<strong>on</strong>. Identify all the procedures, functi<strong>on</strong>s, and triggers and<br />

rewrite in T-<strong>SQL</strong>.<br />

5. Job schedul<br />

ing. Batch jobs that are written in PL/<strong>SQL</strong> should be rewritten.<br />

6. Interface file c<strong>on</strong>versi<strong>on</strong>. For any inbound (text file -> table) jobs, pay attenti<strong>on</strong> <strong>to</strong><br />

the interface file and make sure there are no problems with the current <str<strong>on</strong>g>for</str<strong>on</strong>g>mat of<br />

the interface file. Pay attenti<strong>on</strong> <strong>to</strong> any outbound interface as well. Keep in mind that<br />

the date <str<strong>on</strong>g>for</str<strong>on</strong>g>mat between <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong> are different.<br />

7. Workflow au<strong>to</strong>mati<strong>on</strong>. Workflow au<strong>to</strong>mati<strong>on</strong> is implemented in the applicati<strong>on</strong>.<br />

The creati<strong>on</strong><br />

of Mail Ids is required.<br />

8. Per<str<strong>on</strong>g>for</str<strong>on</strong>g>man ce tuning. Tune the T-<strong>SQL</strong> statements wherever it is required.<br />

During these steps, the developer should look at the applicati<strong>on</strong> code and start<br />

c<strong>on</strong>verting <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>-specific code in<strong>to</strong> T-<strong>SQL</strong> compatible code. All major <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> commands<br />

and how <strong>to</strong> c<strong>on</strong>vert them in<strong>to</strong> T-<strong>SQL</strong> are discussed in detail throughout this chapter.<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong> both provide extensive support <str<strong>on</strong>g>for</str<strong>on</strong>g> XML, whose migrati<strong>on</strong> is not<br />

within the scope of this guide. For details <strong>on</strong> the SML support available in <strong>SQL</strong> <strong>Server</strong><br />

refer <strong>to</strong> http://msdn.microsoft.com/library/default.asp?url=/library/enus/architec/8_ar_cs_9oj8.asp.<br />

Step 1: Extracti<strong>on</strong> of Data Access<br />

The first step is <strong>to</strong> identify the <strong>SQL</strong> used in the applicati<strong>on</strong>. <strong>SQL</strong> includes Data<br />

Manipulati<strong>on</strong> Language (DML), Data Query Language (DQL or, simply, queries), and<br />

opera<strong>to</strong>rs. The majority of <strong>SQL</strong> syntax is comm<strong>on</strong> between <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong> with<br />

minor variati<strong>on</strong>s.<br />

There are several different types of in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> in the <strong>SQL</strong> code that will need <strong>to</strong> be<br />

identified. If these types do not comply with the specificati<strong>on</strong>s and syntax of <strong>SQL</strong> <strong>Server</strong>,<br />

this in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> will need <strong>to</strong> be modified. An in-depth discussi<strong>on</strong> of the following <strong>to</strong>pics is<br />

included in this secti<strong>on</strong>:<br />

● Opera<strong>to</strong>rs<br />

● Functi<strong>on</strong>s<br />

● Queries<br />

● Data Manipulati<strong>on</strong> Language (DML)<br />

Opera<strong>to</strong>rs<br />

Opera<strong>to</strong>rs are used <str<strong>on</strong>g>for</str<strong>on</strong>g> many different purposes in <strong>SQL</strong>. Table 11. 11 displays these<br />

o pera<strong>to</strong>rs by type.<br />

Table 11.11 : Comm<strong>on</strong>ly Used Opera<strong>to</strong>rs<br />

Opera<strong>to</strong>r Type Example<br />

Arithmetic +, -, *, /<br />

Comparis<strong>on</strong> =, , =<br />

Logical<br />

AND,<br />

OR, NOT , XOR


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 183<br />

These opera<strong>to</strong>rs may play a role in the SELECT clause of a query ( <str<strong>on</strong>g>for</str<strong>on</strong>g> reporting<br />

purposes), or they may be used in a PL/<strong>SQL</strong> block <str<strong>on</strong>g>for</str<strong>on</strong>g> per<str<strong>on</strong>g>for</str<strong>on</strong>g>ming various calculati<strong>on</strong>s <strong>to</strong><br />

complete the transacti<strong>on</strong>.<br />

The in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> under the following heading describes how each of the opera<strong>to</strong>rs is used<br />

i n <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong>.<br />

Opera<strong>to</strong>r Precedence<br />

When multiple arithmetic opera<strong>to</strong>rs are used in a single query, the processing of the<br />

operati<strong>on</strong> takes place according <strong>to</strong> the precedence of the opera<strong>to</strong>rs. The precedence<br />

l evel of arithmetic opera<strong>to</strong>rs in an expressi<strong>on</strong> is multiplicati<strong>on</strong> (*), divisi<strong>on</strong> (/), modulo (%),<br />

additi<strong>on</strong> (+), c<strong>on</strong>catenati<strong>on</strong> (+), and subtracti<strong>on</strong> (-). Equati<strong>on</strong>s c<strong>on</strong>tained within<br />

parentheses take precedence and are per<str<strong>on</strong>g>for</str<strong>on</strong>g>med first. The order of executi<strong>on</strong> is from left<br />

<strong>to</strong> right.<br />

C<strong>on</strong>catenati<strong>on</strong> Opera<strong>to</strong>rs<br />

C<strong>on</strong>catenati<strong>on</strong> is per<str<strong>on</strong>g>for</str<strong>on</strong>g>med differently between <strong>SQL</strong> <strong>Server</strong> and <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>. The<br />

c<strong>on</strong>catenati<strong>on</strong> opera<strong>to</strong>r (<str<strong>on</strong>g>for</str<strong>on</strong>g> character strings) used in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> is “||” or CONCAT(string1,<br />

string2). The following example shows this syntax <str<strong>on</strong>g>for</str<strong>on</strong>g> each usage. Each of these<br />

statements will produce the same result in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>.<br />

SELECT FI RSTNAME || LASTNAME NAME FROM EMPLOYEE<br />

SELECT CONCAT(FIRSTNAME, LASTNAME) NAME FROM EMPLOYEE;<br />

In these statements, the first name is c<strong>on</strong>catenated with the last name and the label <str<strong>on</strong>g>for</str<strong>on</strong>g><br />

the field is NAME. <strong>SQL</strong> <strong>Server</strong> uses a different opera<strong>to</strong>r <str<strong>on</strong>g>for</str<strong>on</strong>g> c<strong>on</strong>catenati<strong>on</strong>. The<br />

c<strong>on</strong>catenati<strong>on</strong> op era<strong>to</strong>r (<str<strong>on</strong>g>for</str<strong>on</strong>g> character strings) used in <strong>SQL</strong> <strong>Server</strong> is “+.” The following<br />

example shows the first name c<strong>on</strong>catenated with the last name, al<strong>on</strong>g with empty space<br />

in between the names. The label<br />

<str<strong>on</strong>g>for</str<strong>on</strong>g> the field is NAME.<br />

SELECT FIRSTNAME + ‘ ‘ + LASTNAME As NAME FROM EMPLOYEE<br />

Comparis<strong>on</strong> Opera<strong>to</strong>rs<br />

C<strong>on</strong>diti<strong>on</strong>s are evaluated using comparis<strong>on</strong> opera<strong>to</strong>rs, including "=", ">" and ">=", “


184 Developing: Applicati<strong>on</strong>s — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>SQL</strong> and PL/<strong>SQL</strong><br />

Opera<strong>to</strong>r Meaning<br />

ALL TRUE if all of a set of comparis<strong>on</strong>s are TRUE<br />

AND<br />

TRUE if both Boolean expressi<strong>on</strong>s are TRUE<br />

ANY TRUE if any <strong>on</strong>e of a set of comparis<strong>on</strong>s is TRUE<br />

BETWEEN TRUE if the operand is within a range<br />

EXISTS<br />

IN<br />

TRUE if a subquery c<strong>on</strong>tains any rows<br />

TRUE if the operand is equal <strong>to</strong> <strong>on</strong>e of a list of expressi<strong>on</strong>s<br />

LIKE TRUE if the opera nd matches a pattern<br />

NOT Reverses the value of any other Boolean opera<strong>to</strong>r<br />

SOME<br />

IS NULL<br />

TRUE if some of a set of comparis<strong>on</strong>s are TRUE<br />

TRUE if operand is NULL<br />

IS NOT NULL TRUE if operand is not NULL<br />

OR<br />

Datatype Precedence<br />

TRUE if either Boolean express i<strong>on</strong> is TRUE<br />

Each column valu e and c<strong>on</strong>stant in a <strong>SQL</strong> statement has a datatype that is associated<br />

with a specific s<strong>to</strong>rage <str<strong>on</strong>g>for</str<strong>on</strong>g>mat, c<strong>on</strong>straints, and a valid range of values. When a table is<br />

created, a datatype is specified fo r each column.<br />

Arithmetic operati<strong>on</strong>s per<str<strong>on</strong>g>for</str<strong>on</strong>g>med <strong>on</strong> columns and c<strong>on</strong>stants of different datatypes, such<br />

as INT and SMALLINT, are called as mixed mode arithmetic operati<strong>on</strong>s. In mixed mode<br />

arithmetic operati<strong>on</strong>s, the lower d atatype value is c<strong>on</strong>verted in<strong>to</strong> a h igher datatype value<br />

according <strong>to</strong> datatype precedence.<br />

Datatype c<strong>on</strong>versi<strong>on</strong> is often needed <strong>to</strong> attain compatibility during calculati<strong>on</strong>,<br />

c<strong>on</strong>catenati<strong>on</strong>, or comparis<strong>on</strong> of values.<br />

Functi<strong>on</strong>s<br />

In many places, built-in functi<strong>on</strong>s are used <str<strong>on</strong>g>for</str<strong>on</strong>g> c<strong>on</strong>versi<strong>on</strong> and <str<strong>on</strong>g>for</str<strong>on</strong>g> o ther purposes. Some<br />

comm<strong>on</strong>ly used functi<strong>on</strong>s are defined and discussed here with examples provided <str<strong>on</strong>g>for</str<strong>on</strong>g><br />

their use. Some f uncti<strong>on</strong>s that are available in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> are not available in<br />

<strong>SQL</strong> <strong>Server</strong> 2000 or earlier versi<strong>on</strong>s. However, those functi<strong>on</strong>s can<br />

be written in<br />

<strong>SQL</strong> <strong>Server</strong> with the same name and the same fun cti<strong>on</strong>ality. They are called user-defined<br />

functi<strong>on</strong>s. Some user-defined functi<strong>on</strong>s are described later in this chapter.<br />

Number and Mathematical Functi<strong>on</strong>s<br />

Table 11.13 details the differences in syntax and usage between <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong>.<br />

These functi<strong>on</strong>s are all mathematically based.<br />

Table 11.13: Mathematical Functi<strong>on</strong>s in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong><br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Descripti<strong>on</strong> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>SQL</strong> <strong>Server</strong> <strong>SQL</strong> <strong>Server</strong><br />

Functi<strong>on</strong> Example Functi<strong>on</strong> Example<br />

ABS<br />

Returns the ABS (-20) ABS ABS(-20)<br />

absolute value<br />

of n<br />

ACOS<br />

Returns cosine<br />

of n. n must be<br />

between –1<br />

and 1<br />

ACOS (.4) ACOS ACOS(.4)


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 185<br />

CEIL Returns the CEIL (12.3) CEILING CEILING (12.3)<br />

smallest returns 13<br />

returns 13<br />

integer greater<br />

than n<br />

FLOOR Returns the FLOOR (12.3) FLOOR FLOOR (12.3)<br />

smallest<br />

integer smaller<br />

than n<br />

returns 12<br />

returns 12<br />

MOD<br />

Returns the MOD (12,5) % 12%5 returns 2<br />

reminder of m<br />

divided by n<br />

returns 2<br />

POWER Computes the<br />

value of<br />

POWER (10,5)<br />

returns 100000<br />

POWER POWER (10,5)<br />

returns 100000<br />

argument 1<br />

raised <strong>to</strong> the<br />

power of<br />

argument 2<br />

ROUND<br />

Returns the<br />

nearest value<br />

of the decimal<br />

as per the<br />

precisi<strong>on</strong><br />

specified<br />

Truncates the<br />

decimal<br />

ROUND<br />

(10.125,2)<br />

ROUND<br />

ROUND<br />

(10.125,2)<br />

returns 10.13 returns 10.130<br />

TRUNC TRUNC (12.54) CONVERT<br />

returns 12<br />

CONVERT<br />

(INTEGER,<br />

12.54) returns<br />

12<br />

Character Functi<strong>on</strong>s<br />

Table 11.14 details the differences in syntax and usage between <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong>.<br />

These functi<strong>on</strong>s are all related <strong>to</strong> text strings and characters.<br />

Table 11.14: Character Functi<strong>on</strong>s in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong><br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g><br />

Functi<strong>on</strong><br />

Descripti<strong>on</strong> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g><br />

Example<br />

CHR Returns the CHR (65)<br />

character <str<strong>on</strong>g>for</str<strong>on</strong>g> returns A<br />

the ASCII value<br />

CONCAT Appends two CONCAT<br />

string value s ('Tom', 'Mike')<br />

return Tom<br />

Mike<br />

INITCAP Gives<br />

INITCAP ('terry<br />

uppercase <strong>to</strong><br />

adams') returns<br />

the title (Title<br />

Terry Adams<br />

case)<br />

<strong>SQL</strong> <strong>Server</strong> <strong>SQL</strong> <strong>Server</strong><br />

Functi<strong>on</strong> Example<br />

CHAR CHAR (65)<br />

returns A<br />

+ 'Tom' + 'Mike'<br />

returns Tom<br />

Mike<br />

No equivalent<br />

functi<strong>on</strong><br />

An algorithm<br />

can be written<br />

<str<strong>on</strong>g>for</str<strong>on</strong>g> equivalent<br />

functi<strong>on</strong>ality


186 Developing: Applicati<strong>on</strong>s — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>SQL</strong> and PL/<strong>SQL</strong><br />

LOWER<br />

Returns the<br />

lowercase of<br />

the string<br />

LOWER ('TIM')<br />

returns tim<br />

LOWER<br />

LTRIM Trims the LTRIM (' TIM') LTRIM<br />

leading spaces<br />

in a given<br />

returns 'TIM'<br />

String<br />

REPLACE Replaces a REPLACE<br />

REPLACE<br />

matching String ('TIM','I','o')<br />

with a new returns ToM<br />

String in a<br />

given String<br />

RPAD<br />

Pad characters RPAD<br />

No equivalent<br />

<strong>to</strong> the right side ('USA',5,'*')<br />

functi<strong>on</strong><br />

of the string returns USA**<br />

LPAD<br />

SOUNDEX<br />

SUBSTR<br />

Pad characters<br />

<strong>to</strong> the left side<br />

of the string<br />

SOUNDEX<br />

functi<strong>on</strong> lets<br />

you <strong>to</strong> compare<br />

words that are<br />

spelled<br />

differently but<br />

sound alike<br />

To take <strong>on</strong>ly a<br />

few characters<br />

LPAD<br />

('USA',5,'*')<br />

returns **USA<br />

SOUNDEX<br />

('CHARLOTTE'<br />

) is equal <strong>to</strong><br />

SOUNDEX('CH<br />

ARLOTE')<br />

SUBSTRING<br />

('Bikes', 1,4)<br />

No equivalent<br />

functi<strong>on</strong><br />

SOUNDEX<br />

SUBSTRING<br />

LOWER('TIM')<br />

returns tim<br />

LTRIM(' TIM')<br />

returns 'TIM'<br />

REPLACE('TIM<br />

','i','o') returns<br />

ToM<br />

An algorithm<br />

can be written<br />

<str<strong>on</strong>g>for</str<strong>on</strong>g> equivalent<br />

functi<strong>on</strong>ality<br />

An algorithm<br />

can be written<br />

<str<strong>on</strong>g>for</str<strong>on</strong>g> equivalent<br />

functi<strong>on</strong>ality<br />

SOUNDEX<br />

('CHARLOTTE'<br />

) is equal <strong>to</strong><br />

SOUNDEX('CH<br />

ARLOTE')<br />

SUBSTRING<br />

('Bikes', 1,4)<br />

from a string returns Bike returns Bike<br />

TRANSLATE Translate a This functi<strong>on</strong> in No equivalent An algorithm<br />

character <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> is used functi<strong>on</strong> can be written<br />

string. Used <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>to</strong> c<strong>on</strong>vert a<br />

<str<strong>on</strong>g>for</str<strong>on</strong>g> equivalent<br />

encrypti<strong>on</strong> string in<strong>to</strong><br />

another <str<strong>on</strong>g>for</str<strong>on</strong>g>m.<br />

functi<strong>on</strong>ality<br />

Low level of<br />

encrypti<strong>on</strong> is<br />

d<strong>on</strong>e using<br />

this.<br />

TRIM<br />

UPPER<br />

ASCII<br />

To remove the<br />

leading and<br />

trailing spaces<br />

of a string<br />

Returns the<br />

uppercase of<br />

the string<br />

Returns the ASCII ('A')<br />

ASCII value of returns 65<br />

TRIM (' THIS<br />

IS TEST ')<br />

returns THIS IS<br />

LTRIM and<br />

RTRIM can be<br />

combined<br />

RTRIM(LTRIM(<br />

' THIS IS TEST<br />

')) returns THIS<br />

TEST<br />

IS TEST<br />

UPPER ('tim') UPPER UPPER('tim')<br />

returns TIM<br />

returns TIM<br />

ASCII<br />

ASCII('A')<br />

returns 65


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 187<br />

the character<br />

INSTR<br />

LENGTH<br />

Used <strong>to</strong> find<br />

the locati<strong>on</strong> of<br />

a sub string or<br />

a character<br />

inside a string<br />

Returns the<br />

length of a<br />

given string<br />

INSTR<br />

('NORTH<br />

CAROLINA','O<br />

R', 1) returns 2<br />

LENGTH<br />

('TOM') returns<br />

3<br />

CHARINDEX<br />

LEN<br />

CHARINDEX<br />

('OR','NORTH<br />

CAROLINA', 1)<br />

returns 2<br />

LEN ('TOM')<br />

returns 3<br />

Date Functi<strong>on</strong>s<br />

Table 11.15 details the differences in syntax and usage between <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong>.<br />

These functi<strong>on</strong>s are all date-based.<br />

Table 11.15: Date Functi<strong>on</strong>s in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong><br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Descripti<strong>on</strong> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>SQL</strong> <strong>Server</strong> <strong>SQL</strong> <strong>Server</strong><br />

Functi<strong>on</strong><br />

Example Functi<strong>on</strong> Example<br />

ADD_MONTH<br />

S<br />

NEXT_DAY<br />

SYSDATE<br />

TO_CHAR<br />

TO_DATE<br />

To add number<br />

of m<strong>on</strong>ths <str<strong>on</strong>g>for</str<strong>on</strong>g> a<br />

given date<br />

NEXT_DAY<br />

functi<strong>on</strong> returns<br />

the first<br />

weekday later<br />

than the<br />

passed date<br />

Returns the<br />

current date<br />

TO_CHAR is<br />

used when an<br />

INTEGER or<br />

DATE value<br />

needs <strong>to</strong> be<br />

c<strong>on</strong>verted in<strong>to</strong><br />

String<br />

Any given<br />

string in a valid<br />

date <str<strong>on</strong>g>for</str<strong>on</strong>g>mat can<br />

be c<strong>on</strong>verted<br />

in<strong>to</strong> DATE<br />

Datatype<br />

ADD_MONTH<br />

S ('15-NOV-<br />

2004', 1)<br />

returns '15-<br />

DEC-2004'<br />

NEXT_DAY<br />

(SYSDATE,<br />

'FRIDAY')<br />

returns the<br />

date of the<br />

coming Friday<br />

SYSDATE<br />

returns the<br />

current date<br />

TO_CHAR<br />

(sysdate,<br />

'MM/DD/YY')<br />

TO_DATE ('12-<br />

MAY-<br />

2003','DD-<br />

MON-YYYY')<br />

DATEADD<br />

No equivalent<br />

functi<strong>on</strong><br />

DATEADD<br />

(MM, 1,'15-<br />

NOV-2004' )<br />

returns '15-<br />

DEC-2004'<br />

An algorithm<br />

can be written<br />

<str<strong>on</strong>g>for</str<strong>on</strong>g> equivalent<br />

functi<strong>on</strong>ality<br />

GETDATE () GETDATE ()<br />

returns the<br />

current date<br />

with time stamp<br />

CAST or<br />

CONVERT<br />

CAST<br />

CONVERT<br />

(char, getdate()<br />

, 1) returns<br />

date in<br />

MM/DD/YY<br />

<str<strong>on</strong>g>for</str<strong>on</strong>g>mat.<br />

CAST ('12-<br />

MAY-2003<br />

12:00:00' as<br />

DATETIME)<br />

The CONVERT functi<strong>on</strong> is used in <strong>SQL</strong> <strong>Server</strong> <strong>to</strong> change the date <str<strong>on</strong>g>for</str<strong>on</strong>g>mat. This is<br />

equivalent <strong>to</strong> the TO_CHAR functi<strong>on</strong> of <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>. CONVERT<br />

has three parameters. The


188 Developing: Applicati<strong>on</strong>s — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>SQL</strong> and PL/<strong>SQL</strong><br />

first parameter is datatype. The sec<strong>on</strong>d parameter is <str<strong>on</strong>g>for</str<strong>on</strong>g> the column <strong>to</strong> be <str<strong>on</strong>g>for</str<strong>on</strong>g>matted. The<br />

third parameter is the desired <str<strong>on</strong>g>for</str<strong>on</strong>g>mat. Please see the list of <str<strong>on</strong>g>for</str<strong>on</strong>g>mats and the<br />

corresp<strong>on</strong>ding <str<strong>on</strong>g>for</str<strong>on</strong>g>mula in Table 11.16.<br />

Table 11.16: CONVERT Functi<strong>on</strong> Formats in <strong>SQL</strong> <strong>Server</strong><br />

WITH CENTURY (YYYY)<br />

INPUT/OUTPUT<br />

0 OR 100 (*) MON DD YYYY HH:MIAM (OR PM)<br />

101 MM/DD/YY<br />

102 YY.MM.DD<br />

103 DD/MM/YY<br />

104 DD.MM.YY<br />

105 DD-MM-YY<br />

106<br />

DD MON YY<br />

107 MON DD, YY<br />

108 HH:MM:SS<br />

9 OR 109 (*)<br />

DEFAULT + MILLISECONDS<br />

110<br />

MON DD YYYY HH:MI:SS:MMMAM (OR<br />

PM)<br />

MM-DD-YY<br />

111 YY/MM/DD<br />

112 YYMMDD<br />

13 OR 113 (*) DD MON YYYY HH:MM:SS:MMM(24H)<br />

114 HH:MI:SS:MMM(24H)<br />

20 OR 120 (*) YYYY-MM-DD HH:MI:SS(24H)<br />

21 OR 121 (*) YYYY-MM-DD HH: MI: SS.MMM (24H)<br />

130* DD MON YYYY HH:MI:SS:MMMAM<br />

131* DD/MM/YY HH:MI:SS:MMMAM<br />

C<strong>on</strong>diti<strong>on</strong>al Functi<strong>on</strong>s<br />

C<strong>on</strong>diti<strong>on</strong>al functi<strong>on</strong>s are used <strong>to</strong> compare values or <strong>to</strong> evaluate a Boolean expressi<strong>on</strong>.<br />

Table 11.17 compares these functi<strong>on</strong>s between <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong>.<br />

Table 11.17: C<strong>on</strong>diti<strong>on</strong>al Functi<strong>on</strong>s in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong><br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Descripti<strong>on</strong> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>SQL</strong> <strong>Server</strong> <strong>SQL</strong> <strong>Server</strong><br />

Functi<strong>on</strong> Example Functi<strong>on</strong> Example<br />

NVL To return a NVL (SALARY, ISNULL ISNULL<br />

default value if 0) returns 0 if<br />

(SALARY, 0)<br />

the expressi<strong>on</strong> the column returns 0 if the<br />

is null<br />

value (SALARY<br />

column) is null<br />

column value<br />

(SALARY<br />

column) is null<br />

NVL2 To return a NVL2 (Salary, CASE<br />

CASE SALARY<br />

value if the Salary*2, 0) WHEN null<br />

expressi<strong>on</strong> is<br />

null or null<br />

returns two<br />

times the<br />

salary if not null<br />

and 0 if null<br />

THEN 0<br />

ELSE<br />

SALARY*2<br />

END


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 189<br />

NULLIF<br />

Returns a null<br />

value if the two<br />

specified<br />

expressi<strong>on</strong>s<br />

are equivalent<br />

NULLIF<br />

(SYSDATE,<br />

SYSDATE)<br />

returns NULL<br />

NULLIF<br />

NULLIF<br />

(GETDATE (),<br />

GETDATE ())<br />

returns NULL<br />

DECODE Used <strong>to</strong> DECODE(DIS CASE<br />

CASE<br />

evaluate the CONTINUED, DISCONTINUE<br />

values with "if- 0, 'No', 1, 'Yes',<br />

D<br />

else" logic. 'NA')<br />

WHEN 0 THEN<br />

'No'<br />

WHEN 1 THEN<br />

'Yes'<br />

ELSE 'NA'<br />

END<br />

CASE<br />

Used <strong>to</strong><br />

evaluate the<br />

values with "if-<br />

CASE<br />

disc<strong>on</strong>tinued<br />

WHEN 0 THEN<br />

CASE<br />

CASE<br />

disc<strong>on</strong>tinued<br />

WHEN 0 THEN<br />

else" logic. 'No'<br />

'No'<br />

WHEN 1 THEN<br />

'Yes'<br />

ELSE 'NA'<br />

END<br />

WHEN 1 THEN<br />

'Yes'<br />

ELSE 'NA'<br />

END<br />

Queries<br />

The SELECT statement is used <strong>to</strong> query the database and retrieve data. SELECT can be<br />

combined with some DDL and DML statements <strong>to</strong> per<str<strong>on</strong>g>for</str<strong>on</strong>g>m relati<strong>on</strong>al operati<strong>on</strong>s. The<br />

following different clauses comm<strong>on</strong>ly used with SELECT in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong> are<br />

discussed in the remainder of this secti<strong>on</strong>.<br />

● Simple queries<br />

● Joins<br />

● Database links<br />

● Group by<br />

● Case<br />

● Set opera<strong>to</strong>rs<br />

● Rownum<br />

Optimizer hints are not covered in this guidance. Both <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong> use costthat<br />

can be used <strong>to</strong> influence the optimizer. The<br />

based optimizers and offer hints<br />

optimizer hints used with <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> are not available in <strong>SQL</strong> <strong>Server</strong>. For the various types of<br />

hints available in <strong>SQL</strong> <strong>Server</strong> refer <strong>to</strong><br />

http://msdn.microsoft.com/library/default.asp?url=/library/enus/acdata/ac_8_qd_03_8upf.asp.<br />

Simple Queries<br />

A simple query is defined as a SELECT statement that retrieves data from a single table<br />

with or without filter c<strong>on</strong>diti<strong>on</strong>. Because<br />

this is a standard command, there are no<br />

differences in syntax or usage between <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong>. The following example is<br />

a valid statement <str<strong>on</strong>g>for</str<strong>on</strong>g> both <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong>.


190 Developing: Applicati<strong>on</strong>s — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>SQL</strong> and PL/<strong>SQL</strong><br />

SELECT * FROM CUSTOMER;<br />

Joins<br />

Joins play a major role when meaningful in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> needs <strong>to</strong> be retrieved from more<br />

than <strong>on</strong>e table. Often, reports or intricate queries require data from two or more tables.<br />

The data from multiple tables must be logically related. <strong>SQL</strong> combines data from multiple<br />

tables using joins in<strong>to</strong> a single result set.<br />

Joins can be of following types:<br />

● Inner join<br />

● Equi-join<br />

● N<strong>on</strong>-equi join<br />

●<br />

●<br />

Outer join<br />

● Left outer join<br />

● Right outer join<br />

● Full outer join<br />

Self-join<br />

Inner Join<br />

Inner join is the normal join that is per<str<strong>on</strong>g>for</str<strong>on</strong>g>med am<strong>on</strong>g tables <strong>to</strong> fetch the matching data.<br />

Inner join can be either an equi-join or n<strong>on</strong>-equi join. Both equi and n<strong>on</strong>-equi join are<br />

explained under the following headings.<br />

Equi-Join<br />

An equi-join equates fields from two or more tables <strong>to</strong> fetch matching data from the tables<br />

selected. There is c<strong>on</strong>siderable difference in the syntax of an equi-join between <str<strong>on</strong>g>Oracle</str<strong>on</strong>g><br />

and <strong>SQL</strong> <strong>Server</strong>.<br />

The standard <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> equi-join syntax is shown in the following example:<br />

SELECT TABLE1. FIELD1, TABLE2.FIELD1, TABLE2.FILED2<br />

FROM TABLE1, TABLE2<br />

WHERE TABLE1.FIELD3 = TABLE2.FIELD3<br />

AND TABLE1.FIELD4 = TABLE2.FIELD4<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> 9i equi-joins are slightly different; the syntax is modified <strong>to</strong> comply with the ANSI<br />

standard. The <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> 9i syntax is shown in the following example:<br />

SELECT TABLE1.FIELD1, TABLE2.FIELD1, TABLE2.FIELD2<br />

FROM (TABLE1 INNER JOIN TABLE2 ON TABLE1.FIELD3 = TABLE2.FIELD3<br />

AND TABLE1.FIELD4 = TABLE2.FIELD4)<br />

The <strong>SQL</strong> <strong>Server</strong> syntax is also slightly different, and it is shown in the following example:<br />

SELECT TABLE1.FIELD1, TABLE2.FIELD1, TABLE2.FIELD2<br />

FROM TABLE1 INNER JOIN TABLE2<br />

ON TABLE1.FIELD3_=_TABLE2.FIELD3<br />

AND TABLE1.FIELD4 = TABLE2.FIELD4<br />

For example, a company needs <strong>to</strong> create a report with the following in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong>:<br />

● Product name<br />

● Price<br />

● Supplier’s company name<br />

● Category name


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 191<br />

For a product produced by the example company, the corresp<strong>on</strong>ding supplier’s company<br />

name and the corresp<strong>on</strong>ding category name have <strong>to</strong> be displayed. The PRODUCT table<br />

has SUPPLIERID and CATEGORYID, but not their corresp<strong>on</strong>ding names. Procedures<br />

<str<strong>on</strong>g>for</str<strong>on</strong>g> using the PRODUCTNAME <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>, <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> 9i, and <strong>SQL</strong> <strong>Server</strong> are shown in the<br />

following examples.<br />

In <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>, the inner join will provide the needed in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong>:<br />

SELECT A.PRODUCTNAME, A.UNITPRICE, B.COMPANYNAME, C.CATEGORYNAME<br />

FROM PRODUCT A, SUPPLIERS B, CATEGORY C<br />

WHERE A.SUPPLIERID = B.SUPPLIERID<br />

AND A.CATEGORYID = C.CATEGORYID<br />

The following code produces the same inner join in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> 9i:<br />

SELECT A.PRODUCTNAME, A.UNITPRICE, B.COMPANYNAME, C.CATEGORYNAME<br />

FROM (PRODUCT A INNER JOIN SUPPLIERS B<br />

ON A.SUPPLIERID = B.SUPPLIERID INNER JOIN CATEGORY C<br />

ON A.CATEGORYID = C.CATEGORYID<br />

)<br />

The <strong>SQL</strong> <strong>Server</strong> syntax is the same as the preceding <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> 9i syntax.<br />

Self Joins<br />

Self joins can be used when <strong>on</strong>e row in a table relates itself with other rows in the same<br />

table. That is, the same table is used twice <str<strong>on</strong>g>for</str<strong>on</strong>g> comparis<strong>on</strong>. The same table must be<br />

exhibited as two different tables by using different aliases. This functi<strong>on</strong> is available in<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong>, though there are slight differences in syntax. The syntax <str<strong>on</strong>g>for</str<strong>on</strong>g><br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> self joins is provided here:<br />

SELECT A.FIELD1, A.FIELD2, B.FIELD1, B.FIELD2<br />

FROM TABLE1 A, TABLE1 B<br />

WHERE A.FIELD1 = B.FIELD1<br />

AND A.FIELD2 < B.FIELD2<br />

The <strong>SQL</strong> <strong>Server</strong> syntax is shown in the following example. Note the differences in the<br />

third and fourth lines of the statement.<br />

SELECT A.FIELD1, A.FIELD2, B.FIELD1, B.FIELD2<br />

FROM TABLE1 A JOIN TABLE1 B<br />

ON A.FIELD1 = B.FIELD1<br />

WHERE A.FIELD2 < B.FIELD2<br />

C<strong>on</strong> sider a case in which the result set must return a list of all companies in the same city<br />

as the company “ABC Inc.”<br />

In <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>, the statement would appear as:<br />

SELECT B.COMPANYNAME<br />

FROM CUSTOMER A, CUSTOMER B<br />

WHERE A.CITY = B.CITY<br />

AND A.COMPANYNAME = 'ABC Inc'<br />

In <strong>SQL</strong> <strong>Server</strong>, the same result set can be returned using the following statement:<br />

SELECT B.COMPANYNAME<br />

FROM CUSTOMER A JOIN CUSTOMER B<br />

ON A.CITY = B.CITY<br />

WHERE A COMPANYNAME = 'ABC Inc'


192 Developing: Applicati<strong>on</strong>s — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>SQL</strong> and PL/<strong>SQL</strong><br />

N<strong>on</strong>-Equi Joins<br />

N<strong>on</strong> -equi joins are used when there is not a direct link criteri<strong>on</strong> between the tables. It is<br />

simply a join where the joining criteria are anything other than “=.” The difference in the<br />

syntax between <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong> in cases of n<strong>on</strong>-equi join is a minor difference in<br />

the opera<strong>to</strong>rs used <strong>to</strong> notify the n<strong>on</strong>-equi join. The <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> syntax is provided in the<br />

following example:<br />

SELECT A.FIELD1, A.FIELD2, A.FIELD3, B.FIELD4<br />

FROM TABLE1 A, TABLE2 B<br />

WHERE A.FIELD1 = B.FIELD1<br />

AND A.FIELD2 B.FIELD2<br />

The <strong>SQL</strong> <strong>Server</strong> syntax is provided in the following example. Note the use of the inner<br />

join opera<strong>to</strong>r.<br />

SELECT A.FIELD1, A.FIELD2, A.FIELD3, B.FIELD4<br />

FROM TABLE1 A INNER JOIN TABLE2 B<br />

ON A.FIELD1 = B.FIELD1<br />

WHERE A.FIELD2 B.FIELD2<br />

For example, imagine a case where there is a need <strong>to</strong> retrieve those products listed<br />

under the same category but from different suppliers. In <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>, the statement can be<br />

created as follows:<br />

SELECT A.PRODUCTID, A.PRODUCTNAME, A.UNITPRICE<br />

FROM PRODUCT A, PRODUCT B<br />

WHERE A.CATEGORYID = B.CATEGORYID<br />

AND A.SUPPLIERID B.SUPPLIERID<br />

The same result can be accomplished in <strong>SQL</strong> <strong>Server</strong>, as shown in the following example:<br />

SELECT A.PRODUCTID, A.PRODUCTNAME, A.UNITPRICE<br />

FROM PRODUCT A INNER JOIN PRODUCT B<br />

ON A.CATEGORYID = B.CATEGORYID<br />

AND A.SUPPLIERID B.SUPPLIERID<br />

Outer Joins<br />

A join is termed as outer join when the result set c<strong>on</strong>tains all the rows from <strong>on</strong>e table and<br />

<strong>on</strong>ly the matching rows from the other table.<br />

An outer join can be a left outer join or a right outer join. Outer join syntax in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and<br />

<strong>SQL</strong> <strong>Server</strong> remained different until the release of <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> 9i. Thereafter, both follow ANSI<br />

standards of using INNER JOIN or OUTER JOIN in words instead of opera<strong>to</strong>rs.<br />

All rows are retrieved from the left table referenced with a left outer join. Here, the outer<br />

join opera<strong>to</strong>r (+) is placed beside the table that is <strong>to</strong> the left of the "=" opera<strong>to</strong>r during the<br />

join.<br />

● <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> — left outer join<br />

The syntax <str<strong>on</strong>g>for</str<strong>on</strong>g> left outer join is as follows:<br />

SELECT A.FIELD1, A.FIELD2, B.FIELD1, B.FIELD2<br />

FROM TABLE1 A, TABLE1 B<br />

WHERE A.FIELD1(+) = B.FIELD1<br />

Example <str<strong>on</strong>g>for</str<strong>on</strong>g> left outer join is:<br />

●<br />

SELECT A.PRODUCTNAME, A.CATEGORYID, B.COMPANYNAME, B.CONTACTNAME<br />

FROM PRODUCT A, SUPPLIERS B<br />

WHERE A.SUPPLIERID(+) = B.SUPPLIERID<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> 9i — left outer join


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 193<br />

The ANSI syntax <str<strong>on</strong>g>for</str<strong>on</strong>g> left outer join is as follows:<br />

SELECT A.FIELD1, A.FIELD2, B.FIELD1, B.FIELD2<br />

FROM TABLE1 A LEFT OUTER JOIN TABLE2 B<br />

ON A.FIELD1 = B.FIELD1<br />

Example <str<strong>on</strong>g>for</str<strong>on</strong>g> ANSI compliant left outer join is:<br />

●<br />

SELECT A.PRODUCTNAME, A.CATEGORYID, B.COMPANYNAME, B.CONTACTNAME<br />

FROM PRODUCT A LEFT OUTER JOIN SUPPLIERS B<br />

ON A.SUPPLIERID = B.SUPPLIERID<br />

<strong>SQL</strong> <strong>Server</strong> — left outer join<br />

The syntax <str<strong>on</strong>g>for</str<strong>on</strong>g> left outer join is as follows:<br />

SELECT A.FIELD1, A.FIELD2, B.FIELD1, B.FIELD2<br />

FROM TABLE1 A LEFT OUTER JOIN TABLE2 B<br />

ON A.FIELD1 = B.FIELD1<br />

Example <str<strong>on</strong>g>for</str<strong>on</strong>g> left outer join is:<br />

SELECT A.PRODUCTNAME, A.CATEGORYID, B.COMPANYNAME, B.CONTACTNAME<br />

FROM PRODUCT A LEFT OUTER JOIN SUPPLIERS B<br />

ON A.SUPPLIERID = B.SUPPLIERID<br />

All rows are retrieved from the right table referenced in a right outer join. A right outer join<br />

is used <strong>to</strong> furnish null rows <strong>to</strong> the right side table used during the Join c<strong>on</strong>diti<strong>on</strong>.<br />

● <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> — right outer join<br />

The syntax <str<strong>on</strong>g>for</str<strong>on</strong>g> right outer join is as follows:<br />

SELECT A.FIELD1, A.FIELD2, B.FIELD1, B.FIELD2<br />

FROM TABLE1 A, TABLE1 B<br />

WHERE A.FIELD1 = B.FIELD1(+)<br />

Example <str<strong>on</strong>g>for</str<strong>on</strong>g> right outer join is:<br />

●<br />

SELECT A.PRODUCTNAME, A.CATEGORYID, B.COMPANYNAME, B.CONTACTNAME<br />

FROM PRODUCT A, SUPPLIERS B<br />

WHERE A.SUPPLIERID = B.SUPPLIERID(+)<br />

<strong>SQL</strong> <strong>Server</strong> — right outer join<br />

The syntax <str<strong>on</strong>g>for</str<strong>on</strong>g> right outer join is as<br />

follows:<br />

SELECT A.FIELD1, A.FIELD2, B.FIELD1, B.FIELD2<br />

FROM TABLE1 A RIGHT OUTER JOIN TABLE2 B<br />

ON A.FIELD1 = B.FIELD1<br />

Example <str<strong>on</strong>g>for</str<strong>on</strong>g> right outer join is:<br />

SELECT A.PRODUCTNAME, A.CATEGORYID, B.COMPANYNAME, B.CONTACTNAME<br />

FROM PRODUCT A RIGHT OUTER JOIN SUPPLIERS B<br />

ON A.SUPPLIERID = B.SUPPLIERID<br />

All row s from both tables are returned in a full outer join.<br />

• <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> — full outer join<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> does not have a separate outer join syntax. The following shows an<br />

example <str<strong>on</strong>g>for</str<strong>on</strong>g> full outer join:<br />

SELECT A.PRODUCTNAME, A.CATEGORYID, B.COMPANYNAME, B.CONTACTNAME<br />

FROM PRODUCT A, SUPPLIERS B<br />

WHERE A.SUPPLIERID = B.SUPPLIERID(+)<br />

UNION


194 Developing: Applicati<strong>on</strong>s — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>SQL</strong> and PL/<strong>SQL</strong><br />

SELECT A.PRODUCTNAME, A.CATEGORYID, B.COMPANYNAME, B.CONTACTNAME<br />

FROM PRODUCT A, SUPPLIERS B<br />

WHERE A.SUPPLIERID(+) = B.SUPPLIERID<br />

• <strong>SQL</strong> Service — full outer join<br />

The syntax <str<strong>on</strong>g>for</str<strong>on</strong>g> full outer join is as follows:<br />

SELECT A.FIELD1, A.FIELD2, B.FIELD1, B.FIELD2<br />

FROM TABLE1 A FULL OUTER JOIN TABLE2 B<br />

ON A.FIELD1 = B.FIELD1<br />

Example <str<strong>on</strong>g>for</str<strong>on</strong>g> full outer join is:<br />

SELECT A.PRODUCTNAME, A.CATEGORYID, B.COMPANYNAME, B. CONTACTNAME<br />

FROM PRODUCT A FULL OUTER JOIN SUPPLIERS B<br />

ON A.SUPPLIERID = B.SUPPLIERID<br />

Subqueries<br />

A subquery is a normal query that is nested inside another query using parentheses.<br />

Subqueries are used <strong>to</strong> retrieve data from tables that depend <strong>on</strong> the values <strong>on</strong> the same<br />

table or a different table. A statement c<strong>on</strong>taining a subquery is called a parent statement.<br />

A subquery can be comm<strong>on</strong>ly found in the FROM and WHERE clauses of a SELECT<br />

statement. A subquery in the FROM clause is also called an inline view. Inline views in<br />

<strong>SQL</strong> <strong>Server</strong> are similar <strong>to</strong> those in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>. In <strong>SQL</strong> <strong>Server</strong>, inline views have <strong>to</strong> be aliased<br />

in all cases.<br />

Subqueries found in the WHERE clauses are called nested queries. Subqueries may be<br />

nested in other subqueries. T-<strong>SQL</strong> queries can use a maximum of 256 tables, including<br />

all subqueries, and a maximum of 32 levels of nesting. In c<strong>on</strong>trast, <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> allows 255<br />

levels of nesting. It is uncomm<strong>on</strong> <strong>to</strong> use more than two or three levels of nesting in<br />

queries. <strong>SQL</strong> <strong>Server</strong> supports most implementati<strong>on</strong>s of the nested query in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>.<br />

Examples of nested queries are found throughout this chapter. <strong>SQL</strong> <strong>Server</strong>, however,<br />

does not support the ordered set as shown in the following example:<br />

SELECT productid, revisedprice<br />

FROM OrderPrice<br />

WHERE (orderid, productid) IN (SELECT orderid, productid<br />

FROM OrderDetails)<br />

In such cases, the query can be c<strong>on</strong>verted in<strong>to</strong> <strong>on</strong>e using joins instead of the nested<br />

query.<br />

SELECT OP.productid, OP.revisedprice<br />

FROM OrderPrice OP INNER JOIN OrderDetails OD<br />

ON OP.orderid = OD.orderid<br />

AND OP.productid = OD.productid<br />

A nested query in which the nested query references columns in the parent table is called<br />

a correlated subquery. A correlated subquery is executed <strong>on</strong>ce <str<strong>on</strong>g>for</str<strong>on</strong>g> each row in the parent<br />

statement. Because <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> syntax and <strong>SQL</strong> <strong>Server</strong> syntax are similar, examples are not<br />

provided here.<br />

Grouping Result Set<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong> provide a method of grouping the result set using the GROUP BY<br />

clause. The GROUP BY clause summarizes the result set in<strong>to</strong> the groups defined in the<br />

query using aggregate functi<strong>on</strong>s<br />

such as AVG or SUM. Using the HAVING clause can


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 195<br />

further filter the result set by comparing it with the aggregate functi<strong>on</strong>'s result. The<br />

HAVING clause without a GROUP BY clause behaves like a simple WHERE c<strong>on</strong>diti<strong>on</strong>.<br />

HAV ING clauses are used with aggregati<strong>on</strong> functi<strong>on</strong>s and cannot be used with single row<br />

functi<strong>on</strong>s.<br />

The GROUP BY clause treats the HAVING clause in the same way as SELECT treats<br />

WHERE.<br />

A SELECT statement with a GROUP BY clause cannot have a COLUMN_NAME other<br />

than the columns available in the GROUP BY list. When GROUP BY is specified, either<br />

each column in any n<strong>on</strong>-aggregate expressi<strong>on</strong> in the select list should be included in the<br />

GROUP BY list, or the GROUP BY expressi<strong>on</strong> must match exactly the select list<br />

expressi<strong>on</strong>.<br />

A GROUP BY clause can include an expressi<strong>on</strong> as l<strong>on</strong>g as it does not include any<br />

agg regate functi<strong>on</strong>, and it cannot c<strong>on</strong>tain any sub query, either. In <strong>SQL</strong> <strong>Server</strong>, GROUP<br />

BY “ALL” can be used, but it is opti<strong>on</strong>al. When ALL is specified, null values are returned<br />

<str<strong>on</strong>g>for</str<strong>on</strong>g> the summary columns of groups that do not meet the search c<strong>on</strong>diti<strong>on</strong>.<br />

Because <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong> <strong>SQL</strong> are similar, examples are not provided here.<br />

Database Link<br />

When tables are <strong>to</strong> be joined across databases that are in different servers, the database<br />

link functi<strong>on</strong>ality can be used. In the examples provided in this secti<strong>on</strong>, the databases are<br />

distributed in two geographical locati<strong>on</strong>s. One database is in New York, and another is in<br />

Bos t<strong>on</strong>. A business user wants <strong>to</strong> know the <strong>to</strong>tal number of orders <str<strong>on</strong>g>for</str<strong>on</strong>g> the m<strong>on</strong>th of May,<br />

2004.<br />

● In <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>, databases are linked using the command CREATE DATABASE LINK.<br />

The TNSNAMES.ORA entry <str<strong>on</strong>g>for</str<strong>on</strong>g> the database is required.<br />

SELECT COUNT(*)<br />

FROM<br />

(<br />

SELECT ORDERID FROM ORDERMASTER<br />

WHERE orderdate > sysdate - 30<br />

UNION<br />

SELECT ORDERID FROM ORDERMASTER@BOSTON<br />

WHERE ORDERDATE > sysdate - 30<br />

);<br />

● In <strong>SQL</strong> <strong>Server</strong>, some c<strong>on</strong>figurati<strong>on</strong> is needed be<str<strong>on</strong>g>for</str<strong>on</strong>g>e accessing remote databases.<br />

Be<str<strong>on</strong>g>for</str<strong>on</strong>g>e querying tables from different databases <strong>on</strong> different servers, log in<strong>to</strong> the<br />

first database, go <strong>to</strong> Query Analyzer, and execute the following code.<br />

USE MASTER<br />

GO<br />

EXEC SP_ADDLINKEDSERVER<br />

@SERVER= 'BOSTON',<br />

@SRVPRODUCT= '',<br />

@PROVIDER='<strong>SQL</strong>OLEDB',<br />

@DATASRC='BOSTON\NWIND'<br />

GO<br />

EXEC SP_ADDLINKEDSRVLOGIN<br />

@RMTSRVNAME ='BOSTON',<br />

@USESELF='FALSE',<br />

@LOCALLOGIN=NULL,


196 Developing: Applicati<strong>on</strong>s — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>SQL</strong> and PL/<strong>SQL</strong><br />

CASE<br />

@RMTUSER ='ABC',<br />

@RMTPASSWORD ='ABC'<br />

GO<br />

Executing these procedures establishes the link between the servers. Next,<br />

execute the following query <strong>to</strong> retrieve the data from two databases.<br />

SELECT COUNT(ORDERID)<br />

FROM<br />

(SELECT ORDERID FROM ORDERMASTER<br />

WHERE ORDERDATE > getdate() - 30<br />

UNION<br />

SELECT ORDERID FROM [BOSTON].NWIND.DBO.ORDERMASTER<br />

WHERE ORDERDATE > getdate() - 30<br />

)<br />

CASE is used when there is a need <strong>to</strong> have "if-else" in this secti<strong>on</strong>, a s<strong>to</strong>re manager wants <strong>to</strong> see cus<strong>to</strong>mer names and segregate<br />

logic. In the example code that<br />

appears<br />

the orders in<strong>to</strong> the three following categories:<br />

● An order value less than $5,000 is small<br />

● An order value between $5,000 and $10,000 is medium<br />

● An order value greater than $10,000 is large<br />

In <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>, this task would be accomplished using CASE as shown in the following code<br />

example:<br />

SELECT ORDERID,<br />

CASE<br />

WHEN SUM(UNITPRICE)


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 197<br />

●<br />

<strong>SQL</strong> <strong>Server</strong><br />

SELECT COMPANYNAME<br />

FROM [NEWYORK].NWIND.DBO.SUPPLIERS<br />

UNION<br />

SELECT COMPANYNAME<br />

FROM [BOSTON].NWIND.DBO.SUPPLIERS<br />

Set Opera<strong>to</strong>rs: Intersect<br />

The intersect opera<strong>to</strong>r will <strong>on</strong>ly retrieve the comm<strong>on</strong> values from more than <strong>on</strong>e table. In<br />

the following example code, intersect is used <strong>to</strong> retrieve the supplier names comm<strong>on</strong> <strong>to</strong><br />

both NEWYORK and BOSTON s<strong>to</strong>res.<br />

● <str<strong>on</strong>g>Oracle</str<strong>on</strong>g><br />

●<br />

SELECT COMPANYNAME FROM SUPPLIERS@BOSTON<br />

INTERSECT<br />

SELECT COMPANYNAME FROM SUPPLIERS@NEWYORK<br />

clause can be written <str<strong>on</strong>g>for</str<strong>on</strong>g> the same<br />

Set Opera<strong>to</strong>rs: Minus<br />

A minus opera<strong>to</strong>r is used when the difference of values from more than <strong>on</strong>e table needs<br />

<strong>to</strong> be fetched. In the following example code, this opera<strong>to</strong>r is used <strong>to</strong> list the supplier<br />

names that are <strong>on</strong>ly in the BOSTON database and that are not in NEWYORK database.<br />

● <str<strong>on</strong>g>Oracle</str<strong>on</strong>g><br />

●<br />

<strong>SQL</strong> <strong>Server</strong><br />

In <strong>SQL</strong> <strong>Server</strong>, a subquery with an EXISTS<br />

purpose.<br />

SELECT COMPANYNAME FROM [NEWYORK].NWIND.DBO.SUPPLIERS A<br />

WHERE EXISTS<br />

(SELECT 'X'<br />

FROM [BOSTON].NWIND.DBO.SUPPLIERS B<br />

WHERE A.COMPANYNAME = B.COMPANYNAME);<br />

SELECT COMPANYNAME FROM SUPPLIERS@BOSTON<br />

MINUS<br />

SELECT COMPANYNAME FROM SUPPLIERS@NEWYORK;<br />

<strong>SQL</strong> <strong>Server</strong><br />

Because MINUS is not available in <strong>SQL</strong> <strong>Server</strong>, NOT EXISTS can be used. The<br />

following example shows how <strong>to</strong> use the NOT EXISTS opera<strong>to</strong>r.<br />

SELECT COMPANYNAME FROM SUPPLIERS A<br />

WHERE NOT EXISTS<br />

(SELECT 'X'<br />

FROM [BOSTON].NWIND.DBO.SUPPLIERS B<br />

WHERE A.COMPANYNAME = B.COMPANYNAME) ;


198 Developing: Applicati<strong>on</strong>s — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>SQL</strong> and PL/<strong>SQL</strong><br />

ROWNUM<br />

ROWNUM is a special keyword in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>. Using ROWNUM can limit the number of rows<br />

retrieved without any c<strong>on</strong>diti<strong>on</strong>. In the following example, ROWNUM is used <strong>to</strong> display<br />

the <strong>to</strong>p 10 orders from the ORDERDETAILS table.<br />

● <str<strong>on</strong>g>Oracle</str<strong>on</strong>g><br />

●<br />

SELECT *<br />

FROM<br />

(SELECT ORDERID, SUM(UNITPRICE)<br />

FROM ORDERDETAILS<br />

GROUP BY ORDERID<br />

ORDER BY SUM(UNITPRICE) DESC<br />

)<br />

WHERE ROWNUM < 11;<br />

<strong>SQL</strong> <strong>Server</strong><br />

SELECT TOP 10 ORDERID, SUM(UNITPRICE)<br />

FROM ORDERDETAILS<br />

GROUP BY ORDERID<br />

ORDER BY SUM(UNITPRICE) DESC<br />

Data Manipulati<strong>on</strong> Language (DML)<br />

DML includes INSERT, UPDATE, and DELETE. The MERGE statement has also been<br />

discussed. The following secti<strong>on</strong>s describe how each command is used in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and<br />

how the command can be c<strong>on</strong>verted in<strong>to</strong> <strong>SQL</strong> <strong>Server</strong>-specific syntax.<br />

Insert<br />

The INSERT command is used <strong>to</strong> add <strong>on</strong>e or more rows <strong>to</strong> a table. The column values<br />

are separated by commas. Insert can be used in several different ways within <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>. All<br />

of the different <str<strong>on</strong>g>for</str<strong>on</strong>g>ms are explained under the following headings.<br />

Inse rting a row in<strong>to</strong> a table is identical in <strong>SQL</strong> <strong>Server</strong> and in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>. The syntax is shown<br />

here:<br />

INSERT INTO TABLE1 VALUES (FIELD1, FIELD2 …);<br />

Insert Sequences<br />

Compatibility between the <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> tables and the new <strong>SQL</strong> <strong>Server</strong> tables should be<br />

checked. If a table in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> uses SEQUENCES, then <strong>SQL</strong> <strong>Server</strong> tables should use<br />

IDENTITY.<br />

IDENTITY will au<strong>to</strong>matically increment a column value so that no two rows will have<br />

same value <str<strong>on</strong>g>for</str<strong>on</strong>g> the column. To enable this facility, a column can be included in the table<br />

which will have its unique value and au<strong>to</strong>-incrementing defined. This is achieved through<br />

SEQUENCES in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and IDENTITY in <strong>SQL</strong> <strong>Server</strong>. This column can also be used as<br />

primary key <str<strong>on</strong>g>for</str<strong>on</strong>g> tables that do not have a natural key.<br />

A sequence is a database object that can generate unique, sequential integer values. It<br />

can be used <strong>to</strong> au<strong>to</strong>matically generate primary key or unique key values. A sequence can<br />

be either in ascending or descending order. The syntax is explained in the following<br />

examples.<br />

● <str<strong>on</strong>g>Oracle</str<strong>on</strong>g><br />

INSERT INTO SUPPLIERS VALUES


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 199<br />

●<br />

(SUPPLIER_SEQUENCE.NEXTVAL,' Abc Inc.', 'Lingerfelt, Steve', 'Mr.', 'Apt # 104<br />

Andrew''s Drive', 'Charlotte', 28262,'USA',7049654371,7049652300);<br />

<strong>SQL</strong> <strong>Server</strong><br />

<strong>SQL</strong> <strong>Server</strong> has a unique way of handling running serial numbers: the IDENTITY<br />

property. This property provides a unique incremental value <str<strong>on</strong>g>for</str<strong>on</strong>g> the column. Its use<br />

in an insert command is explained later in this secti<strong>on</strong>. This is equivalent <strong>to</strong><br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g>'s Sequence. When a column is declared as IDENTITY, a value does not<br />

have <strong>to</strong> be specified <str<strong>on</strong>g>for</str<strong>on</strong>g> the column. In <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>, the value has <strong>to</strong> be explicitly<br />

retrieved from a sequence during an insert.<br />

The current value of an IDENTITY can be found using the following code:<br />

SELECT IDENT_CURRENT ('SUPPLIERS')<br />

INSERT INTO SUPPLIERS VALUES<br />

(' A bc Inc.', 'Lingerfelt, Steve', 'Mr.', 'Apt # 104 Andrew''s Drive' ,<br />

'Charlotte', 28262,'USA','7049654371','7049652300');<br />

Using Date Values in Insert Operati<strong>on</strong>s<br />

During an insert or update, the date <str<strong>on</strong>g>for</str<strong>on</strong>g>mat can be the same as <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> (DD-MON-YYYY).<br />

However, while retrieving, the <str<strong>on</strong>g>for</str<strong>on</strong>g>mat will be different. A c<strong>on</strong>versi<strong>on</strong> functi<strong>on</strong> that was<br />

discussed in the "Functi<strong>on</strong>s"<br />

secti<strong>on</strong> will have <strong>to</strong> be used. In <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>, <strong>to</strong> insert the date with time, a c<strong>on</strong>versi<strong>on</strong> of the<br />

date with date time is needed. This is d<strong>on</strong>e with the help of the TO_CHAR functi<strong>on</strong>. This<br />

is not required in <strong>SQL</strong> <strong>Server</strong> because it already s<strong>to</strong>res the date with time stamp.<br />

The following example illustrates how <strong>to</strong> insert the current date in an insert operati<strong>on</strong> of<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong>.<br />

● <str<strong>on</strong>g>Oracle</str<strong>on</strong>g><br />

●<br />

INSERT INTO OrderMaster VALUES(1,1076,121,SYSDATE,'19-AUG-2004', NULL,<br />

'Federal Shipping', 40,'Ernst Handel','2817 Milt<strong>on</strong> Dr.','Dallas','TX','87110')<br />

INSERT INTO OrderMaster VALUES(1,1076,121, GETDATE(),'19-AUG-2004', NULL,<br />

'Federal Shipping', 40, 'Ernst Handel','2817 Milt<strong>on</strong><br />

Dr.','Dallas','TX','87110')<br />

The following example shows how the time part of a date is handled in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and how<br />

this can be c<strong>on</strong>verted <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>SQL</strong> <strong>Server</strong> database.<br />

● <str<strong>on</strong>g>Oracle</str<strong>on</strong>g><br />

●<br />

<strong>SQL</strong> <strong>Server</strong><br />

INSERT INTO OrderMaster VALUES(1,1076,121,TO_DATE('01-MAR-2004 13:45:33', 'DD-<br />

MON-YYYY<br />

HH24:MI:SS'),'19-AUG-2004', NULL, 'Federal Shipping', 40, 'Ernst Handel','2817<br />

Milt<strong>on</strong> Dr.',' Dallas','TX','87110')<br />

<strong>SQL</strong> <strong>Server</strong><br />

INSERT INTO OrderMaster VALUES(1,1076,121, '01-MAR-2004 13:45:33','19-AUG-<br />

2004', NULL, 'Federal Shipping', 40, 'Ernst Handel','2817 Milt<strong>on</strong><br />

Dr.','Dallas','TX' ,'87110')<br />

Insert with Subquery<br />

In many applicati<strong>on</strong>s, a subquery is used <strong>to</strong> return a specific subset of rows which<br />

are then inserted in<strong>to</strong> the table. The subquery can refer <strong>to</strong> any table, view, or


200 Developing: Applicati<strong>on</strong>s — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>SQL</strong> and PL/<strong>SQL</strong><br />

even the target table itself. If the subquery returns no rows, then no rows are<br />

inserted in<strong>to</strong> the table.<br />

Update<br />

Update is an imperative DML statement that facilitates the changes <strong>to</strong> values of fields in<br />

the tables. In an <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> or <strong>SQL</strong> <strong>Server</strong> database, an UPDATE is comm<strong>on</strong>ly used <strong>to</strong><br />

incorporate modificati<strong>on</strong>s <strong>to</strong> an already inserted value. All of the key c<strong>on</strong>straints are<br />

handled by the databases prior <strong>to</strong> affecting the UPDATE permanently. <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and<br />

<strong>SQL</strong> <strong>Server</strong> have followed the c<strong>on</strong>venti<strong>on</strong>al ANSI way of using the UPDATE statement.<br />

The UPDATE statement can be per<str<strong>on</strong>g>for</str<strong>on</strong>g>med in three different ways:<br />

● Simple update. This is a straight<str<strong>on</strong>g>for</str<strong>on</strong>g>ward change <strong>to</strong> the values of <strong>on</strong>e or more<br />

fields of a table, with or without a c<strong>on</strong>diti<strong>on</strong> <str<strong>on</strong>g>for</str<strong>on</strong>g> updating.<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong> use the same syntax <str<strong>on</strong>g>for</str<strong>on</strong>g> UPDATE statement.<br />

● Update with joins. Updates with joins are frequently used when a change is<br />

required in the field value of <strong>on</strong>ly the rows matching specific c<strong>on</strong>diti<strong>on</strong>s between<br />

two or more tables.<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong> use the same syntax <str<strong>on</strong>g>for</str<strong>on</strong>g> UPDATE statement.<br />

● Update with subqueries. Requirements will sometimes demand a change <strong>to</strong> a<br />

field value with data from another table. Update with subqueries is useful in<br />

situati<strong>on</strong>s where data from <strong>on</strong>e table is set <strong>to</strong> a field from another table.<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong> use the same syntax c<strong>on</strong>venti<strong>on</strong>s <str<strong>on</strong>g>for</str<strong>on</strong>g> UPDATE with<br />

subqueries. An excepti<strong>on</strong> is updates involving correlated subqueries.<br />

UPDATE OrderDetails o<br />

SET o.unitprice = (SELECT unitprice<br />

FROM Product p<br />

WHERE p.productid = o.productid)<br />

The preceding <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> update statement can be rewritten using a syntax that is<br />

unique <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> as follows:<br />

Merge<br />

UPDATE o<br />

SET o.unitprice = p.unitprice<br />

FROM OrderDetails o JOIN Product p<br />

ON p.productid = o.productid<br />

This is a new feature in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> 9i. The MERGE statement is used <strong>to</strong> update and insert<br />

rows in a table. In the following examples, an ORDERPRICE table exists that s<strong>to</strong>res the<br />

revised price of a product in a particular order. The price can be revised any number of<br />

times. If a record already exists, then the price needs <strong>to</strong> be updated and the date<br />

changed. If a row <str<strong>on</strong>g>for</str<strong>on</strong>g> that order and product does not exist, then you need <strong>to</strong> insert a new<br />

row with the revised price of the product in that particular order.<br />

● <str<strong>on</strong>g>Oracle</str<strong>on</strong>g><br />

MERGE INTO ORDERPRICE A<br />

USING (SELECT ORDERID, PRODUCTID FROM ORDERDETAILS WHERE ORDERID=1<br />

AND PRODUCTID =1) B<br />

ON (A.ORDERID = B.ORDERID AND A.PRODUCTID = B.PRODUCTID)<br />

WHEN MATCHED THEN<br />

UPDATE SET REVISEDPRICE = 120, REVISEDON = SYSDATE<br />

WHEN NOT MATCHED THEN<br />

INSERT INTO<br />

ORDERPRICE VALUES


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 201<br />

●<br />

(B.ORDERID, B.PRODUCTID, 100, SYSDATE);<br />

<strong>SQL</strong> <strong>Server</strong><br />

To achieve this functi<strong>on</strong>ality in <strong>SQL</strong> <strong>Server</strong>, use a s<strong>to</strong>red procedure with the<br />

following logic. More in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> about writing s<strong>to</strong>red procedures is included later<br />

in this chap ter in the "Subprograms C<strong>on</strong>versi<strong>on</strong>" secti<strong>on</strong>.<br />

declare @orderid char(10)<br />

declare @productid char(10)<br />

declare @count integer<br />

SELECT @count = COUNT(*) FROM ORDERPRICE<br />

WHERE ORDERID= @ORDERID AND PRODUCTID = @PRODUCTID<br />

IF @count > 0<br />

UPDATE ORDERPRICE SET REVISEDPRICE =<br />

120, REVISEDON = GETDATE()<br />

WHERE ORDERID = @ORDERID AND PRODUCTID = @PRODUCTID<br />

ELSE<br />

INSERT INTO ORDERPRICE VALUES(@ORDERID, @PRODUCTID, 100, GETDATE())<br />

Delete<br />

As tables are used, unneeded rows can be removed. DELETE is a DML operati<strong>on</strong> that is<br />

used <strong>to</strong> eliminate all or certain rows from a table, keeping the table structure intact. Even<br />

though all the rows are deleted, the structure of the table remains and can be populated<br />

with additi<strong>on</strong>al rows using INSERT. By using c<strong>on</strong>diti<strong>on</strong>al deleti<strong>on</strong>, <strong>on</strong>ly selected rows are<br />

eliminated from the table. C<strong>on</strong>diti<strong>on</strong>al deleti<strong>on</strong> is accomplished by using the c<strong>on</strong>venti<strong>on</strong>al<br />

WHERE clause. <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong> both allow <str<strong>on</strong>g>for</str<strong>on</strong>g> c<strong>on</strong>diti<strong>on</strong>al deleti<strong>on</strong>. The ANSI<br />

way of writing the DELETE statement is used in both <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong>.<br />

The following types of delete exist:<br />

● Simple delete. A general way of deleting all or selected rows from a table. A<br />

simple delete operati<strong>on</strong> is similar <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong>.<br />

● Delete all rows. Both <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong> offer the TRUNCATE TABLE<br />

statement.<br />

● Delete with subqueries. Using subqueries in c<strong>on</strong>juncti<strong>on</strong> with the DELETE<br />

operati<strong>on</strong> allows <str<strong>on</strong>g>for</str<strong>on</strong>g> more specificity. The subquery enables the value <str<strong>on</strong>g>for</str<strong>on</strong>g> the<br />

WHERE c<strong>on</strong>diti<strong>on</strong> <strong>to</strong> be fetched from a different table.<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong> use the same methodology <strong>to</strong> delete the rows in a table.<br />

● Delete duplicate records. It is possible <strong>to</strong> have exact copies of rows in a table<br />

that does not en<str<strong>on</strong>g>for</str<strong>on</strong>g>ce a strict key structure. These situati<strong>on</strong>s demand the deleti<strong>on</strong><br />

of all the duplicate records from the table. <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong> have different<br />

ways <strong>to</strong> do this:<br />

●<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g><br />

DELETE FROM TABLE1 WHERE TABLE1.ROWID ><br />

(SELECT MIN (TABLE2.ROWID) FROM TABLE2<br />

WHERE TABLE1.FIELD1 = TABLE2.FIELD1)<br />

● <strong>SQL</strong> <strong>Server</strong><br />

For an example of how <strong>to</strong> per<str<strong>on</strong>g>for</str<strong>on</strong>g>m this in <strong>SQL</strong> <strong>Server</strong>, refer <strong>to</strong><br />

http://support.microsoft.com/default.aspx?scid=kb;en-us;139444<br />

• Truncate<br />

Both <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong> offer the TRUNCATE command <str<strong>on</strong>g>for</str<strong>on</strong>g> deleting all rows<br />

of a table with minimal logging.


202 Developing: Applicati<strong>on</strong>s — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>SQL</strong> and PL/<strong>SQL</strong><br />

Step 2: Transacti<strong>on</strong> Management<br />

After identifying all instances of <strong>SQL</strong>, transacti<strong>on</strong>s need <strong>to</strong> be carefully modified as part of<br />

the data migrati<strong>on</strong> process. This secti<strong>on</strong> discusses how <strong>to</strong> handle the transacti<strong>on</strong>s in<br />

<strong>SQL</strong> <strong>Server</strong>.<br />

To begin, identify all of the transacti<strong>on</strong> commands currently used with <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and<br />

implement them <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>SQL</strong> <strong>Server</strong>. In <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>, all commands inside two transacti<strong>on</strong> c<strong>on</strong>trol<br />

language statements are c<strong>on</strong>sidered as a batch. If a set of statements needs <strong>to</strong> be<br />

c<strong>on</strong>sidered as a batch, then all the statements must be inside BEGIN TRANSACTION<br />

and COMMIT TRANSACTION commands. A discussi<strong>on</strong> of these architecture <strong>to</strong>pics is<br />

provided in Appendix A: <strong>SQL</strong> <strong>Server</strong> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Professi<strong>on</strong>als.<br />

Transacti<strong>on</strong> C<strong>on</strong>trol Language (TCL)<br />

A tr ansacti<strong>on</strong> can be defined as a group of statements that must either succeed or fail as<br />

a group. In <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>, transacti<strong>on</strong>s are normally implicit in nature and can be explicitly<br />

specified by use of BEGIN and END clauses. In <strong>SQL</strong> <strong>Server</strong>, BEGIN TRAN and END<br />

TRAN have <strong>to</strong> be explicitly used <strong>to</strong> demarcate a transacti<strong>on</strong>.<br />

Transacti<strong>on</strong> is c<strong>on</strong>trolled by any <strong>on</strong>e of these commands:<br />

● COMMIT<br />

● ROLLBACK<br />

● SAVEPOINT<br />

These commands are discussed in detail under the following headings.<br />

COMMIT<br />

The COMMIT command is used <strong>to</strong> end a transacti<strong>on</strong>. Changes are made permanent in<br />

the database with the COMMIT command. This erases all the savepoints inside the<br />

tran sacti<strong>on</strong> and also releases the locks.<br />

After a transacti<strong>on</strong> is committed, the change is permanent and cannot be reverted. Of<br />

course, you can always delete the inserted row. There is no way <strong>to</strong> undo a committed<br />

transacti<strong>on</strong>.<br />

The syntax is as follows:<br />

● <str<strong>on</strong>g>Oracle</str<strong>on</strong>g><br />

●<br />

COMMIT;<br />

<strong>SQL</strong> <strong>Server</strong><br />

COMMIT TRANSACTION ;<br />

The COMMIT WORK command functi<strong>on</strong>s in the same way as COMMIT TRANSACTION,<br />

except COMMIT TRANSACTION accepts a user-defined transacti<strong>on</strong> name. This<br />

COMMIT syntax, with or without specifying the opti<strong>on</strong>al keyword WORK, is compatible<br />

with <strong>SQL</strong>-92. This command is available in <strong>SQL</strong> <strong>Server</strong> using the following command:<br />

COMMIT WORK;<br />

SAVEPOINT<br />

A savepoint is a marker that divides a very lengthy transacti<strong>on</strong> in<strong>to</strong> several smaller <strong>on</strong>es.<br />

SAVEPOINT is used <strong>to</strong> identify a rollback point in the transacti<strong>on</strong>. Thus, SAVEPOINT is<br />

used in c<strong>on</strong>juncti<strong>on</strong> with ROLLBACK <strong>to</strong> revert a porti<strong>on</strong> of current transacti<strong>on</strong>. The syntax<br />

in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong> differs:<br />

● <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 203<br />

●<br />

SAVEPOINT ;<br />

<strong>SQL</strong> <strong>Server</strong><br />

SAVE TRANSACTION ;<br />

ROLLBACK<br />

The ROLLBACK command is used <strong>to</strong> undo a porti<strong>on</strong> of the current transacti<strong>on</strong>. It is<br />

possible <strong>to</strong> roll back the entire transacti<strong>on</strong> so that all changes made by <strong>SQL</strong> statements<br />

are und<strong>on</strong>e, or <strong>to</strong> roll back a transacti<strong>on</strong> <strong>to</strong> a save point so that the <strong>SQL</strong> statements after<br />

the save point are rolled back. The syntax in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong> differs:<br />

●<br />

●<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g><br />

ROLLBACK;<br />

ROLLBACK TO ;<br />

<strong>SQL</strong> <strong>Server</strong><br />

ROLLBACK TRANSACTION <br />

ROLLBACK TRANSACTION <br />

In additi<strong>on</strong>, the ROLLBACK WORK statement functi<strong>on</strong> is similar <strong>to</strong> the ROLLBACK. The<br />

<strong>on</strong>ly difference is that ROLLBACK TRANSACTION accepts a user-defined transacti<strong>on</strong><br />

name. With or without specifying the opti<strong>on</strong>al WORK keyword, this ROLLBACK syntax is<br />

<strong>SQL</strong>-92-compatible and is available in <strong>SQL</strong> <strong>Server</strong> using the following syntax:<br />

ROLLBACK WORK<br />

Ste p 3: Fetch Strategy<br />

Cursors are effective <str<strong>on</strong>g>for</str<strong>on</strong>g> row processing and batch processing. <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>-based applicati<strong>on</strong>s<br />

can use many c ursors <str<strong>on</strong>g>for</str<strong>on</strong>g> row processing. Analyze the code <strong>to</strong> determine if it can be<br />

c<strong>on</strong>verted without using cursors. Cursor operati<strong>on</strong>s are always costly when compared <strong>to</strong><br />

SET operati<strong>on</strong>s because they use temporary memory area and processes. If the cursors<br />

are not handled properly, it may result in dead processes and locks.<br />

In <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>, a cursor is defined as a work area <strong>to</strong> execute the <strong>SQL</strong> statements and <strong>to</strong> s<strong>to</strong>re<br />

processing in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong>. <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> creates a work area <strong>to</strong> process all the <strong>SQL</strong> statements.<br />

That work area is called an implicit cursor. <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> also allows you <strong>to</strong> define an explicit<br />

cursor <strong>to</strong> process and apply business logic.<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> has implemented the following types of cursors:<br />

● Implicit cursors<br />

● Explicit cursors<br />

Implicit cursors are opened au<strong>to</strong>matically whenever queries or DML are issued in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>.<br />

<strong>SQL</strong> <strong>Server</strong> calls this a default result set.<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> allows defining a cursor with the help of keyword "cursor." Such explicitly declared<br />

curs ors have a SELECT statement. The output of the select is s<strong>to</strong>red in separate memory<br />

areas and it can be used in a PL/<strong>SQL</strong> program. Explicit cursors can be parameterized.<br />

Transact <strong>SQL</strong> Cursors, in <strong>SQL</strong> <strong>Server</strong>, are based <strong>on</strong> the DECLARE CURSOR syntax and<br />

are used mainly in Transact-<strong>SQL</strong> scripts, s<strong>to</strong>red procedures, and triggers. Transact-<strong>SQL</strong><br />

cursors are implemented <strong>on</strong> the server and are managed by Transact-<strong>SQL</strong> statements<br />

sent from the client <strong>to</strong> the server.<br />

Using Transact-<strong>SQL</strong> Cursors<br />

High-level steps <str<strong>on</strong>g>for</str<strong>on</strong>g> using Transact-<strong>SQL</strong> cursors inside the code include:


204 Developing: Applicati<strong>on</strong>s — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>SQL</strong> and PL/<strong>SQL</strong><br />

1. Declare Transact-<strong>SQL</strong> variables <strong>to</strong> c<strong>on</strong>tain the data returned by the cursor. Declare<br />

<strong>on</strong>e variable <str<strong>on</strong>g>for</str<strong>on</strong>g> each result set column. Declare the variables <strong>to</strong> be large enough<br />

<strong>to</strong> hold the values returned by the column.<br />

2. Associate a Transact-<strong>SQL</strong> cursor with a SELECT statement using the DECLARE<br />

CURSOR statement. The DECLARE CURSOR statement also defines the<br />

characteristics of the cursor, such as the cursor name and whether the cursor is<br />

read-<strong>on</strong>ly or <str<strong>on</strong>g>for</str<strong>on</strong>g>ward-<strong>on</strong>ly.<br />

3. Use the OPEN statement <strong>to</strong> execute the SELECT statement and populate the<br />

cursor.<br />

4. Use the FETCH INTO statement <strong>to</strong> fetch individual rows and have the data <str<strong>on</strong>g>for</str<strong>on</strong>g><br />

each column moved in<strong>to</strong> a specified variable. Other Transact-<strong>SQL</strong> statements can<br />

then reference those variables <strong>to</strong> access the fetched data values. Transact-<strong>SQL</strong><br />

cursors do not support fetching blocks of rows.<br />

5. When you are finished with the cursor, use the CLOSE statement. Closing a cursor<br />

frees some resources, such as the cursor's result set and its locks <strong>on</strong> the current<br />

row, but the cursor structure is still available <str<strong>on</strong>g>for</str<strong>on</strong>g> processing if you reissue an OPEN<br />

statement. Because the cursor is still present, you cannot reuse the cursor name at<br />

this point. The DEALLOCATE statement completely frees all resources allocated <strong>to</strong><br />

the cursor, including the cursor name. After a cursor is de-allocated, you must<br />

issue a DECLARE statement <strong>to</strong> rebuild the cursor.<br />

Th e cursor syntax differs between <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong>:<br />

● <str<strong>on</strong>g>Oracle</str<strong>on</strong>g><br />

●<br />

DECLARE<br />

CURSOR IS < SELECT STATEMENT><br />

BEGIN<br />

FOR IN CURSOR_NAME<br />

LOOP<br />

-- Business Logic<br />

END LOOP;<br />

END;<br />

<strong>SQL</strong> <strong>Server</strong><br />

DECLARE <br />

DECLARE CURSOR FOR <br />

BEGIN<br />

OPEN <br />

FETCH NEXT FROM INTO <br />

WHILE @@FETCH_STATUS = 0<br />

BEGIN<br />

-- business logic goes here<br />

FETCH NEXT FROM INTO <br />

END<br />

CLOSE <br />

DEALLOCATE <br />

END<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> allows the entire cursor record <strong>to</strong> be transferred in<strong>to</strong> a user-defined data structure<br />

defined using ROWTYPE. In <strong>SQL</strong> <strong>Server</strong>, the record values need <strong>to</strong> be assigned in<strong>to</strong> an<br />

individual variable. The following example uses ROWTYPE <strong>to</strong> process the SHIPPERS<br />

table record by<br />

record.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 205<br />

●<br />

●<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g><br />

DECLARE<br />

CURSOR SHIPPER_CURSOR IS SELECT * FROM SHIPPERS;<br />

SHIPPER_REC SHIPPERS%ROWTYPE;<br />

BEGIN<br />

OPEN SHIPPER_CURSOR;<br />

LOOP<br />

FETCH SHIPPER_CURSOR INTO SHIPPER_REC;<br />

EXIT WHEN SHIPPER_CURSOR%NOTFOUND;<br />

DBMS_OUTPUT.PUT_LINE('SHIPPER NAME IS '||SHIPPER_REC.COMPANYNAME);<br />

DBMS_OUTPUT.PUT_LINE('SHIPPER PHONE IS '||SHIPPER_REC. PHONE);<br />

END LOOP;<br />

CLOSE SHIPPER_CURSOR;<br />

END;<br />

<strong>SQL</strong> <strong>Server</strong><br />

DECLARE @SHIPPER_NAME VARCHAR(50),@PHONE VARCHAR(50)<br />

DECLARE SHIPPER_CURSOR CURSOR FOR SELECT COMPANYNAME,PHONE FROM SHIPPERS;<br />

BEGIN<br />

OPEN SHIPPER_CURSOR;<br />

FETCH NEXT FROM SHIPPER_CURSOR INTO @SHIPPER_NAME, @PHONE<br />

WHILE @@FETCH_STATUS = 0<br />

BEGIN<br />

PRINT 'SHIPPER NAME IS ' + @SHIPPERNAME<br />

PRINT 'SHIPPER PHONE IS ' + @PHONE<br />

FETCH NEXT FROM SHIPPER_CURSOR INTO @SHIPPER_NAME, @PHONE<br />

END<br />

CLOSE SHIPPER_CURSOR<br />

DEALLOCATE SHIPPER_ CURSOR<br />

END<br />

Transact <strong>SQL</strong> Extensi<strong>on</strong>s<br />

<strong>SQL</strong> <strong>Server</strong> extends the following functi<strong>on</strong>ality with cursors. Some of the key features<br />

include:<br />

●<br />

●<br />

●<br />

●<br />

●<br />

●<br />

FETCH FIRST<br />

Fetches the first row in the cursor.<br />

FETCH NEXT<br />

Fetches the row after the last row fetched.<br />

FETCH PRIOR<br />

Fetches the row be<str<strong>on</strong>g>for</str<strong>on</strong>g>e the last row fetched.<br />

FETCH LAST<br />

Fetches the last row in the cursor.<br />

FETCH ABSOLUTE n<br />

Fetches the nth row from the first row in the cursor if n is a positive integer. If n is a<br />

negative integer, the row n rows be<str<strong>on</strong>g>for</str<strong>on</strong>g>e the end of the cursor is fetched. If n is 0, no<br />

rows are fetched.<br />

FETCH RELATIVE n<br />

Fetches the nth row from the current positi<strong>on</strong> of the cursor. If n is positive, the nth<br />

row after<br />

the last row fetched is fetched. If n is negative, the nth row be<str<strong>on</strong>g>for</str<strong>on</strong>g>e the last


206 Developing: Applicati<strong>on</strong>s — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>SQL</strong> and PL/<strong>SQL</strong><br />

row fetched is fetched. If n is 0, the same row is fetched again. It also allows<br />

retrieving <strong>on</strong>e row or block of rows from the current positi<strong>on</strong> in the result set.<br />

It supports data modificati<strong>on</strong>s <strong>to</strong> the rows at the current positi<strong>on</strong> in the result set.<br />

Step 4: Subprograms C<strong>on</strong>versi<strong>on</strong><br />

The next step is <strong>to</strong> migrate the procedures, functi<strong>on</strong>s, and triggers. This secti<strong>on</strong><br />

discusses how each comp<strong>on</strong>ent can be c<strong>on</strong>verted <str<strong>on</strong>g>for</str<strong>on</strong>g> use with <strong>SQL</strong> <strong>Server</strong>.<br />

<str<strong>on</strong>g>Migrating</str<strong>on</strong>g> Procedures<br />

A s<strong>to</strong>red procedure is a precompiled object. This means that a procedure is compiled<br />

be<str<strong>on</strong>g>for</str<strong>on</strong>g>ehand and is readily available <str<strong>on</strong>g>for</str<strong>on</strong>g> the various applicati<strong>on</strong>s <strong>to</strong> execute. As a result,<br />

time is not wasted parsing and compiling the procedure again. However, the procedure<br />

will be compiled every time if it c<strong>on</strong>tains dynamic <strong>SQL</strong>. S<strong>to</strong>red procedures in <strong>SQL</strong> <strong>Server</strong><br />

are very similar <strong>to</strong> procedures in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> PL/<strong>SQL</strong>. Some similarities include:<br />

● Both can accept parameters and return multiple values in the <str<strong>on</strong>g>for</str<strong>on</strong>g>m of output<br />

parameters (OUT parameter) <strong>to</strong> the calling procedure.<br />

● Both c<strong>on</strong>tain programming statements that per<str<strong>on</strong>g>for</str<strong>on</strong>g>m operati<strong>on</strong>s in the database,<br />

including calling other procedures.<br />

● Both can overwrite existing procedures. <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> uses the keyword REPLACE, while<br />

<strong>SQL</strong> <strong>Server</strong> uses ALTER.<br />

The syntax between <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong> procedures differs. The differences are<br />

shown in the following examples:<br />

● <str<strong>on</strong>g>Oracle</str<strong>on</strong>g><br />

●<br />

CREATE OR REPLACE PROCEDURE <br />

(PARAMETER1 DATATYPE [IN OUT],<br />

PARAMETER2 DATATYPE [IN OUT],)<br />

IS<br />

VARIABLE1 DATATYPE;<br />

VARIABLE2 DATATYPE;<br />

BEGIN<br />

EXECUTABLE STATEMENTS;<br />

EXCEPTION<br />

EXECUTABLE STATEMENTS;<br />

END;<br />

<strong>SQL</strong> <strong>Server</strong><br />

CREATE PROCEDURE [ ; number ]<br />

[ { @PARAMETER DATATYPE }<br />

[ VARYING ] [ = default ] [ OUTPUT ]<br />

] [ ,...n ] AS<br />

EXECUTABLE STATEMENTS<br />

In the following example, a s<strong>to</strong>red procedure calculates the number of m<strong>on</strong>ths remaining<br />

until retirement <str<strong>on</strong>g>for</str<strong>on</strong>g> each employee. Retirement age is passed as a parameter <strong>to</strong> the<br />

procedure. The output needs <strong>to</strong> be written in<strong>to</strong> a table named RETIRE. The RETIRE<br />

table has two columns. The columns are EMPLOYEEID and MONTHS_REMAINING.<br />

The number of m<strong>on</strong>ths remaining is calculated and inserted in<strong>to</strong> this table. Be<str<strong>on</strong>g>for</str<strong>on</strong>g>e starting<br />

the operati<strong>on</strong>, the table needs <strong>to</strong> be flushed.<br />

● <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 207<br />

CREATE OR REPLACE PROCEDURE CALCULATE_RETIRE_MONTHS(RETIRE_AGE NUMBER) IS<br />

CURRENT_AGE NUMBER;<br />

MONTHS_REMAINING NUMBER;<br />

CURSOR EMP_CURSOR IS SELECT EMPLOYEEID, BIRTHDATE FROM EMPLOYEE;<br />

BEGIN<br />

EXECUTE IMMEDIATE 'TRUNCATE TABLE RETIRE';<br />

FOR CUR_VAL IN EMP_CURSOR<br />

LOOP<br />

CURRENT_AGE := ROUND(ROUND(SYSDATE - CUR_VAL.BIRTHDATE)/30)<br />

MONTHS_REMAINING := (RETIRE_AGE * 12) - CURRENT_AGE;<br />

INSERT INTO RETIRE VALUES(CUR_VAL.EMPLOYEE_ID,MONTHS_REMAINING);<br />

END LOOP;<br />

COMMIT;<br />

END;<br />

● <strong>SQL</strong> S erver<br />

IF EXISTS (SELECT NAME FROM SYSOBJECTS<br />

WHERE NAME = 'CALCULATE_RETIRE_YRS' AND TYPE = 'P')<br />

DROP PROCEDURE CALCULATE_RETIRE_YRS<br />

GO<br />

CREATE PROCEDURE CALCULATE_RETIRE_YRS @RETIRE_AGE INTEGER AS<br />

DECLARE @CUR_AGE INTEGER,@MONTHS_REMAINING INTEGER<br />

DECLARE @V_DOB DATETIME,@V_EMPLOYEEID VARCHAR(30)<br />

DECLA<br />

RE EMP_CURSOR CURSOR FOR<br />

SELECT EMPLOYEEID,BIRTHDATE FROM EMPLOYEE<br />

BEGIN<br />

TRUNCATE TABLE RETIRE;<br />

OPEN EMP_CURSOR<br />

FETCH NEXT FROM EMP_CURSOR INTO @V_EMPLOYEEID,@V_DOB<br />

IF @@FETCH_STATUS 0<br />

BEGIN<br />

PRINT 'NO EMP'<br />

END<br />

ELSE<br />

BEGIN<br />

WHILE (@@FETCH_STATUS = 0)<br />

BEGIN<br />

SET @CUR_AGE = ( SELECT DATEDIFF(MONTH,@V_DOB,GETDATE()) )<br />

SET @MONTHS_REMAINING = (SELECT (@RETIRE_AGE * 12) -<br />

@CUR_AGE)<br />

INSERT INTO RETIRE VALUES<br />

(@V_EMPLOYEEID,@MONTHS_REMAINING)<br />

FETCH NEXT FROM EMP_CURSOR INTO @V_EMPLOYEEID,@V_DOB<br />

END<br />

END<br />

CLOSE EMP_CURSOR<br />

DEALLOCATE EMP_CURSOR<br />

END


208 Developing: Applicati<strong>on</strong>s — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>SQL</strong> and PL/<strong>SQL</strong><br />

Functi<strong>on</strong>s<br />

While si milar <strong>to</strong> procedures, functi<strong>on</strong>s return a value. There may be some mathematical<br />

calculati<strong>on</strong> needed <str<strong>on</strong>g>for</str<strong>on</strong>g> the applicati<strong>on</strong> that is readily available in the database server. If<br />

you need the result of a complex algorithm as part of a <strong>SQL</strong> statement, you need <strong>to</strong> write<br />

a functio n that per<str<strong>on</strong>g>for</str<strong>on</strong>g>ms the required calculati<strong>on</strong> and returns a value.<br />

The syntax between <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong> functi<strong>on</strong>s differs, as shown in the following<br />

examples:<br />

● <str<strong>on</strong>g>Oracle</str<strong>on</strong>g><br />

●<br />

CREATE OR REPLACE FUNCTION <br />

(PARAMETER DATATYPE,<br />

PARAMETER DATATYPE ETC ..) RETURN DATATYPE<br />

IS<br />

<br />

BEGIN<br />

<br />

RETURN <br />

EXCEPTION<br />

;<br />

END;<br />

<strong>SQL</strong> <strong>Server</strong><br />

CREATE FUNCTION @PARAMETER DATATYPE,@PARAMETER DATATYPE ETC ..<br />

RETURNS AS<br />

BEGIN<br />

<br />

RETURN <br />

END<br />

The difference between built-in functi<strong>on</strong>s in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong> are discussed here.<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> also has a functi<strong>on</strong> called NEXT_DAY that returns the date of the first weekday<br />

named by char that is later than the current date. The char argument must be a day of<br />

the week in the date language of the sessi<strong>on</strong>, either the full name or the abbreviati<strong>on</strong>.<br />

The minimum number of letters required is the number of letters in the abbreviated<br />

versi<strong>on</strong>. Any characters immediately following the valid abbreviati<strong>on</strong> are ignored and the<br />

return value has the same hours, minutes, and sec<strong>on</strong>ds comp<strong>on</strong>ent as the argument<br />

date.<br />

By default, this functi<strong>on</strong> is not available in <strong>SQL</strong> <strong>Server</strong>. But the following example shows<br />

<strong>on</strong>e way <strong>to</strong> provide this functi<strong>on</strong> in <strong>SQL</strong> <strong>Server</strong>, and it can be expanded <strong>to</strong> meet your<br />

needs:<br />

CREATE FUNCTION NEXT_DAY(@D DATETIME,@DAY VARCHAR(10)) RETURNS DATETIME AS<br />

BEGIN<br />

DECLARE @DAY_NUMBER INTEGER<br />

DECLARE @NEWDATE DATETIME<br />

IF UPPER(@DAY)='SUNDAY'<br />

BEGIN<br />

IF ( 1 - DATEPART(DW,@D))=0<br />

SET @NEWDATE = @D + 7<br />

ELSE IF ( 1 - DATEPART(DW,@D)) < 0<br />

SET @NEWDATE = @D + 1 + ( 7 - DATEPART(DW,@D))<br />

ELSE


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 209<br />

END<br />

SET @NEWDATE = @ D + 1 - DATEPART(DW,@D)<br />

ELSE IF UPPER(@DAY)='MONDAY' OR UPPER(@DAY)= ‘MON’<br />

BEGIN<br />

IF ( 2 - DATEPART(DW,@D)) = 0<br />

SET @NEWDATE = @D + 7<br />

ELSE IF ( 2 - DATEPART(DW,@D))< 0<br />

SET @NEWDATE = @D + 2 + ( 7 - DATEPART(DW,@D))<br />

ELSE<br />

SET @NEWDATE = @D + 2 - DATEPART(DW,@D)<br />

END<br />

ELSE IF UPPER(@DAY)='TUESDAY' OR UPPER(@DAY)= ‘TUE’<br />

BEGIN<br />

IF ( 3 - DATEPART(DW,@D)) = 0<br />

SET @NEWDATE = @D + 7<br />

ELSE IF ( 3 - DATEPART(DW,@D))< 0<br />

SET @NEWDATE = @D + 3 + ( 7 - DATEPART(DW,@D))<br />

ELSE<br />

SET @NEWDATE = @D + 3 - DATEPART(DW,@D)<br />

END<br />

ELSE IF UPPER(@DAY)='WEDNESDAY' OR UPPER(@DAY)= ‘WED’<br />

BEGIN<br />

IF ( 4 - DATEPART(DW,@D)) = 0<br />

SET @NEWDATE = @D + 7<br />

ELSE IF ( 4 - DATEPART(DW,@D))< 0<br />

SET @NEWDATE = @D + 4 + ( 7 - DATEPART(DW,@D))<br />

ELSE<br />

SET @NEWDATE = @D + 4 - DATEPART(DW,@D)<br />

END<br />

ELSE IF UPPER(@DAY)='THURSDAY' OR UPPER(@DAY)= ‘THU’<br />

BEGIN<br />

IF ( 5 - DATEPART(DW,@D)) = 0<br />

SET @NEWDATE = @D + 7<br />

ELSE IF ( 5 - DATEPART(DW, @D))< 0<br />

SET @NEWDATE = @D + 5 + ( 7 - DATEPART(DW,@D))<br />

ELSE<br />

SET @NEWDATE = @D + 5 - DATEPART(DW,@D)END<br />

ELSE IF UPPER(@DAY)='FRIDAY' OR UPPER(@DAY)= ‘FRI’<br />

BEGIN<br />

IF ( 6 - DATEPART(DW,@D)) = 0<br />

SET @NEWDATE = @D + 7<br />

ELSE IF ( 6 - DATEPART(DW,@D))< 0<br />

SET @NEWDATE = @D + 6 + ( 7 - DATEPART(DW,@D))<br />

ELSE<br />

SET @NEWDATE = @D + 6 - DATEPART(DW,@D)END<br />

ELSE IF UPPER(@DAY)='SATURDAY' OR UPPER(@DAY)= ‘SAT’<br />

BEGIN<br />

IF ( 7 - DATEPART(DW,@D)) = 0


210 Developing: Applicati<strong>on</strong>s — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>SQL</strong> and PL/<strong>SQL</strong><br />

SET @NEWDATE = @D + 7<br />

ELSE IF ( 7 - DATEPART(DW,@D))< 0<br />

SET @NEWDATE = @D + 7 + ( 7 - DATEPART(DW,@D))<br />

ELSE<br />

SET @NEWDATE = @D + 7 - DATEPART(DW,@D)<br />

END<br />

ELSE<br />

SET @NEWDATE = NULL<br />

RETURN @NEWDATE<br />

END<br />

Triggers<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong> provide two primary mechanisms <str<strong>on</strong>g>for</str<strong>on</strong>g> en<str<strong>on</strong>g>for</str<strong>on</strong>g>cing business rules<br />

and data integrity through c<strong>on</strong>straints and triggers. A trigger is a special type of s<strong>to</strong>red<br />

procedure that au<strong>to</strong>matically takes effect when an event occurs. The event can be<br />

INSERT, UPDATE, or DELETE. The trigger and the statement that triggers are treated as<br />

a single transacti<strong>on</strong>, which can be rolled back from within the trigger. If an error is<br />

detected, the entire transacti<strong>on</strong> is au<strong>to</strong>matically rolled back.<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> uses two types of triggers <strong>on</strong> tables: table-level triggers and row-level triggers. If<br />

the key word FOR EACH ROW is specified, then it is a row-level trigger. Row-level<br />

triggers are fired <str<strong>on</strong>g>for</str<strong>on</strong>g> each row when it is affected. For example, if an update statement<br />

changes 5 rows, then the trigger will be fired 5 times. Table-level triggers are <strong>on</strong>ly fired<br />

<strong>on</strong>ce. In a table-level trigger, individual values cannot be captured. Row-level triggers<br />

capture the individual rows with the help of the keywords :NEW and :OLD. Unlike <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>,<br />

<strong>SQL</strong> <strong>Server</strong> does not have two types of triggers. The individual values can be captured<br />

from a special table called INSERTED. Old values can be fetched from the DELETED<br />

table and the new changed values can be retrieved from the INSERTED table.<br />

The deleted values can be referred with the special variable :OLD in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>. <strong>SQL</strong> <strong>Server</strong><br />

has a special table called DELETED. The DELETED table s<strong>to</strong>res copies of the affected<br />

rows during DELETE and UPDATE statements. During the executi<strong>on</strong> of a DELETE or<br />

UPDATE statement, rows are deleted from the trigger table and transferred <strong>to</strong> the<br />

DELETED table. The DELETED and INSERTED tables in <strong>SQL</strong> <strong>Server</strong> are <strong>on</strong>ly<br />

c<strong>on</strong>ceptual; they do not physically exist.<br />

A mapping of the functi<strong>on</strong>ality of triggers in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong> as well as a<br />

comparis<strong>on</strong> of the syntax is available under the <strong>to</strong>pic "Triggers" in Chapter 6:<br />

"Developing: Databases — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> Schemas."<br />

The syntax <str<strong>on</strong>g>for</str<strong>on</strong>g> the triggers differs as follows:<br />

● <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> triggers<br />

Separate syntax is used <str<strong>on</strong>g>for</str<strong>on</strong>g> each trigger command:<br />

● INSERT trigger syntax<br />

CREATE OR REPLACE TRIGGER <br />

[ BEFORE | AFTER ] INSERT ON <br />

[ FOR EACH ROW ]<br />

DECLARE<br />

BEGIN<br />

EXCEPTION<br />

END;


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 211<br />

●<br />

UPDATE trigger syntax<br />

CREATE OR REPLACE TRIGGER <br />

[ BEFORE | AFTER ] UPDATE OF ON <br />

[ FOR EACH ROW ]<br />

DECLARE<br />

BEGIN<br />

EXCEPTION<br />

●<br />

END;<br />

DELETE trigger syntax<br />

CREATE OR REPLACE TRIGGER <br />

[ BEFORE | AFTER ] DELETE ON <br />

[ FOR EACH ROW ]<br />

DECLARE<br />

BEGIN<br />

EXCEPTION<br />

END;<br />

●<br />

<strong>SQL</strong> <strong>Server</strong><br />

Unlike <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>, <strong>on</strong>ly <strong>on</strong>e syntax is needed <str<strong>on</strong>g>for</str<strong>on</strong>g> trigger functi<strong>on</strong>s in <strong>SQL</strong> <strong>Server</strong>:<br />

CREATE TRIGGER ON <br />

{FOR|AFTER|INSTEAD OF}<br />

{[INSERT][,][UPDATE][,][DELETE]}<br />

AS<br />

[{IF UPDATE(column)[{AND|OR}UPDATE(column)]}]<br />

EXECUTABLE STATEMENTS<br />

The following example further illustrates the use of trigger functi<strong>on</strong>s. In this example, the<br />

PRODUCT tables need <strong>to</strong> be updated when an order is issued against any product. The<br />

following code uses an INSERT trigger <strong>to</strong> per<str<strong>on</strong>g>for</str<strong>on</strong>g>m this task.<br />

● <str<strong>on</strong>g>Oracle</str<strong>on</strong>g><br />

●<br />

CREATE TRIGGER UPDATE_STOCK<br />

AFTER INSERT ON ORDERDETAILS<br />

FOR EACH ROW<br />

BEGIN<br />

UPDATE PRODUCT SET UNITINSTOCK = UNITINSTOCK - :NEW.QUANTITY<br />

WHERE PRODUCTID = :NEW.PRODUCTID;<br />

EXCEPTION<br />

WHEN OTHERS THEN<br />

NULL;<br />

END;<br />

<strong>SQL</strong> <strong>Server</strong><br />

CREATE TRIGGER UPDATE_STOCK ON ORDERDETAILS<br />

AFTER INSERT AS<br />

BEGIN<br />

UPDATE PRODUCT SET UNITINSTOCK = UNITINSTOCK – QUANTITY


212 Developing: Applicati<strong>on</strong>s — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>SQL</strong> and PL/<strong>SQL</strong><br />

FROM INSERTED WHERE PRODUCT.PRODUCTID = INSERTED.PRODUCTID<br />

END<br />

INSTEAD OF Triggers<br />

In gene ral, complex views are not updateable. Complex views are defined as normal<br />

views that include more than <strong>on</strong>e table or have GROUP BY expressi<strong>on</strong>s. Complex views<br />

can b e updated using INSTEAD OF triggers. Both <strong>SQL</strong> <strong>Server</strong> and <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> have the<br />

opti<strong>on</strong> of INSTEAD OF triggers. The INSTEAD OF trigger is generally defined <strong>on</strong> the<br />

view instead of <strong>on</strong> a table. In <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>, INSTEAD OF triggers can be applied <strong>on</strong>ly <strong>to</strong> the<br />

view and not <strong>to</strong> tables. In <strong>SQL</strong> <strong>Server</strong>, INSTEAD OF triggers can be applied <strong>to</strong> views and<br />

tables. When an insert, update or delete statement is executed against the table, the<br />

INSTEAD OF trigger is executed in place of the triggering statement.<br />

Also, INSTEAD OF triggers are executed instead of the triggering acti<strong>on</strong>. These triggers<br />

are executed after the inserted and deleted tables are created, but be<str<strong>on</strong>g>for</str<strong>on</strong>g>e any other<br />

acti<strong>on</strong>s are taken. They are executed be<str<strong>on</strong>g>for</str<strong>on</strong>g>e any c<strong>on</strong>straints, so they can per<str<strong>on</strong>g>for</str<strong>on</strong>g>m<br />

preprocessing that supplements the c<strong>on</strong>straint acti<strong>on</strong>.<br />

The triggering mechanism <strong>on</strong> INSTEAD OF triggers is implemented such that the trigger<br />

is not called recursively. The statement is processed as if there is no INSTEAD OF<br />

trigger defined <str<strong>on</strong>g>for</str<strong>on</strong>g> the table.<br />

If an UPDATE statement is executed <strong>on</strong> a view that has an INSTEAD OF trigger, the<br />

trigger will be called, but it is not executed recursively. The UPDATE statement is<br />

resolved against the base tables underlying the view. In this case, the view definiti<strong>on</strong><br />

must meet all of the restricti<strong>on</strong>s <str<strong>on</strong>g>for</str<strong>on</strong>g> an updateable view. The UPDATE executed by the<br />

trigger is processed against the view as if the view did not have an INSTEAD OF trigger.<br />

The columns changed by the UPDATE must be resolved <strong>to</strong> a single base table. Each<br />

modificati<strong>on</strong> <strong>to</strong> underlying base tables starts the chain of applying c<strong>on</strong>straints and firing<br />

AFTER triggers defined <str<strong>on</strong>g>for</str<strong>on</strong>g> the table.<br />

<strong>SQL</strong> <strong>Server</strong> provides most of the functi<strong>on</strong>ality present in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> with respect <strong>to</strong> triggers<br />

with very little differences in their implementati<strong>on</strong>. <strong>SQL</strong> <strong>Server</strong>, however, does not have<br />

the BEFORE triggers and can be programmed using the INSTEAD OF triggers <strong>on</strong> tables.<br />

In <strong>SQL</strong> <strong>Server</strong> triggers <strong>on</strong> views have the same kind of features as seen <strong>on</strong> triggers <strong>on</strong><br />

tables as shown by the following syntax:<br />

CREATE TRIGGER ON <br />

{FOR|AFTER|INSTEAD OF}<br />

{[INSERT][,][UPDATE][,][DELETE]}<br />

AS<br />

BEGIN<br />

[{IF UPDATE(column)[{AND|OR}UPDATE(column)]<br />

EXECUTABLE STATEMENTS<br />

END<br />

An example of the use of INSTEAD OF triggers <strong>on</strong> view is given in:<br />

http://msdn.microsoft.com/library/default.asp?url=/library/en-<br />

us/vdbt7/html/dvc<strong>on</strong>usinginsteadoftriggers<strong>on</strong>views.asp.<br />

Error Handling<br />

Run-time errors in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>'s PL/<strong>SQL</strong> programs are d<strong>on</strong>e through excepti<strong>on</strong>s and<br />

excepti<strong>on</strong> handlers. Excepti<strong>on</strong>s are raised when errors occur. Although there are predefined<br />

system errors, users can also define their own errors in the declarati<strong>on</strong> secti<strong>on</strong><br />

using the syntax:<br />

excepti<strong>on</strong>_name<br />

EXCEPTION;


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 213<br />

The user-defined excepti<strong>on</strong>s can be triggered using the syntax:<br />

RAISE excepti<strong>on</strong>_name;<br />

Each BEGIN … END block has an associated<br />

end whose syntax is as follows.<br />

EXCEPTION WHEN excepti<strong>on</strong>_name THEN<br />

… statements …<br />

END;<br />

excepti<strong>on</strong> handler secti<strong>on</strong> defined at the<br />

Although these excepti<strong>on</strong> handler secti<strong>on</strong>s are absent in <strong>SQL</strong> <strong>Server</strong> at the block level,<br />

error handling is per<str<strong>on</strong>g>for</str<strong>on</strong>g>med through the use of the global variable @@Error, which is<br />

passed <strong>to</strong> the calling program and can be handled there. <strong>SQL</strong> <strong>Server</strong> sets the value of<br />

the @@Error variable after each T<strong>SQL</strong> statement. For example:,<br />

INSERT ….<br />

IF @@Error 0<br />

BEGIN<br />

END<br />

SELECT 'Unexpected error occurred: Insert failed', @@Error<br />

Return @@Error<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> has many predefined excepti<strong>on</strong>s, such as NO_DATA_FOUND,<br />

TOO_MANY_ROWS, ZERO_DIVIDE, INVALID_CURSOR, etc. The predefined excepti<strong>on</strong><br />

OTHERS is of special interest because it can be used as a catch-all excepti<strong>on</strong> <str<strong>on</strong>g>for</str<strong>on</strong>g> any<br />

excepti<strong>on</strong>s <str<strong>on</strong>g>for</str<strong>on</strong>g> which there is no definiti<strong>on</strong> in the excepti<strong>on</strong> secti<strong>on</strong>.<br />

<strong>SQL</strong> <strong>Server</strong> error messages can be viewed by selecting sysmessages system table.<br />

Each <strong>SQL</strong> <strong>Server</strong> internal error is qualified in<strong>to</strong> various severity levels. The severity of<br />

errors ranges from 1 <strong>to</strong> 25. Errors with severity 19 and above are c<strong>on</strong>sidered critical and<br />

may result in complete aborti<strong>on</strong> of the batch. In such cases, @@ Error may not capture<br />

the<br />

error raised.<br />

Similar in functi<strong>on</strong>ality <strong>to</strong> user-defined excepti<strong>on</strong>s and the<br />

RAISE_APPLICATON_ERROR functi<strong>on</strong> in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>, <strong>SQL</strong> <strong>Server</strong> provides ways <strong>to</strong> create<br />

cus<strong>to</strong>mized error messages that can be raised within T<strong>SQL</strong> code. These are called user-<br />

defined errors and can be raised using RAISERROR statement. If you are referencing an<br />

error number in the RAISERROR functi<strong>on</strong> in T<strong>SQL</strong>, you must create the user-defined<br />

message. You can also dynamically specify a text message in the RAISERROR functi<strong>on</strong>.<br />

This is d<strong>on</strong>e by using sp_addmessage system s<strong>to</strong>red procedure. For more in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong><br />

<strong>on</strong> how<br />

<strong>to</strong> create and raise user-defined errors, see<br />

http:/ /msdn.microsoft.com/library/defa ult.asp?url= /library/enus/acdata/ac_8_<br />

c<strong>on</strong>_05_3f76.asp.<br />

Step 5: Job Scheduling<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> uses applicati<strong>on</strong> code and OS utilities <strong>to</strong> schedule a job. <strong>SQL</strong> <strong>Server</strong> uses<br />

<strong>SQL</strong> <strong>Server</strong> agent <strong>to</strong> per<str<strong>on</strong>g>for</str<strong>on</strong>g>m these jobs. The in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> in this secti<strong>on</strong> describes<br />

creating a job and scheduling it in <strong>SQL</strong> <strong>Server</strong>.<br />

Scheduling Functi<strong>on</strong>s and Jobs<br />

Some frequently used scheduling functi<strong>on</strong>s that are packaged with <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> are discussed<br />

in this secti<strong>on</strong>. They include:<br />

● DBMS_JOB. This is an <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> supplied package <str<strong>on</strong>g>for</str<strong>on</strong>g> scheduling jobs. Several<br />

different procedures are packed inside this package.<br />

Included are:


214 Developing: Applicati<strong>on</strong>s — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>SQL</strong> and PL/<strong>SQL</strong><br />

●<br />

●<br />

●<br />

●<br />

DBMS_JOB.INSTANCE. This procedure is used <strong>to</strong> assign a particular instance<br />

<strong>to</strong> execute a job<br />

DBMS_JOB.CHANGE. This is used <strong>to</strong> alter the schedule of a job.<br />

DBMS_JOB.SUBMIT. After the creati<strong>on</strong> of job, this procedure submits a job <strong>to</strong><br />

the <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> instance.<br />

DBMS_JOB.RUN. Jobs can be executed <strong>on</strong> demand using this procedure.<br />

●<br />

cr<strong>on</strong>: cr<strong>on</strong> is a daem<strong>on</strong>, which means that it <strong>on</strong>ly needs <strong>to</strong> be started <strong>on</strong>ce, and<br />

will lay dormant until it is required. Generally, a <strong>SQL</strong> file is written that calls a<br />

particular procedure. This <strong>SQL</strong> file is called from a shell script and this script is<br />

scheduled using cr<strong>on</strong>. This is how a job is scheduled in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> running <strong>on</strong> <strong>UNIX</strong>.<br />

In <strong>SQL</strong> <strong>Server</strong>, jobs can be executed in the following ways:<br />

● Using the Enterprise Manager<br />

● Using the s<strong>to</strong>red procedures SP_ADD_JOB and SP_ADD_JOBSCHEDULE<br />

Using <strong>SQL</strong> <strong>Server</strong> Enterprise Manager<br />

A job can be scheduled by using the following steps.<br />

To execute a job in the background <strong>on</strong> scheduled basis, <strong>SQL</strong> <strong>Server</strong> agent must be running.<br />

1. Log in <strong>to</strong> Enterprise Manager.<br />

2. Expand the server group and then expand the server. Expand Management.<br />

Expand <strong>SQL</strong> <strong>Server</strong> Agent and select the Jobs node.<br />

3. Create a new job by right-clicking Jobs.<br />

4. Enter a name <str<strong>on</strong>g>for</str<strong>on</strong>g> the job in the Name field.<br />

5. Check the Enabled check box <strong>to</strong> make the job available <str<strong>on</strong>g>for</str<strong>on</strong>g> executi<strong>on</strong> either<br />

immediately or by scheduling it. A disabled job runs <strong>on</strong>ly if a user explicitly<br />

executes it..<br />

6. In the Owner list, select a user <strong>to</strong> be the owner of the job.<br />

7. Write the descripti<strong>on</strong> about the job in Descripti<strong>on</strong> text area.<br />

8. Select the Steps tab. A job step is an acti<strong>on</strong> that the job takes <strong>on</strong> a database or a<br />

server. Every job must have at least <strong>on</strong>e job step. Job steps can be operating<br />

system commands, Transact-<strong>SQL</strong> statements, or ActiveX Scripts.<br />

9. Click New <strong>to</strong> get the job step dialog box. Enter a job step name in the Job step<br />

name box. Select the type in the Type list, For example, you can click Operating<br />

system command (CmdExec).<br />

10. Enter a value from 0 <strong>to</strong> 999999 in the Process exit code dialog box.<br />

11. Enter the operating system command or executable program in the command box.<br />

If you select Transact-<strong>SQL</strong> statements or ActiveX scripts, you need <strong>to</strong> specify the<br />

commands as per the selecti<strong>on</strong>.<br />

12. In the Schedules tab, the schedule can be specified. Jobs can be scheduled <strong>to</strong> run<br />

weekly, daily, or recursive.<br />

13. In the Notificati<strong>on</strong>s tab, you can specify an e-mail address <strong>to</strong> send a notificati<strong>on</strong> if<br />

a job fails or succeeds. Messages can also be sent <strong>to</strong> a pager.<br />

Using SP_ADD_JOB<br />

Jobs in <strong>SQL</strong> <strong>Server</strong> can also be scheduled using the s<strong>to</strong>red procedure SP_ADD_JOB.<br />

This simply adds a job in <strong>SQL</strong> Agent service. Job steps and scheduling can be d<strong>on</strong>e <strong>on</strong>ly<br />

with other procedures. The syntax <str<strong>on</strong>g>for</str<strong>on</strong>g> use and descripti<strong>on</strong>s are provided in the following<br />

example:


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 215<br />

SP_ADD_JOB [ @JOB_NAME = ] 'JOB_NAME'<br />

[ , [ @ENABLED = ] ENABLED ]<br />

[ , [ @DESCRIPTION = ] 'DESCRIPTION' ]<br />

[ , [ @OWNER_LOGIN_NAME = ] 'LOGIN' ]<br />

[ , [ @NOTIFY_LEVEL_EVENTLOG = ] EVENTLOG_LEVEL ]<br />

[ , [ @NOTIFY_LEVEL_EMAIL = ] EMAIL_LEVEL ]<br />

[ , [ @NOTIFY_LEVEL_NETSEND = ] NETSEND_LEVEL ]<br />

[ , [ @NOTIFY_LEVEL_PAGE = ] PAGE_LEVEL ]<br />

[ , [ @NOTIFY_EMAIL_OPERATOR_NAME = ] 'EMAIL_NAME' ]<br />

[ , [ @NOTIFY_NETSEND_ OPERATOR_NAME = ] 'NETSEND_NAME' ]<br />

[ , [ @NOTIFY_PAGE_OPERATOR_NAME = ] 'PAGE_NAME' ]<br />

[ , [ @DELETE_LEVEL = ] DELETE_LEVEL ]<br />

[ @JOB_NAME = ] 'JOB_NAME'<br />

@JOB_ NAME is the name of the job. The name must be unique and cannot c<strong>on</strong>tain the<br />

percent (%) character. The comm<strong>on</strong>ly used parameters include:<br />

● [ @ENABLED = ] ENABLED<br />

@ENABLED indicates the status of the added job. ENABLED has a default of 1<br />

(enabled). If 0, the job is not enabled and does not run according <strong>to</strong> its schedule,<br />

but it can be run manually.<br />

● [ @DESCRIPTION = ] 'DESCRIPTION'<br />

@DESCRI PTION is the descripti<strong>on</strong> of the job. This descripti<strong>on</strong> can be a maximum<br />

of 512 characters.<br />

● [ @OWNER_LOGIN_NAME = ] 'LOGIN'<br />

@OWNER_LOGIN_NAME is the name of the login that owns the job.<br />

● [ @ NOTIFY_LEVEL_EVENTLOG = ] EVENTLOG_LEVEL<br />

@NOTIFY_LEVEL_EVENTLOG is a value indicating when <strong>to</strong> place an entry in the<br />

Windows® applicati<strong>on</strong> log (Event viewer) <str<strong>on</strong>g>for</str<strong>on</strong>g> this job. The value can c<strong>on</strong>tain <strong>on</strong>e of<br />

the values described in Table 11.18:<br />

Table 11.18: Values <str<strong>on</strong>g>for</str<strong>on</strong>g> EVENTLOG_LEVEL <str<strong>on</strong>g>for</str<strong>on</strong>g> SP_ADD_JOB<br />

Value<br />

Descripti<strong>on</strong><br />

0 Never<br />

1 On success<br />

2 (default) On failure<br />

3 Always<br />

●<br />

●<br />

●<br />

●<br />

[ @NOTIFY_LEVEL_EMAIL = ] EMAIL_LEVEL<br />

The value indicates when <strong>to</strong> send e-mail up<strong>on</strong> the completi<strong>on</strong> of this job. This uses<br />

the same values as listed in Table 11.18.<br />

[ @NOTIFY_LEVEL_NETSEND = ] NETSEND_LEVEL<br />

The value indicates when <strong>to</strong> send a network message up<strong>on</strong> the completi<strong>on</strong> of this<br />

job. This uses the same values as listed in Table 11.18.<br />

[ @NOTIFY_LEVEL_PAGE = ] PAGE_LEVEL<br />

The value indicates when <strong>to</strong> send a page up<strong>on</strong> the completi<strong>on</strong> of this job. This<br />

uses the same values as listed in Table 11.18.<br />

[ @NOTIFY_EMAIL_OPERATOR_NAME = ] 'EMAIL_NAME'


216 Developing: Applicati<strong>on</strong>s — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>SQL</strong> and PL/<strong>SQL</strong><br />

●<br />

●<br />

●<br />

This is the e-mail address of the pers<strong>on</strong> <strong>to</strong> send e-mail <strong>to</strong> when EMAIL_LEVEL is<br />

reached.<br />

[ @NOTIFY_NETSEND_OPERATOR_NAME = ] 'NETSEND_NAME'<br />

Name of the opera<strong>to</strong>r <strong>to</strong> whom the network message is sent up<strong>on</strong> completi<strong>on</strong> of<br />

this job.<br />

[ @NOTIFY_PAGE_OPERATOR_NAME = ] 'PAGE_NAME'<br />

Name of the pers<strong>on</strong> <strong>to</strong> page up<strong>on</strong> completi<strong>on</strong> of this job.<br />

[ @DELETE_LEVEL = ] DELETE_LEVEL<br />

This value indicates when <strong>to</strong> delete the job. This uses the same values as listed in<br />

Table 11.18.<br />

The following example shows how <strong>to</strong> create a job from the s<strong>to</strong>red procedure. This creates<br />

a job named FILE2. The job is enabled with the notificati<strong>on</strong> level of zero. No notificati<strong>on</strong>s<br />

will be created up<strong>on</strong> success or failure. Opera<strong>to</strong>r DBO is assigned as owner <str<strong>on</strong>g>for</str<strong>on</strong>g> this job.<br />

USE MSDB<br />

EXEC SP_ADD_JOB @JOB_NAME = 'FILE2',<br />

@ENABLED = 1,<br />

@DESCRIPTION = 'FILE DUMP JOB',<br />

@OWNER_LOGIN_NAME = 'DBO',<br />

@NOTIFY_LEVEL_EVENTLOG = 0,<br />

@NOTIFY_LEVEL_EMAIL = 0,<br />

@NOTIFY_LEVEL_NETSEND = 0,<br />

@NOTIFY_LEVEL_PAGE = 0,<br />

@DELETE_LEVEL = 0<br />

After the job is created, it must have some steps <strong>to</strong> execute. The steps define the<br />

functi<strong>on</strong> of the job. The following example runs a Data Trans<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> package by using<br />

the DTSRUN utility. SUBSYSTEM should be CMDEXEC <strong>to</strong> run any utility from a job.<br />

USE MSDB<br />

EXEC SP_ADD_JOBSTEP @JOB_NAME = 'FILE2',<br />

@STEP_NAME = 'STEP1 IN FILE2',<br />

@SUBSYSTEM = 'CMDEXEC',<br />

@COMMAND = 'DTSRUN /S "(LOCAL)" /N "FILETRANSFER" /U "SA" /P "SA" ',<br />

@RETRY_ATTEMPTS = 5,<br />

@RETRY_INTERVAL = 5<br />

@SUBSYSTEM is used by the <strong>SQL</strong> <strong>Server</strong> agent service. The available values are<br />

described in Table 11.19.<br />

Table 11.19: Values <str<strong>on</strong>g>for</str<strong>on</strong>g> @SUBSYSTEM <str<strong>on</strong>g>for</str<strong>on</strong>g> SP_ADD_JOB<br />

Subsystem Type<br />

ACTIVESCRIPTING<br />

CMDEXEC<br />

DISTRIBUTION<br />

SNAPSHOT<br />

LOGREADER<br />

MERGE<br />

'T<strong>SQL</strong>' (default)<br />

Descripti<strong>on</strong><br />

Active Script<br />

Operating-system command or executable program<br />

Replicati<strong>on</strong> Distributi<strong>on</strong> Agent job<br />

Replicati<strong>on</strong> Snapshot Agent job<br />

Replicati<strong>on</strong> Log Reader Agent job<br />

Replicati<strong>on</strong> Merge Agent job<br />

Transact-<strong>SQL</strong> statement<br />

@COMMAND<br />

is the actual command <strong>to</strong> execute. In the following example, the DTSRUN<br />

utility is used. Any executable can be called using @COMMAND.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 217<br />

Any number of steps can be added <strong>to</strong> a single job. The sequence of the steps is<br />

determined by the parameter @STEP_ID in this procedure.<br />

After the steps have been created, the job can be either executed manually or scheduled.<br />

If it needs <strong>to</strong> be scheduled, then SP_ADD_JOBSCHEDULE is used with a set of<br />

parameters.<br />

This example highlights how <strong>to</strong> schedule a job FILE2 <strong>to</strong> occur everyday at 1:00 A.M. in<br />

<strong>SQL</strong> <strong>Server</strong>.<br />

USE MSDB<br />

EXEC SP_ADD_JOBSCHEDULE @JOB_NAME = 'FILE2',<br />

@NAME = 'DAILY LOAD',<br />

@FREQ_TYPE = 4, -- DAILY<br />

@FREQ_INTERVAL = 1,<br />

@ACTIVE_START_TIME = 10000<br />

@FREQ_TYPE is the frequency type. It can accept any <strong>on</strong>e of the values listed in Table<br />

11.20:<br />

Table 11.20: Values <str<strong>on</strong>g>for</str<strong>on</strong>g> @FREQ_TYPE <str<strong>on</strong>g>for</str<strong>on</strong>g> SP_ADD_JOB<br />

Value Descripti<strong>on</strong><br />

1 Once<br />

4 Daily<br />

8 Weekly<br />

16 M<strong>on</strong>thly<br />

32 M<strong>on</strong>thly, relative <strong>to</strong> freq interval<br />

64 Run when <strong>SQL</strong> <strong>Server</strong> Agent service starts<br />

128 Run when the computer is idle<br />

@FREQ_INTERVAL acts depend up<strong>on</strong> the value of @FREQ_TYPE. For example, if<br />

@ FREQ_TYPE is set as <strong>on</strong>ce, then @ FREQ_INTERVAL has no impact. If<br />

@FREQ_INTERVAL is set <strong>to</strong> run weekly, then @FREQ_INTERVAL is used <strong>to</strong> indicate<br />

<strong>on</strong> which day the job should run.<br />

For more in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <strong>on</strong> this <strong>to</strong>pic, refer <strong>to</strong> the MSDN library at http://www.msdn.com.<br />

Step 6: Interface File C<strong>on</strong>versi<strong>on</strong><br />

Any applicati<strong>on</strong> will have inbound and outbound interface files. During applicati<strong>on</strong><br />

migrati<strong>on</strong>, it is the applicati<strong>on</strong> developer's resp<strong>on</strong>sibility <strong>to</strong> c<strong>on</strong>sider all inbound as well as<br />

outbound files. External applicati<strong>on</strong>s will use specified <str<strong>on</strong>g>for</str<strong>on</strong>g>mats. Even after the c<strong>on</strong>versi<strong>on</strong><br />

from <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>, the external applicati<strong>on</strong> will still need the interface file in the same <str<strong>on</strong>g>for</str<strong>on</strong>g>mat.<br />

Similarly, the external applicati<strong>on</strong> might send some interface files <strong>to</strong> the database.<br />

C<strong>on</strong>sidering that the <str<strong>on</strong>g>for</str<strong>on</strong>g>mat might remain the same, applicati<strong>on</strong> code must be c<strong>on</strong>verted<br />

in such a way that the applicati<strong>on</strong> will handle the file, even though it is not in a<br />

<strong>SQL</strong> <strong>Server</strong>-specific <str<strong>on</strong>g>for</str<strong>on</strong>g>mat.<br />

Step 7: Workflow Au<strong>to</strong>mati<strong>on</strong><br />

When per<str<strong>on</strong>g>for</str<strong>on</strong>g>ming the applicati<strong>on</strong> migrati<strong>on</strong>, workflow must also be examined. This<br />

secti<strong>on</strong> discusses how <strong>to</strong> send<br />

mail from the <strong>SQL</strong> <strong>Server</strong> database.


218 Developing: Applicati<strong>on</strong>s — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>SQL</strong> and PL/<strong>SQL</strong><br />

Sending Mail<br />

Sending mail from an applicati<strong>on</strong> is a very comm<strong>on</strong> requirement. <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> includes a<br />

package named UTL_SMTP <strong>to</strong> provide e-mail functi<strong>on</strong>s. Using UTL_SMTP, applicati<strong>on</strong><br />

developers write their code <strong>to</strong> send notificati<strong>on</strong> mails from PL/<strong>SQL</strong> programs. Some<br />

setup is needed in the server side be<str<strong>on</strong>g>for</str<strong>on</strong>g>e UTL_SMTP can be used.<br />

<strong>SQL</strong> <strong>Server</strong> has several opti<strong>on</strong>s <strong>to</strong> send e-mail. Be<str<strong>on</strong>g>for</str<strong>on</strong>g>e using these opti<strong>on</strong>s, the mail<br />

accounts and mail service in the server where <strong>SQL</strong> <strong>Server</strong> resides needs <strong>to</strong> be set up<br />

and c<strong>on</strong>figured. After this is set up, the XP_SENDMAIL s<strong>to</strong>red procedure can be used <strong>to</strong><br />

send notificati<strong>on</strong> mails. XP_SENDMAIL has all the opti<strong>on</strong>s of mail services, including<br />

attachments. For example, the error log file can be sent <strong>to</strong> the administra<strong>to</strong>r in case of<br />

server side errors.<br />

Be<str<strong>on</strong>g>for</str<strong>on</strong>g>e using mail opti<strong>on</strong>s, set up <strong>SQL</strong> Mail in <strong>SQL</strong> <strong>Server</strong> Enterprise Manager<br />

using the following steps:<br />

1. Expand the server group and then expand the server.<br />

2. Expand Support Services, right-click <strong>SQL</strong> Mail, and then click Properties.<br />

3. In the Profile list, select the profile that you created earlier.<br />

4. Click Test if you want <strong>to</strong> test the <strong>SQL</strong> mail.<br />

After <strong>SQL</strong> mail is set up, jobs can be c<strong>on</strong>figured <strong>to</strong> send mail alerts <strong>on</strong> job<br />

completi<strong>on</strong> <strong>to</strong> indicate whether the job succeeded or failed. To c<strong>on</strong>figure the<br />

jobs, follow these steps:<br />

1. Go <strong>to</strong> Jobs, select a particular job, and then click Properties.<br />

2. On the Notificati<strong>on</strong> tab, you can enable the mailing opti<strong>on</strong> up<strong>on</strong> success or failure.<br />

3. To send mail from Jobs, the Mail comp<strong>on</strong>ent needs <strong>to</strong> be started. This can be<br />

started au<strong>to</strong>matically whenever <strong>SQL</strong> <strong>Server</strong> agent starts. Alternatively,<br />

XP_STARTMAIL can be used <strong>to</strong> start the mail agent of <strong>SQL</strong> <strong>Server</strong>.<br />

In additi<strong>on</strong>, XP_SENDMAIL can be used <strong>to</strong> send mail from T-<strong>SQL</strong> batches, triggers, or<br />

procedures. The syntax is shown in the following example:<br />

XP_SENDMAIL {[@RECIPIENTS =] 'RECIPIENTS [;...N]'}<br />

[,[@MESSAGE =] 'MESSAGE']<br />

[,[@QUERY =] 'QUERY']<br />

[,[@ATTACHMENTS =] 'ATTACHMENTS [;...N]']<br />

[,[@COPY_RECIPIENTS =] 'COPY_RECIPIENTS [;...N]'<br />

[,[@BLIND_COPY_RECIPIENTS =] 'BLIND_COPY_RECIPIENTS [;...N]'<br />

[,[@SUBJECT =] 'SUBJECT']<br />

The following example sends a mail <strong>to</strong> the mail ID <strong>SQL</strong>DBA@ABC.COM and a copy <strong>to</strong><br />

another mail ID <strong>SQL</strong>DBA1@ABC.COM. This also sends an attachment with the name<br />

"error.log" that is in the direc<strong>to</strong>ry C:\.<br />

XP_SENDMAIL @RECIPIENTS='<strong>SQL</strong>DBA@ABC.COM', @MESSAGE='Test mail from <strong>SQL</strong> Mail',<br />

@ATTACHMENTS='C:\ERROR_LOG', @COPY_RECIPIENTS='@<strong>SQL</strong>DBA1@ABC.COM', @SUBJECT='Test<br />

Subject'<br />

Step 8: Per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance Tuning<br />

After the code changes have been incorporated, the next step is <strong>to</strong> review and tune the<br />

per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance. Make sure proper joins are in place and all possible indexed columns are<br />

used while executing the query.<br />

General techniques and guidelines are discussed in this<br />

secti<strong>on</strong>.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 219<br />

After following these optimizati<strong>on</strong> techniques, test the applicati<strong>on</strong> with a test database. If<br />

possible, use a copy of producti<strong>on</strong> data while testing so that the real resp<strong>on</strong>se times can<br />

be recorded and more time can be spent tuning the applicati<strong>on</strong>.<br />

The goal of per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance tuning is <strong>to</strong> minimize the resp<strong>on</strong>se time <str<strong>on</strong>g>for</str<strong>on</strong>g> each query and <strong>to</strong><br />

maximize the throughput of the entire database server by reducing network traffic, disk<br />

I/O, and CPU time. This goal is achieved through understanding applicati<strong>on</strong><br />

requirements, the logical and physical structure of the data, and tradeoffs between<br />

c<strong>on</strong>flicting uses of the database. Per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance strategies vary in their effectiveness, and<br />

systems with different purposes, such as operati<strong>on</strong>al systems and decisi<strong>on</strong> support<br />

systems, require different per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance skills.<br />

System per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance is designed and built in<strong>to</strong> a system. It does not just happen.<br />

Per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance issues should be c<strong>on</strong>sidered throughout the development cycle, not just at<br />

the end when the system is implemented. Many per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance issues that result in<br />

significant improvements are achieved by careful design from the outset.<br />

Per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance problems are usually the result of competiti<strong>on</strong> <str<strong>on</strong>g>for</str<strong>on</strong>g>, or exhausti<strong>on</strong> of, system<br />

resources.<br />

When a system resource is exhausted, the system is unable <strong>to</strong> scale <strong>to</strong> higher<br />

levels of per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance. Although other system-level per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance issues, such as memory<br />

or hardware, are certainly candidates <str<strong>on</strong>g>for</str<strong>on</strong>g> study, experience shows that the per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance<br />

gains from tuning a query are <strong>on</strong>ly incremental when there are fundamental problems in<br />

its design.<br />

This secti<strong>on</strong> describes how <strong>SQL</strong> <strong>Server</strong> queries can be optimized when migrating from<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> applicati<strong>on</strong>s.<br />

For example, in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>, there are several areas where a DBA c<strong>on</strong>centrates <strong>on</strong> tuning the<br />

database and queries, such as:<br />

● Memory tuning<br />

● I/O tuning<br />

● <strong>SQL</strong> tuning<br />

● Managing data and transacti<strong>on</strong>s<br />

<strong>SQL</strong> <strong>Server</strong> au<strong>to</strong>matically manages available hardware resources, reducing the need <str<strong>on</strong>g>for</str<strong>on</strong>g><br />

extensive system-level manual tuning. Apart from this au<strong>to</strong>matic management,<br />

<strong>SQL</strong> <strong>Server</strong> provides several ways <strong>to</strong> optimize per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance during the development and<br />

after the system is released in<strong>to</strong> producti<strong>on</strong>. These methods are discussed under the<br />

following headings.<br />

Query Tuning<br />

It may be tempting <strong>to</strong> address a per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance problem solely by system-level server<br />

per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance tuning; <str<strong>on</strong>g>for</str<strong>on</strong>g> example, by altering memory size, type of file system, and<br />

number and type of processors. Generally, most per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance problems cannot be<br />

resolved this way. They must be addressed by analyzing the applicati<strong>on</strong>, queries, and<br />

updates that the applicati<strong>on</strong> is submitting <strong>to</strong> the database, and how these queries and<br />

updates interact with the database schema.<br />

Unexpected l<strong>on</strong>g-lasting queries and updates can be caused by:<br />

● Slow network communicati<strong>on</strong><br />

● Inadequate memory in the server computer<br />

● Lack of useful statistics<br />

● Out-of-date statistics<br />

● Lack of useful indexes


220 Developing: Applicati<strong>on</strong>s — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>SQL</strong> and PL/<strong>SQL</strong><br />

●<br />

●<br />

Lack of useful data striping<br />

Improper database design<br />

These issues can be resolved <strong>on</strong>ly by looking at the query and its path of executi<strong>on</strong>.<br />

<strong>SQL</strong> <strong>Server</strong> has several ways <strong>to</strong> identify all of these issues. Two of the comm<strong>on</strong>ly used<br />

methods, <strong>SQL</strong> Profiler and the SET SHOWPLAN statement, are discussed here. Refer <strong>to</strong><br />

Appendix B <str<strong>on</strong>g>for</str<strong>on</strong>g> a list of references about improving per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance.<br />

<strong>SQL</strong> Profiler<br />

This graphical <strong>to</strong>ol allows system administra<strong>to</strong>rs <strong>to</strong> m<strong>on</strong>i<strong>to</strong>r events in an instance of<br />

<strong>SQL</strong> <strong>Server</strong>. Each event can be captured <strong>to</strong> a file or another table. Using this data, the<br />

query can be analyzed. A s<strong>to</strong>red procedure that hampers the per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance can also be<br />

m<strong>on</strong>i<strong>to</strong>red.<br />

Only use the <strong>SQL</strong> Profiler <str<strong>on</strong>g>for</str<strong>on</strong>g> suspicious events. As <strong>SQL</strong> Profiler is used, it can slow<br />

down the server and increase the trace file size. Specific events can be filtered so <strong>on</strong>ly a<br />

subset of data can be m<strong>on</strong>i<strong>to</strong>red.<br />

After you have traced the events, <strong>SQL</strong> Profiler allows captured event data <strong>to</strong> be replayed<br />

against an instance of <strong>SQL</strong> <strong>Server</strong>, effectively re-executing the saved events as they<br />

occurred originally.<br />

<strong>SQL</strong> Profiler can be used <strong>to</strong>:<br />

● M<strong>on</strong>i<strong>to</strong>r the per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance of an instance of <strong>SQL</strong> <strong>Server</strong>.<br />

● Debug Transact-<strong>SQL</strong> statements and s<strong>to</strong>red procedures.<br />

● Identify slow-executing queries.<br />

● Test <strong>SQL</strong> statements and s<strong>to</strong>red procedures in the Developing Phase of a project<br />

by going through statements <strong>to</strong> c<strong>on</strong>firm that the code works as expected.<br />

● Troubleshoot problems in <strong>SQL</strong> <strong>Server</strong> by capturing events <strong>on</strong> a producti<strong>on</strong> system<br />

and replaying them <strong>on</strong> a test system. This is useful <str<strong>on</strong>g>for</str<strong>on</strong>g> testing or debugging<br />

purposes and allows users <strong>to</strong> c<strong>on</strong>tinue using the producti<strong>on</strong> system without<br />

interference.<br />

● Audit and review activity that occurred <strong>on</strong> an instance of <strong>SQL</strong> <strong>Server</strong>. This allows a<br />

security administra<strong>to</strong>r <strong>to</strong> review any of the auditing events, including the success<br />

and failure of a login attempt and the success and failure of permissi<strong>on</strong>s in<br />

accessing statements and objects.<br />

• Provide input <strong>to</strong> the Index Tuning Wizard <strong>to</strong> determine index usage suggesti<strong>on</strong>s.<br />

Using SET SHOWPLAN in <strong>SQL</strong> <strong>Server</strong><br />

SET SHOWLAN is similar <strong>to</strong> the <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> EXPAIN PLAN command, and it is used <strong>to</strong><br />

display detailed in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> about a query. SET SHOWPLAN_ALL causes <strong>SQL</strong> <strong>Server</strong><br />

not <strong>to</strong> execute Transact-<strong>SQL</strong> statements. Instead, <strong>SQL</strong> <strong>Server</strong> returns detailed<br />

in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> about how the statements are executed and provides estimates of the<br />

resource requirements <str<strong>on</strong>g>for</str<strong>on</strong>g> the statements. The syntax <str<strong>on</strong>g>for</str<strong>on</strong>g> this command is:<br />

SET SHOWPLAN_ALL {ON | OFF}<br />

When SET SHOWPLAN_ALL is ON, <strong>SQL</strong> <strong>Server</strong> returns executi<strong>on</strong> in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <str<strong>on</strong>g>for</str<strong>on</strong>g> each<br />

statement without executing it, and Transact-<strong>SQL</strong> statements are not executed. After this<br />

opti<strong>on</strong> is set ON, in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> about all subsequent Transact-<strong>SQL</strong> statements is returned<br />

until the opti<strong>on</strong> is set OFF.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 221<br />

For example, if a CREATE TABLE statement is executed while SET SHOWPLAN_ALL is<br />

ON, <strong>SQL</strong> <strong>Server</strong> returns an error message. When SET SHOWPLAN_ALL is OFF,<br />

<strong>SQL</strong> <strong>Server</strong> executes the statements without generating a report.<br />

Use SET SHOWPLAN_TEXT <strong>to</strong> return readable output <str<strong>on</strong>g>for</str<strong>on</strong>g> Microsoft MS-DOS<br />

applicati<strong>on</strong>s, such as the osql utility.<br />

SET SHOWPLAN_TEXT and SET SHOWPLAN_ALL cannot be specified inside a s<strong>to</strong>red<br />

procedure; they must be the <strong>on</strong>ly statements in a batch.<br />

SET SHOWPLAN_ALL returns in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> as a set of rows that <str<strong>on</strong>g>for</str<strong>on</strong>g>m a hierarchical tree<br />

representing the steps taken by the <strong>SQL</strong> <strong>Server</strong> query processor as it executes each<br />

statement. Each statement reflected in the output c<strong>on</strong>tains a single row with the text of<br />

the statement, followed by several rows with the details of the executi<strong>on</strong> steps.<br />

For a more detailed view of the output obtained by turning <strong>on</strong> SET SHOWPLAN_ALL,<br />

refer <strong>to</strong> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_set-<br />

set_365o.asp.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 223<br />

12<br />

Developing: Applicati<strong>on</strong>s —<br />

<str<strong>on</strong>g>Migrating</str<strong>on</strong>g> Perl<br />

Introducti<strong>on</strong> and Goals<br />

This chapter c<strong>on</strong>tains a detailed discussi<strong>on</strong> of changes that must be made <strong>to</strong> Perl<br />

applicati<strong>on</strong>s <strong>to</strong> work with Microsoft® <strong>SQL</strong> <strong>Server</strong>. At the c<strong>on</strong>clusi<strong>on</strong> of this chapter, the<br />

Perl applicati<strong>on</strong> should be capable of successfully c<strong>on</strong>necting <strong>to</strong> the <strong>SQL</strong> <strong>Server</strong><br />

database that was migrated from <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and the soluti<strong>on</strong> can be tested.<br />

As discussed in the "Define the <str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> C<strong>on</strong>cept" secti<strong>on</strong> of Chapter 2, "Envisi<strong>on</strong>ing<br />

Phase", there are four different strategies available <str<strong>on</strong>g>for</str<strong>on</strong>g> transiti<strong>on</strong>ing applicati<strong>on</strong>s in an<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> migrati<strong>on</strong> project. The strategies are:<br />

● Interoperate the applicati<strong>on</strong> with <strong>UNIX</strong>.<br />

● Port or rewrite the applicati<strong>on</strong> <strong>to</strong> the Microsoft .NET plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m.<br />

● Port or rewrite the applicati<strong>on</strong> <strong>to</strong> the Microsoft Win32® plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m.<br />

● Quick port using the Windows® Services <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>UNIX</strong> 3.5 plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m.<br />

Perl is an interpreted scripting language that runs <strong>on</strong> both <strong>UNIX</strong> and Windows. Because<br />

of the cross-plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m capabilities of Perl, some of these strategies are more logical than<br />

others.<br />

For example, because Perl can be ported <strong>to</strong> Windows, there is no need <strong>to</strong> rewrite the<br />

applicati<strong>on</strong> in the .NET framework or <str<strong>on</strong>g>for</str<strong>on</strong>g> the Win32® envir<strong>on</strong>ment. Also, because the<br />

applicati<strong>on</strong> can run within the Windows envir<strong>on</strong>ment, a quick port using<br />

Windows Services <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>UNIX</strong> is not necessary and would <strong>on</strong>ly prevent the applicati<strong>on</strong> from<br />

tightly integrating with Windows.<br />

Based <strong>on</strong> available migrati<strong>on</strong> strategies, two scenarios can be developed <strong>to</strong> migrate Perl<br />

applicati<strong>on</strong>s. The soluti<strong>on</strong> scenarios are:<br />

● Scenario 1: Interoperati<strong>on</strong> of Perl <strong>on</strong> <strong>UNIX</strong> with <strong>SQL</strong> <strong>Server</strong><br />

If the business requirements do not include eliminating the <strong>UNIX</strong> envir<strong>on</strong>ment, an<br />

interoperati<strong>on</strong> strategy can be implemented quickly. Few changes need <strong>to</strong> be<br />

made <strong>to</strong> the source code, and installing a new driver allows the Perl applicati<strong>on</strong> <strong>to</strong><br />

c<strong>on</strong>nect <strong>to</strong> a <strong>SQL</strong> <strong>Server</strong> database. Interoperati<strong>on</strong> can also be used as an interim<br />

step if the migrati<strong>on</strong> is per<str<strong>on</strong>g>for</str<strong>on</strong>g>med in phases.<br />

● Scenario 2: Port the Perl Applicati<strong>on</strong> <strong>to</strong> Win32


224 Developing: Applicati<strong>on</strong>s — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> Perl<br />

Perl applicati<strong>on</strong>s can also be ported <strong>to</strong> run natively <strong>on</strong> the Windows plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m. As<br />

with interoperati<strong>on</strong>, few changes need <strong>to</strong> be made <strong>to</strong> the source code.<br />

Note If your Perl applicati<strong>on</strong>s use <strong>UNIX</strong> system calls extensively (such as frequent use<br />

of syscall and exec), porting them <strong>to</strong> Windows Services <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>UNIX</strong>/Interix may be a<br />

suitable opti<strong>on</strong> because Interix has more support <str<strong>on</strong>g>for</str<strong>on</strong>g> the desired system calls. Chapter<br />

2, "Envisi<strong>on</strong>ing Phase," provides a more detailed discussi<strong>on</strong> of when choosing<br />

Services <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>UNIX</strong> would be more appropriate when moving <strong>to</strong> a Windows-based<br />

plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m.<br />

You will need the following <strong>to</strong> implement this opti<strong>on</strong> (porting Perl applicati<strong>on</strong>s <strong>to</strong> Services<br />

<str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>UNIX</strong>/<strong>SQL</strong> <strong>Server</strong>):<br />

● A port of Perl <str<strong>on</strong>g>for</str<strong>on</strong>g> Interix (downloadable from Interop Systems at<br />

http://www.interopsystems.com/<strong>to</strong>ols/warehouse.htm), which ships with the<br />

necessary DBI, DBD::ODBC and DBD::Sybase modules.<br />

● A c<strong>on</strong>nectivity driver <strong>to</strong> the <strong>SQL</strong> <strong>Server</strong> database. This is provided by the port of<br />

FreeTDS <strong>on</strong> Interix and is downloadable from Interop Systems at<br />

http://www.interopsystems.com/<strong>to</strong>ols/db.htm. FreeTDS provides two c<strong>on</strong>nectivity<br />

opti<strong>on</strong>s <str<strong>on</strong>g>for</str<strong>on</strong>g> the Perl applicati<strong>on</strong> <strong>to</strong> c<strong>on</strong>nect <strong>to</strong> the <strong>SQL</strong> <strong>Server</strong> database. One is a<br />

library called CTlib, which can be accessed through the DBD::Sybase module. The<br />

other is an odbc driver, which can be accessed though the DBD::ODBC module.<br />

● If you use the ODBC driver, you will also need an ODBC driver manager. Two<br />

different ODBC driver managers iODBC and unixODBC are available <str<strong>on</strong>g>for</str<strong>on</strong>g> Windows<br />

Services <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>UNIX</strong> from http://www.inte ropsystems.com/<strong>to</strong>ols/warehouse.htm.<br />

This technology opti<strong>on</strong>, however, has not been fully tested as a part of development of<br />

this soluti<strong>on</strong> and there<str<strong>on</strong>g>for</str<strong>on</strong>g>e has not been detailed further.<br />

Introducti<strong>on</strong> <strong>to</strong> the Perl DBI Architecture<br />

There are several different modules<br />

available <str<strong>on</strong>g>for</str<strong>on</strong>g> use with Perl that extend the capabilities<br />

of the language. One of these modules, the Database Independent Interface (DBI),


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 225<br />

provides a comm<strong>on</strong> programming interface <str<strong>on</strong>g>for</str<strong>on</strong>g> several different proprietary databases,<br />

including <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong>. DBI offers a single set of functi<strong>on</strong>s or methods that can<br />

interact with the databases. These functi<strong>on</strong>s <str<strong>on</strong>g>for</str<strong>on</strong>g>m an abstracti<strong>on</strong> layer that allows the<br />

programmer <strong>to</strong> write code using generic DBI calls without needing specific API<br />

knowledge <str<strong>on</strong>g>for</str<strong>on</strong>g> the particular database. This layer makes the Perl code portable across<br />

databases.<br />

These generic DBI calls are then interpreted in<strong>to</strong> RDBMS-specific functi<strong>on</strong>s using<br />

specialized Database Driver (DBD) modules. A DBD is a database-specific driver that<br />

translates DBI calls <strong>to</strong> the target database. The DBI API <str<strong>on</strong>g>for</str<strong>on</strong>g>wards the call <strong>to</strong> the<br />

appropriate database driver module, which then provides support, such as the dynamic<br />

load ing of drivers, error-checking, and management. Figure 12.1 provides a visual<br />

representati<strong>on</strong> of path from a Perl script <strong>to</strong> the backend database using DBI-DBD.<br />

Figure 12.1<br />

Perl communicati<strong>on</strong> with databases using DBI API and DBD drivers<br />

DBI also supports the Open Database C<strong>on</strong>nectivity (ODBC) interface. While DBI itself is<br />

an abstracti<strong>on</strong> layer, ODBC <str<strong>on</strong>g>for</str<strong>on</strong>g>ms another additi<strong>on</strong>al abstracti<strong>on</strong> layer. This layer,<br />

c<strong>on</strong>sisting of an ODBC driver and ODBC driver manager mirrors the functi<strong>on</strong>s of the DBI<br />

and DBD within Perl. If the current soluti<strong>on</strong> utilizes ODBC, then a port using ODBC may<br />

provide the most direct soluti<strong>on</strong>. In other instances, ODBC may simply duplicate other<br />

laye rs and add additi<strong>on</strong>al processing overhead. In these situati<strong>on</strong>s, ODBC is not<br />

recommended. Figure 12.2 shows the path from Perl script <strong>to</strong> backend database<br />

involving ODBC drivers.<br />

Figure 12.2<br />

ODBC adds additi<strong>on</strong>al layers of c<strong>on</strong>nectivity between the applicati<strong>on</strong> and database<br />

Scenario 1: Interoperati<strong>on</strong> of Perl <strong>on</strong> <strong>UNIX</strong> with<br />

<strong>SQL</strong> <strong>Server</strong><br />

Interoperati<strong>on</strong> between a <strong>UNIX</strong>-based Perl applicati<strong>on</strong> and a <strong>SQL</strong> <strong>Server</strong> database is<br />

possible because of the availability of a driver that interfaces between these<br />

technologies. Because of the DBI API, this type of migrati<strong>on</strong> is usually a relatively simple<br />

process. Only minimal changes may need <strong>to</strong> be made <strong>to</strong> the Perl applicati<strong>on</strong>'s source


226 Developing: Applicati<strong>on</strong>s — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> Perl<br />

code.<br />

The cases described in this secti<strong>on</strong> discuss opti<strong>on</strong>s available <str<strong>on</strong>g>for</str<strong>on</strong>g> Perl applicati<strong>on</strong>s<br />

using ODBC or <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> drivers. The following cases assume that the Perl applicati<strong>on</strong><br />

currently uses either the ODBC DBD or the <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> DBD within the existing soluti<strong>on</strong>.<br />

Case 1: Interoperating an ODBC DBD Applicati<strong>on</strong><br />

If the original applicati<strong>on</strong> was written using ODBC DBD, then the best migrati<strong>on</strong> opti<strong>on</strong> is<br />

<strong>to</strong> c<strong>on</strong>tinu e <strong>to</strong> use this driver. Because ODBC is not database-specific, no changes<br />

should need <strong>to</strong> be made <strong>to</strong> the applicati<strong>on</strong>'s source code. The <strong>on</strong>ly changes that need <strong>to</strong><br />

be made c<strong>on</strong>cern c<strong>on</strong>nectivity with the <strong>SQL</strong> <strong>Server</strong> database.<br />

T o interoperate the Perl applicati<strong>on</strong> using ODBC, follow these comm<strong>on</strong> steps:<br />

1. Install the ODBC driver.<br />

The DBD::ODBC module requires a driver manager and a driver <strong>to</strong> interact with<br />

<strong>SQL</strong> <strong>Server</strong>. DBD::ODBC is packaged with the Independent ODBC (iODBC) driver<br />

manager from OpenLink Software (http://www.openlinksw.com/). For more<br />

in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> about this driver, refer <strong>to</strong><br />

http ://www.freetds.org/userguide/perl.htm#DBD.ODBC. Another driver manager,<br />

unixODBC, that could be used in an interoperati<strong>on</strong> scenario is available from<br />

http://www.freetds.org/user guide/prepodbc.htm.<br />

FreeTDS is a popular ODBC driver used <strong>to</strong> c<strong>on</strong>nect <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> from a <strong>UNIX</strong>-<br />

source implementati<strong>on</strong> of Tabular Data<br />

based applicati<strong>on</strong>. FreeTDS is an open<br />

Stream (TDS) pro<strong>to</strong>col that allows the applicati<strong>on</strong> native access <strong>to</strong> <strong>SQL</strong> <strong>Server</strong>.<br />

OpenLink also offers drivers <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>SQL</strong> <strong>Server</strong> that use the FreeTDS implementati<strong>on</strong><br />

of TDS. Detailed instructi<strong>on</strong>s <str<strong>on</strong>g>for</str<strong>on</strong>g> building and c<strong>on</strong>figuring this driver are available at<br />

http://www.freetds.org/userguide/perl.htm.<br />

For detailed steps <strong>on</strong> installing the unixODBC or FreeTDS drivers, see Appendix<br />

D: "Installing Comm<strong>on</strong> Drivers and Applicati<strong>on</strong>s." Even though the discussi<strong>on</strong> is<br />

related <strong>to</strong> installing FreeTDS in a Windows Services <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>UNIX</strong> envir<strong>on</strong>ment, it<br />

applies equally <strong>to</strong> <strong>UNIX</strong> as well.<br />

2. Create a <strong>SQL</strong> <strong>Server</strong> data source.<br />

To functi<strong>on</strong>, ODBC needs a data source <strong>to</strong> c<strong>on</strong>nect <strong>to</strong> the database. The Data<br />

Source Name (DSN) is generally defined in an odbc.ini file that is used by the<br />

driver manager. The DSN is used by the driver manager <strong>to</strong> load the ODBC driver.<br />

iODBC offers a graphical user interface <strong>to</strong> set up the DSN. Complete instructi<strong>on</strong>s<br />

are available from http://www.iodbc.org/index.php?page=docs/odbcs<strong>to</strong>ry.<br />

The DSN can also be c<strong>on</strong>figured by manually modifying the odbc.ini file. The<br />

following example file uses an <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> DSN.<br />

[ODBC Data Sources]<br />

ORA_HR_DB=Sample <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>8 dsn<br />

[ORA_HR_DB]<br />

Driver=/opt/odbc/lib/ivor8x01.so<br />

Descripti<strong>on</strong>=<str<strong>on</strong>g>Oracle</str<strong>on</strong>g>8<br />

<strong>Server</strong>Name=uxdbp1<br />

Log<strong>on</strong>ID=daveb<br />

Password=cougar<br />

This c<strong>on</strong>figurati<strong>on</strong> file can be modified <strong>to</strong> use the <strong>SQL</strong> <strong>Server</strong> DSN, as shown in<br />

the following example. Note that the [ORA_HR_DB] secti<strong>on</strong> is replaced with<br />

[SS_HR_DB]. Though most of the keys remain, the values are modified <strong>to</strong> allow <str<strong>on</strong>g>for</str<strong>on</strong>g><br />

the <strong>SQL</strong> <strong>Server</strong> data source.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 227<br />

[ODBC Data Sources]<br />

SS_HR_DB=Sample MS <strong>SQL</strong><strong>Server</strong><br />

[SS_HR_DB]<br />

Driver=/usr/local/freetds/lib/libtdsodbc.so<br />

Descripti<strong>on</strong>=<strong>SQL</strong> <strong>Server</strong> 2000<br />

Database=hrapp<br />

UID=daveb<br />

PWD=cougar<br />

Address=win2kdbp1,1433<br />

Note The isql command line utility can be used <strong>to</strong> check the validity of the DSN<br />

entry when using unixODBC. This allows you <strong>to</strong> ensure that the entries in the<br />

odbc.ini are correct. The syntax <str<strong>on</strong>g>for</str<strong>on</strong>g> use is:<br />

isql -v DSN username password<br />

3.<br />

Test the c<strong>on</strong>nectivity.<br />

iODBC c<strong>on</strong>tains a utility named odbctest which can be used <strong>to</strong> test the DSN<br />

entries and interact with the database by c<strong>on</strong>necting and issuing queries directly<br />

without any code. The syntax <str<strong>on</strong>g>for</str<strong>on</strong>g> per<str<strong>on</strong>g>for</str<strong>on</strong>g>ming this test is:<br />

odbctest "DSN=SS_HR_DB;UID=daveb;PWD=cougar"<br />

4. Change the existing applicati<strong>on</strong> <strong>to</strong> use <strong>SQL</strong> <strong>Server</strong> as data source.<br />

The following sample source Perl program from an <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> envir<strong>on</strong>ment c<strong>on</strong>tains<br />

functi<strong>on</strong>s <strong>to</strong> c<strong>on</strong>nect, prepare, execute, bind, and disc<strong>on</strong>nect. Compare these<br />

functi<strong>on</strong>s with the Perl code in the following example. Minor adjustments are made<br />

<strong>to</strong> allow <str<strong>on</strong>g>for</str<strong>on</strong>g> the data source change.<br />

#Load the DBI module<br />

use DBI;<br />

my $c<strong>on</strong>nectstring_oracle = 'ora_hr_db';<br />

my $username = 'daveb';<br />

my $password = 'cougar';<br />

my $tablename = 'Employee_Info';<br />

#C<strong>on</strong>necting <strong>to</strong> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> DB using ODBC<br />

my $dbh = DBI->c<strong>on</strong>nect(" dbi:ODBC:$c<strong>on</strong>nectstring_oracle", "$username",<br />

"$password");<br />

#Preparing the <strong>SQL</strong> statement<br />

$sth = $dbh->prepare("insert in<strong>to</strong> $tablename (last_name) values (?)");<br />

#Binding the value <strong>to</strong> the parameter at run time.<br />

$sth->bind_param( 1,"LName);<br />

#Executing the query<br />

$sth->execute() or warn $sth->errstr(); # check <str<strong>on</strong>g>for</str<strong>on</strong>g> error<br />

$sth->finish();


228 Developing: Applicati<strong>on</strong>s — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> Perl<br />

#Disc<strong>on</strong>nect from <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> database<br />

$dbh->disc<strong>on</strong>nect or warn "Can't disc<strong>on</strong>nect from the <str<strong>on</strong>g>Oracle</str<strong>on</strong>g><br />

$c<strong>on</strong>nectstring_oracle database: $DBI::errstr\n";<br />

The same functi<strong>on</strong>s are modified <strong>to</strong> use a <strong>SQL</strong> <strong>Server</strong> data source in the following<br />

example:<br />

my $c<strong>on</strong>nectstring_oracle = 'ora_hr_db';<br />

my $username = 'daveb';<br />

my $password = 'cougar';<br />

my $tablename = 'Employee_Info';<br />

#C<strong>on</strong>necting <strong>to</strong> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> DB using ODBC<br />

my $dbh = DBI->c<strong>on</strong>nect("dbi:ODBC:$c<strong>on</strong>nectstring_oracle", "$username",<br />

"$password")<br />

<strong>to</strong><br />

my $c<strong>on</strong>nectstring_ss = 'ss_hr_db';<br />

my $username = 'daveb';<br />

my $password = 'cougar';<br />

my $tablename = 'Employee_Info';<br />

#C<strong>on</strong>necting <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> DB using ODBC<br />

my $dbh = DBI->c<strong>on</strong>nect("dbi:ODBC:$c<strong>on</strong>nectstring_ss", "$username", "$password")<br />

5. Change all embedded <strong>SQL</strong> statements <strong>to</strong> T-<strong>SQL</strong>.<br />

This is a step comm<strong>on</strong> <strong>to</strong> all migrati<strong>on</strong>s. Refer <strong>to</strong> Chapter 11, "Developing:<br />

Applicati<strong>on</strong>s — <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>SQL</strong> and PL/<strong>SQL</strong>," <str<strong>on</strong>g>for</str<strong>on</strong>g> a detailed discussi<strong>on</strong> <strong>on</strong> modifying<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>SQL</strong> <strong>to</strong> be <strong>SQL</strong> <strong>Server</strong>-compliant.<br />

Case 2: Interoperating an <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> DBD Applicati<strong>on</strong><br />

If the original applicati<strong>on</strong> was written using the <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> DBD, there are two possible<br />

opti<strong>on</strong>s that can be evaluated. The recommended opti<strong>on</strong> is <strong>to</strong> replace the <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> DBD<br />

with a Sybase DBD. The sec<strong>on</strong>d opti<strong>on</strong> is <strong>to</strong> migrate <strong>to</strong> an ODBC framework similar <strong>to</strong><br />

the <strong>on</strong>e seen in "Case 1: Interoperating an ODBC DBD Applicati<strong>on</strong>." Sybase DBD offers<br />

better per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance than ODBC.<br />

Migrate <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> Using Sybase DBD<br />

Becau se <strong>SQL</strong> <strong>Server</strong> was originally based <strong>on</strong> the Sybase data structure, it is possible <strong>to</strong><br />

use the Sybase DBD <strong>to</strong> c<strong>on</strong>nect <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> using a <strong>SQL</strong> <strong>Server</strong> driver.<br />

To use the Sybase DBD <strong>to</strong> c<strong>on</strong>nect <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> using a <strong>SQL</strong> <strong>Server</strong> driver,<br />

follow these steps:<br />

1. Install <strong>SQL</strong> <strong>Server</strong> library support.<br />

The FreeTDS driver is needed <str<strong>on</strong>g>for</str<strong>on</strong>g> this method. Instructi<strong>on</strong>s <str<strong>on</strong>g>for</str<strong>on</strong>g> installing and<br />

c<strong>on</strong>figuring the driver are located in Appendix D, "Installing Comm<strong>on</strong> Drivers and<br />

Applicati<strong>on</strong>s." Even though the discussi<strong>on</strong> is related <strong>to</strong> installing FreeTDS in a<br />

Windows Services <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>UNIX</strong> envir<strong>on</strong>ment, it applies equally <strong>to</strong> <strong>UNIX</strong> as well.<br />

Because the driver is not being used with ODBC, the -disable-odbc switch can be<br />

used with the c<strong>on</strong>figure command while installing FreeTDS. Details <strong>on</strong> the use of<br />

this command are availa ble at http://www.freetds.org/userguide/c<strong>on</strong>fig.htm.<br />

2. C<strong>on</strong>figure the data source.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 229<br />

After FreeTDS is installed, the freetds.c<strong>on</strong>f file should be modified <strong>to</strong> include the<br />

<strong>SQL</strong> <strong>Server</strong> database in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong>. A sample entry is shown in the following<br />

example:<br />

[SS_HR_DB]<br />

host = win2kdbp1 # or IP address<br />

port = 1433<br />

tds versi<strong>on</strong> = 8.0<br />

3. Install the Sybase DBD module.<br />

For more in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <strong>on</strong> installing this Perl module, refer <strong>to</strong><br />

http://search.cpan.org/~mewp/DBD-Sybase/Sybase.pm.<br />

In additi<strong>on</strong>, the SYBASE envir<strong>on</strong>ment variable should be set <strong>to</strong> the locati<strong>on</strong> of the<br />

FreeTDS installati<strong>on</strong>. If using bash or ksh, the following commands can be used:<br />

4.<br />

export SYBASE=/usr/local/freetds<br />

Modify the applicati<strong>on</strong>'s source code.<br />

Minor changes will need <strong>to</strong> be made <strong>to</strong> the source code <strong>to</strong> allow <str<strong>on</strong>g>for</str<strong>on</strong>g> the data<br />

source change. The following sample code shows some different implementati<strong>on</strong><br />

opti<strong>on</strong>s of the Perl language that may appear in your existing source code.<br />

Compare these <strong>to</strong> the sec<strong>on</strong>d code sample that has been modified <strong>to</strong> use the<br />

Sybase DBD.<br />

# load the DBI module<br />

use DBI;<br />

# C<strong>on</strong>nect <strong>to</strong> the <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Database<br />

my $dbh = DBI->c<strong>on</strong>nect("dbi:<str<strong>on</strong>g>Oracle</str<strong>on</strong>g>: ora_hr_db ",<br />

'userName',<br />

'password',<br />

{<br />

RaiseError = > 1,<br />

Au<strong>to</strong>Commit => 0<br />

}<br />

) || die "Database c<strong>on</strong>necti<strong>on</strong> not made: $DBI::errstr";<br />

#Prepare a <strong>SQL</strong> statement<br />

my $sql = qq{ SELECT id, name, title,<br />

my $sth = $dbh->prepare( $sql );<br />

ph<strong>on</strong>e FROM employees };<br />

#Execute the statement<br />

$sth->execute();<br />

my( $id, $name, $title, $ph<strong>on</strong>e );<br />

# Bind the results <strong>to</strong> the local variables<br />

$sth->bind_columns( undef, \$id, \$name, \$title, \$ph<strong>on</strong>e );<br />

#Retrieve values from the result set<br />

while( $sth->fetch() ) {<br />

print "$name, $title, $ph<strong>on</strong>e\n";<br />

}


230 Developing: Applicati<strong>on</strong>s — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> Perl<br />

#Close the c<strong>on</strong>necti<strong>on</strong><br />

$sth->finish();<br />

$dbh->disc<strong>on</strong>nect();<br />

5. Change the c<strong>on</strong>necti<strong>on</strong> <strong>to</strong> the Sybase DBI and <strong>SQL</strong> <strong>Server</strong> DSN.<br />

The script in Step 4 has been rewritten <strong>to</strong> use DBD::Sybase. Note that the changes<br />

have been made in the header <str<strong>on</strong>g>for</str<strong>on</strong>g> the DBD and in the c<strong>on</strong>necti<strong>on</strong> string <str<strong>on</strong>g>for</str<strong>on</strong>g><br />

<strong>SQL</strong> <strong>Server</strong>. The rest of the Perl code is un<strong>to</strong>uched by this change. This modified<br />

code is shown in the following example.<br />

# load the DBI module<br />

use DBI;<br />

use DBD::Sybase;<br />

BEGIN<br />

{<br />

$ENV{SYBASE} = "/usr/local";<br />

}<br />

# C<strong>on</strong>nect <strong>to</strong> the <strong>SQL</strong> <strong>Server</strong> Database<br />

my $dbh = DBI->c<strong>on</strong>nect( “dbi:Sybase:server=ss_hr_db;database=hrapp”,<br />

'userName',<br />

'password',<br />

{<br />

RaiseError => 1,<br />

Au<strong>to</strong>Commit = > 0<br />

}<br />

) || die "Database c<strong>on</strong>necti<strong>on</strong> not made: $DBI::errstr";<br />

#Prepare a <strong>SQL</strong> statement<br />

my $sql = qq{ SELECT id, name, title, ph<strong>on</strong>e FROM employees };<br />

my $sth = $dbh->prepare( $sql );<br />

#Execute the statement<br />

$sth->execute();<br />

my( $id, $name, $title, $ph<strong>on</strong>e );<br />

# Bind the results <strong>to</strong> the local variables<br />

$sth->bind_columns( undef, \$id, \$name, \$title, \$ph<strong>on</strong>e );<br />

#Retrieve values from the result set<br />

while( $sth->fetch() ) {<br />

print "$name, $title, $ph<strong>on</strong>e\n";<br />

}<br />

#Close the c<strong>on</strong>necti<strong>on</strong><br />

$sth->finish();<br />

$dbh->disc<strong>on</strong>nect();


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 231<br />

6.<br />

Change all embedded <strong>SQL</strong> statements <strong>to</strong> T-<strong>SQL</strong>.<br />

Refer <strong>to</strong> Chapter 11, "Developing: Applicati<strong>on</strong>s — <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>SQL</strong> and PL/<strong>SQL</strong>," <str<strong>on</strong>g>for</str<strong>on</strong>g> a<br />

detailed discussi<strong>on</strong> <strong>on</strong> modifying <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>SQL</strong> <strong>to</strong> be <strong>SQL</strong> <strong>Server</strong>-compliant.<br />

Migrate <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> Using ODBC<br />

To migrate an <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> DBD c<strong>on</strong>necti<strong>on</strong> <strong>to</strong> ODBC, follow these steps:<br />

1. Install the ODBC driver.<br />

FreeTDS should be installed. For more in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> see Appendix D, "Installing<br />

Comm<strong>on</strong> Drivers and Applicati<strong>on</strong>s." Even though the discussi<strong>on</strong> is related <strong>to</strong><br />

installing FreeTDS in a Windows Services <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>UNIX</strong> envir<strong>on</strong>ment, it applies equally<br />

<strong>to</strong> <strong>UNIX</strong> as well.<br />

2. C<strong>on</strong>figure the DSN settings.<br />

The steps <str<strong>on</strong>g>for</str<strong>on</strong>g> creating an ODBC DSN have been shown in "Case 1: Interoperating<br />

an ODBC DBD Applicati<strong>on</strong>."<br />

3. Install the ODBC DBD module.<br />

Installati<strong>on</strong> instructi<strong>on</strong>s are available at http://search.cpan.org/dis t/perl/INSTALL<br />

and http://www.easysoft.com/products/2002/perl_dbi_dbd_odbc.phtml#3_0<br />

In additi<strong>on</strong>, the following envir<strong>on</strong>ment variables need <strong>to</strong> be set:<br />

● ODBCHOME. The direc<strong>to</strong>ry where ODBC driver manager is installed.<br />

● DBI_DSN. The dbi data source.<br />

● DBI_USER. The username <strong>to</strong> c<strong>on</strong>nect <strong>to</strong> the database.<br />

● DBI_PASS. The password <str<strong>on</strong>g>for</str<strong>on</strong>g> the database username.<br />

4. Modify the source code.<br />

The original script written <str<strong>on</strong>g>for</str<strong>on</strong>g> use with DBD::<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> has <strong>to</strong> be changed <strong>to</strong> c<strong>on</strong>nect<br />

<strong>to</strong> <strong>SQL</strong> <strong>Server</strong> through the ODBC DSN. Changes are limited <strong>to</strong> the c<strong>on</strong>nect()<br />

method as shown in the following code.<br />

# load the DBI module<br />

use DBI;<br />

# C<strong>on</strong>nect <strong>to</strong> the <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Database<br />

my $dbh = DBI->c<strong>on</strong>nect("dbi:ODBC:ss_hr_db",<br />

'userName',<br />

'password',<br />

{<br />

RaiseError => 1,<br />

Au<strong>to</strong>Commit => 0<br />

}<br />

) || die "Database c<strong>on</strong>necti<strong>on</strong> not made: $DBI::errstr";<br />

#Prepare a <strong>SQL</strong> statement<br />

my $sql = qq{ SELECT id, name, title, ph<strong>on</strong>e FROM employees };<br />

my $sth = $dbh->prepare( $sql );<br />

#Execute the statement<br />

$sth->execute();<br />

my( $id, $name, $title, $ph<strong>on</strong>e );


232 Developing: Applicati<strong>on</strong>s — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> Perl<br />

# Bind the results <strong>to</strong> the local variables<br />

$sth->bind_columns( undef, \$id, \$name, \$title, \$ph<strong>on</strong>e );<br />

#Retrieve values from the result set<br />

while( $sth->fetch() ) {<br />

print "$name, $title, $ph<strong>on</strong>e\n";<br />

}<br />

#Close the c<strong>on</strong>necti<strong>on</strong><br />

$sth->finish();<br />

$dbh->disc<strong>on</strong>nect();<br />

Note ODBC c<strong>on</strong>necti<strong>on</strong>s can also be made without using DSN sources. The<br />

difference from a DSN is that the required c<strong>on</strong>figurati<strong>on</strong> in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> is embedded<br />

in the Perl code instead of residing in a separate initializati<strong>on</strong> file. The following<br />

example shows a n<strong>on</strong>-DSN c<strong>on</strong>necti<strong>on</strong>:<br />

my $dsn = 'DBI:ODBC:Driver={<strong>SQL</strong> <strong>Server</strong>}';<br />

my $host = 'hostname';<br />

my $database = 'dbname';<br />

my $user = 'username';<br />

my $auth = 'password';<br />

my($dbh) = DBI->c<strong>on</strong>nect("$dsn;$host;$database",$user,$auth,<br />

{ RaiseError => 1, Au<strong>to</strong>Commit => 1});<br />

5. Change all embedded <strong>SQL</strong> statements <strong>to</strong> T-<strong>SQL</strong>.<br />

Refer <strong>to</strong> chapter 11, "Developing: Applicati<strong>on</strong>s — <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>SQL</strong> and PL/<strong>SQL</strong>," <str<strong>on</strong>g>for</str<strong>on</strong>g> a<br />

detailed discussi<strong>on</strong> <strong>on</strong> modifying <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>SQL</strong> <strong>to</strong> be <strong>SQL</strong> <strong>Server</strong>-compliant.<br />

Scenario 2: Porting the Perl Applicati<strong>on</strong> <strong>to</strong> Windows<br />

The migrati<strong>on</strong> of Perl applicati<strong>on</strong>s in a <strong>UNIX</strong> envir<strong>on</strong>ment <strong>to</strong> Windows and moving the<br />

backend <strong>to</strong> a <strong>SQL</strong> <strong>Server</strong> database is not much more ef<str<strong>on</strong>g>for</str<strong>on</strong>g>t than that needed under the<br />

interoperati<strong>on</strong> scenario. It is possible <strong>to</strong> port the Perl applicati<strong>on</strong> <strong>to</strong> both the .NET and the<br />

Win32 envir<strong>on</strong>ment. The port <strong>to</strong> .NET is made possible by the availability of the utility<br />

PerlNET, which can wrap Perl programs in<strong>to</strong> a .NET comp<strong>on</strong>ent. However, the<br />

app licati<strong>on</strong> has <strong>to</strong> be ported from the <strong>UNIX</strong> envir<strong>on</strong>ment <strong>to</strong> Windows envir<strong>on</strong>ment be<str<strong>on</strong>g>for</str<strong>on</strong>g>e<br />

the c<strong>on</strong>versi<strong>on</strong> <strong>to</strong> .NET can be per<str<strong>on</strong>g>for</str<strong>on</strong>g>med. Details about PerlNET are available at<br />

http://aspn.activestate.com/ASPN/docs/PDK/6.0/PerlNET.html#perlnet_<strong>to</strong>p.<br />

There are a few additi<strong>on</strong>al steps that should be followed <strong>to</strong> successfully move the Perl<br />

applicati<strong>on</strong> <strong>to</strong> Win32. These steps are discussed in the following two cases.<br />

Case 1: Porting a Perl Applicati<strong>on</strong> using ODBC DBD<br />

To port the Perl applicati<strong>on</strong> <strong>to</strong> the Windows envir<strong>on</strong>ment, follow these steps:<br />

1. Install Perl in the target Windows envir<strong>on</strong>ment.<br />

ActiveState Perl is available from http://www.activestate.com. For more in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong><br />

<strong>on</strong> installing ActivePerl, see Appendix D, "Installing Comm<strong>on</strong> Drivers and<br />

Applicati<strong>on</strong>s."<br />

2. Install DBI and DBD::ODBC.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 233<br />

The DBI and DBD::ODBC modules can be installed using Perl Package Manager<br />

(PPM), which is installed with ActivePerl. PPM is an interactive command line utility<br />

which can be launched from the command line by typing ppm.<br />

Download the DBI and DBD::ODBC files <strong>to</strong> a local direc<strong>to</strong>ry—<str<strong>on</strong>g>for</str<strong>on</strong>g> example,<br />

c:\perlppd. These files can be downloaded from<br />

http://ppm.activestate.co m/PPMPackages/zips/ .<br />

The modules can be installed by typing the following commands:<br />

PPM> rep add new c:\perlppd<br />

PPM> install DBI<br />

PPM> install DBD-ODBC<br />

PPM> quit<br />

3. Install the ODBC driver.<br />

There are several available opti<strong>on</strong>s <str<strong>on</strong>g>for</str<strong>on</strong>g> acquiring and installing an ODBC driver <str<strong>on</strong>g>for</str<strong>on</strong>g><br />

<strong>SQL</strong> <strong>Server</strong>. These opti<strong>on</strong>s include:<br />

● An ODBC driver <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>SQL</strong> <strong>Server</strong> is included as part of the <strong>SQL</strong> <strong>Server</strong><br />

distributi<strong>on</strong> CD and is installed as part of the <strong>SQL</strong> <strong>Server</strong> client install. Refer <strong>to</strong><br />

http://msdn.microsoft.com/library/default.asp?url=/library/en-<br />

us/how<strong>to</strong>sql/ht_install_029l.asp <str<strong>on</strong>g>for</str<strong>on</strong>g> in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <strong>on</strong> installing the <strong>SQL</strong> <strong>Server</strong><br />

client.<br />

● OpenLink software offers an ODBC soluti<strong>on</strong> that eliminates the need <strong>to</strong> install<br />

<strong>SQL</strong> <strong>Server</strong> client software <strong>on</strong> the server <strong>on</strong> which the Perl applicati<strong>on</strong> will run.<br />

Details <strong>on</strong> this driver are available at http://uda.openlinksw.com/odbc/st/odbc-<br />

sqlserver-st/.<br />

● DataDirect offers C<strong>on</strong>nect <str<strong>on</strong>g>for</str<strong>on</strong>g> ODBC drivers that also provide clientless access<br />

<strong>to</strong> <strong>SQL</strong> <strong>Server</strong>. Details are available at<br />

http://www.datadirect.com/products/odbc/index.ssp.<br />

4.<br />

C<strong>on</strong>figure the ODBC data source.<br />

An ODBC data source can be c<strong>on</strong>figured by modifying odbc.ini as shown in the<br />

"Case 1: Interoperating an ODBC DBD Applicati<strong>on</strong>" secti<strong>on</strong> of Scenario 1. The<br />

data source can also be c<strong>on</strong>figured using the ODBC Data Source Administra<strong>to</strong>r<br />

utility that is bundled with Windows. This utility can be accessed by accessing from<br />

the C<strong>on</strong>trol Panel by choosing Administrative Tools, then Data Sources<br />

(ODBC). Some<br />

database vendors also provide utilities <strong>to</strong> c<strong>on</strong>figure DSNs.


234 Developing: Applicati<strong>on</strong>s — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> Perl<br />

Figure 12.3<br />

C<strong>on</strong>figuring the ODBC System DSN<br />

Note In Windows, DSNs should be created as a System DSN and not as a User<br />

DSN because of permissi<strong>on</strong>s restricti<strong>on</strong>s associated with the latter.<br />

Further steps <str<strong>on</strong>g>for</str<strong>on</strong>g> creating a data source are available at<br />

http://msdn.microsoft.com/library/default.asp?url=/library/enus/how<strong>to</strong>sql/ht_6_odbcht_1oqc.asp.<br />

5. Change the applicati<strong>on</strong> <strong>to</strong> use <strong>SQL</strong> <strong>Server</strong> as the data source.<br />

The move <strong>to</strong> Windows does not add any overhead in terms of modificati<strong>on</strong>s <strong>to</strong> the<br />

applicati<strong>on</strong>. The changes are driven by the change in DSN and are similar <strong>to</strong><br />

changes discussed in the "Case 1: Interoperating an ODBC DBD Applicati<strong>on</strong>"<br />

secti<strong>on</strong> of Scenario 1.<br />

6. Change all embedded <strong>SQL</strong> statements <strong>to</strong> T-<strong>SQL</strong>.<br />

This is a step comm<strong>on</strong> <strong>to</strong> all migrati<strong>on</strong>s. Refer <strong>to</strong> Chapter 11, "Developing:<br />

Applicati<strong>on</strong>s — <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>SQL</strong> and PL/<strong>SQL</strong>," <str<strong>on</strong>g>for</str<strong>on</strong>g> a detailed discussi<strong>on</strong> <strong>on</strong> modifying<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>SQL</strong> <strong>to</strong> be <strong>SQL</strong> <strong>Server</strong>-compliant.<br />

Case 2: Porting a Perl Applicati<strong>on</strong> Using <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> DBD<br />

When migrating from a <strong>UNIX</strong> plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m <strong>to</strong> a Windows plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m, there are two opti<strong>on</strong>s <strong>to</strong><br />

replace the DBD::<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> module. One opti<strong>on</strong> is <strong>to</strong> use the DBD::ODBC module. The<br />

other is <strong>to</strong> use ActiveX Data Objects (ADO) through the DBD::ADO module.<br />

Using DBD::ODBC is recommended in most instances and is discussed in greater detail<br />

in the "Case 1: Interoperating an ODBC DBD Applicati<strong>on</strong>" secti<strong>on</strong> of Scenario 1.<br />

DBD::ADO is a DBI driver that acts as an interface <strong>to</strong> other lower-level database drivers


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 235<br />

within Windows. DBD::ADO requires the DBD::ODBC module <strong>to</strong> functi<strong>on</strong>. Using<br />

DBD::ADO will add an additi<strong>on</strong>al c<strong>on</strong>nectivity layer <strong>to</strong> the soluti<strong>on</strong> and should <strong>on</strong>ly be<br />

implemented if the applicati<strong>on</strong> needs <strong>to</strong> take advantage of the OLE DB APIs. This driver<br />

can then be used <strong>to</strong> c<strong>on</strong>nect <strong>to</strong> and access data from any ADO data source.<br />

Migrate <strong>to</strong> DBD::ADO<br />

To migrate <strong>to</strong> DBD::ADO, follow these steps:<br />

1. Install ActivePerl.<br />

ActivePerl is a Windows-based Perl engine available from<br />

http://www.a ctivestate.com. For detailed installati<strong>on</strong> instructi<strong>on</strong>s, see Appendix D,<br />

"Installing Comm<strong>on</strong> Drivers and Applicati<strong>on</strong>s."<br />

2. Install DBI.<br />

The DBI module can be installed using Perl Package Manager (PPM), which is<br />

installed with ActivePerl.<br />

3. Install DBD::ODBC using PPM.<br />

4. Install the ODBC driver.<br />

5. C<strong>on</strong>figure the ODBC data source.<br />

6. Install ADO.<br />

The DBD::ADO module requires Microsoft ADO versi<strong>on</strong> 2.1 or later <strong>to</strong> work<br />

reliably. ADO drivers are available from Microsoft as part of the Microsoft Data<br />

Access Comp<strong>on</strong>ent (MDAC) available at<br />

http://msdn.microsoft.com/data/technologyinfo/mdac.<br />

Download the DBD::ADO module files <strong>to</strong> a local direc<strong>to</strong>ry—<str<strong>on</strong>g>for</str<strong>on</strong>g> example, c:\perlppd.<br />

The ADO module can be downloaded from<br />

http://ppm.activestate.com/PPMPackages/zips/.<br />

This module can be installed from Perl Package Manager (PPM).<br />

Type ppm at the command line <strong>to</strong> start the package manager, and then type the<br />

following commands:<br />

PPM. Rep add new c:\perlppd<br />

PPM> install DBI<br />

PPM> install DBD-ADO<br />

PPM> quit<br />

7. Modify the c<strong>on</strong>necti<strong>on</strong> string <strong>to</strong> use ADO. No other changes should need <strong>to</strong> be<br />

made <strong>to</strong> the source code. A sample ADO c<strong>on</strong>necti<strong>on</strong> string is shown in the<br />

following example:<br />

use DBI;<br />

my $dsn ="Provider=sqloledb;Trusted_C<strong>on</strong>necti<strong>on</strong>=Yes;<strong>Server</strong>=<br />

win2kdbp1;Database=hrapps";<br />

$dbh = DBI->c<strong>on</strong>nect("dbi:ADO:$dsn", $user, $passwd);<br />

Calling s<strong>to</strong>red procedures is supported by DBD::ADO using the ODBC style call<br />

procedure_name(). An example <str<strong>on</strong>g>for</str<strong>on</strong>g> calling a procedure is<br />

my $sth = $dbh->prepare("{call procedure name (?)}");<br />

Parameters can be either input or output parameters. Parameters are bound as<br />

seen in earlier examples.<br />

8. Change all embedded <strong>SQL</strong> statements <strong>to</strong> T-<strong>SQL</strong>.<br />

This is a step comm<strong>on</strong> <strong>to</strong> all migrati<strong>on</strong>s. Refer <strong>to</strong> Chapter 11, "Developing:<br />

Applicati<strong>on</strong>s — <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>SQL</strong> and PL/<strong>SQL</strong>," <str<strong>on</strong>g>for</str<strong>on</strong>g> a detailed discussi<strong>on</strong> <strong>on</strong> modifying<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>SQL</strong> <strong>to</strong> be <strong>SQL</strong> <strong>Server</strong>-compliant.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 237<br />

13<br />

Developing: Applicati<strong>on</strong>s —<br />

<str<strong>on</strong>g>Migrating</str<strong>on</strong>g> PHP<br />

Introducti<strong>on</strong> and Goals<br />

This chapter explores the opti<strong>on</strong>s available <strong>to</strong> maintain c<strong>on</strong>nectivity of PHP: Hypertext<br />

Preprocessor (PHP) applicati<strong>on</strong>s as part of the <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>to</strong> Microsoft® <strong>SQL</strong> <strong>Server</strong><br />

migrati<strong>on</strong> project. In PHP, the logic <strong>to</strong> interact with databases is provided by database-<br />

functi<strong>on</strong>s <strong>to</strong> per<str<strong>on</strong>g>for</str<strong>on</strong>g>m<br />

specific modules (or drivers). These modules have specialized<br />

database-related tasks and can be replaced <strong>to</strong> accommodate a <strong>SQL</strong> <strong>Server</strong> backend with<br />

relative ease.<br />

PHP is an open source, server-side, cross-plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m scripting language used <strong>to</strong> create<br />

dynamic Web pages. Like any other Comm<strong>on</strong> Gateway Interface (CGI), PHP can provide<br />

dynamic, data-driven characteristics <strong>to</strong> static HTML <str<strong>on</strong>g>for</str<strong>on</strong>g>ms or pages.<br />

As discussed in Chapter 2, "Envisi<strong>on</strong>ing Phase," there are four different strategies<br />

available <str<strong>on</strong>g>for</str<strong>on</strong>g> transiti<strong>on</strong>ing applicati<strong>on</strong>s in an <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> migrati<strong>on</strong> project. The<br />

strategies are:<br />

● Interoperate the applicati<strong>on</strong> with the <strong>UNIX</strong> envir<strong>on</strong>ment.<br />

● Port or rewrite the applicati<strong>on</strong> <strong>to</strong> the Microsoft .NET plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m.<br />

● Port or rewrite the applicati<strong>on</strong> <strong>to</strong> the Microsoft Win32® plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m.<br />

● Quick port using the Microsoft Windows® Services <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>UNIX</strong> 3.5 plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m.<br />

Because of the unique characteristics of PHP, some of<br />

than others.<br />

these strategies are more feasible<br />

For example, because PHP can be ported <strong>to</strong> Windows, there is no need <strong>to</strong> rewrite the<br />

applicati<strong>on</strong> <str<strong>on</strong>g>for</str<strong>on</strong>g> .NET or Win32 unless the existing soluti<strong>on</strong>'s source code is not available.<br />

Because the available drivers <str<strong>on</strong>g>for</str<strong>on</strong>g> .NET are still in beta, the porting has <strong>to</strong> be d<strong>on</strong>e <strong>to</strong> a<br />

Win32 envir<strong>on</strong>ment, Also, because the applicati<strong>on</strong> can run within the Windows<br />

envir<strong>on</strong>ment, a quick port using Windows Services <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>UNIX</strong> is not necessary in most<br />

cases.<br />

Bas ed <strong>on</strong> the available migrati<strong>on</strong> strategies, two scenarios can be developed <strong>to</strong> migrate<br />

PHP applicati<strong>on</strong>s. These scenarios include:<br />

● Scenario 1: Interoperating PHP <strong>on</strong> <strong>UNIX</strong> with <strong>SQL</strong> <strong>Server</strong><br />

If the business requirements<br />

do not include eliminating the <strong>UNIX</strong> envir<strong>on</strong>ment, an<br />

interoperati<strong>on</strong> strategy can be implemented quickly. Few changes need <strong>to</strong> be


238 Developing: Applicati<strong>on</strong>s — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> PHP<br />

●<br />

made <strong>to</strong> the source code and installing a new driver allows the PHP applicati<strong>on</strong> <strong>to</strong><br />

c<strong>on</strong>nect <strong>to</strong> a <strong>SQL</strong> <strong>Server</strong> database. If the migrati<strong>on</strong> is per<str<strong>on</strong>g>for</str<strong>on</strong>g>med in phases,<br />

interoperati<strong>on</strong> can be used as an interim step.<br />

Scenario 2: Porting the Applicati<strong>on</strong> <strong>to</strong> Win32<br />

PHP applicati<strong>on</strong>s can also be ported <strong>to</strong> run natively <strong>on</strong> the Windows plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m. As<br />

with interoperati<strong>on</strong>, few changes need <strong>to</strong> be made <strong>to</strong> the source code.<br />

Available opti<strong>on</strong>s are discussed <str<strong>on</strong>g>for</str<strong>on</strong>g> each scenario in separate cases. Each case lists<br />

steps required <strong>to</strong> c<strong>on</strong>nect the PHP applicati<strong>on</strong> <strong>to</strong> the <strong>SQL</strong> <strong>Server</strong> data source. Also<br />

included are discussi<strong>on</strong>s <strong>on</strong> the differences between the various <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong><br />

functi<strong>on</strong>s. When applicable, sample source code is provided <strong>to</strong> illustrate changes that<br />

need <strong>to</strong> be made.<br />

Note If your PHP scripts use <strong>UNIX</strong> system calls extensively (such as frequent use of<br />

exec, passthru, popen, or the backtick (`)), porting them <strong>to</strong> Windows Services <str<strong>on</strong>g>for</str<strong>on</strong>g><br />

<strong>UNIX</strong>/Interix may be a suitable opti<strong>on</strong> because Interix has more support <str<strong>on</strong>g>for</str<strong>on</strong>g> the desired<br />

system calls. Chapter 2, "Envisi<strong>on</strong>ing Phase," provides a more detailed discussi<strong>on</strong> of<br />

when choosing Windows Services <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>UNIX</strong> would be more appropriate when moving<br />

<strong>to</strong> a Windows-based plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m.<br />

You will need the following <strong>to</strong> implement this opti<strong>on</strong> (porting PHP applicati<strong>on</strong>s <strong>to</strong><br />

Windows Services <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>UNIX</strong>/<strong>SQL</strong> <strong>Server</strong>):<br />

● A port of PHP <str<strong>on</strong>g>for</str<strong>on</strong>g> Interix downloadable from Interop Systems at<br />

http://www.interopsystems.com/<strong>to</strong>ols/warehouse.htm, which includes the capability<br />

of using DBLib, CTLib and ODBC. The PHP distributi<strong>on</strong> will have <strong>to</strong> be compiled<br />

<str<strong>on</strong>g>for</str<strong>on</strong>g> using a specific database c<strong>on</strong>nectivity library.<br />

● A c<strong>on</strong>nectivity driver <strong>to</strong> the <strong>SQL</strong> <strong>Server</strong> database. This is provided by the port of<br />

FreeTDS <strong>on</strong> Interix and is downloadable from Interop Systems at<br />

http://www.interopsystems.com/<strong>to</strong>ols/db.htm. FreeTDS provides three c<strong>on</strong>nectivity<br />

opti<strong>on</strong>s <str<strong>on</strong>g>for</str<strong>on</strong>g> the PHP applicati<strong>on</strong> <strong>to</strong> c<strong>on</strong>nect <strong>to</strong> the <strong>SQL</strong> <strong>Server</strong> database. Two<br />

opti<strong>on</strong>s go through the libraries DBLib and CTLib, which provide c<strong>on</strong>nectivity <strong>to</strong><br />

both Sybase and <strong>SQL</strong> <strong>Server</strong>. The third is the ODBC driver, which can be used <strong>to</strong><br />

access any ODBC database (including <strong>SQL</strong> <strong>Server</strong>).<br />

This technology opti<strong>on</strong>, however, has not been fully tested as a part of development of<br />

this soluti<strong>on</strong> and there<str<strong>on</strong>g>for</str<strong>on</strong>g>e has not been detailed further.<br />

PHP Modules<br />

PHP c<strong>on</strong>tains a rich set of opti<strong>on</strong>s <str<strong>on</strong>g>for</str<strong>on</strong>g> interfacing with comm<strong>on</strong> proprietary databases,<br />

including <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong>. These interfaces are available through PHP as internal<br />

functi<strong>on</strong>s or extensi<strong>on</strong>s. The database-related functi<strong>on</strong>s are grouped in<strong>to</strong> modules which


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 239<br />

must be compiled in<strong>to</strong> the PHP installati<strong>on</strong> be<str<strong>on</strong>g>for</str<strong>on</strong>g>e use. These modules are enabled by<br />

specifying them in the c<strong>on</strong>figurati<strong>on</strong> file (php.ini).<br />

Figure 13.1<br />

PHP modules (functi<strong>on</strong>s) that can access <str<strong>on</strong>g>Oracle</str<strong>on</strong>g><br />

Figure 13.2<br />

PHP modules (functi<strong>on</strong>s) that can access <strong>SQL</strong> <strong>Server</strong><br />

The following modules are comm<strong>on</strong>ly used with <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> databases. Each is discussed in<br />

detail in this chapter:<br />

● <str<strong>on</strong>g>Oracle</str<strong>on</strong>g><br />

(ORA) functi<strong>on</strong>s<br />

ORA is a set of functi<strong>on</strong>s used <strong>to</strong> access <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> databases.<br />

The php_oracle value in the php.ini file (extensi<strong>on</strong>=php_oracle.dll) is used <strong>to</strong><br />

enable functi<strong>on</strong>s. The functi<strong>on</strong>s in this module can be identified by the ora_ prefix,<br />

such as ora_log<strong>on</strong>().<br />

● <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> 8 (OCI8) functi<strong>on</strong>s


240 Developing: Applicati<strong>on</strong>s — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> PHP<br />

●<br />

OCI8 is a set of functi<strong>on</strong>s based <strong>on</strong> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Call Interface (OCI) used <strong>to</strong> access<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> databases, including 8i and 9i releases. This module is more flexible than<br />

the standard <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> functi<strong>on</strong>s.<br />

The php_oci8 value in the php.ini file (extensi<strong>on</strong>=php_oci8.dll) is used <strong>to</strong> enable<br />

the functi<strong>on</strong>s. The set of functi<strong>on</strong>s that are in this module can be identified by the<br />

oci_ prefix, such as oci_log<strong>on</strong>(). Be<str<strong>on</strong>g>for</str<strong>on</strong>g>e PHP 5.0, every oci_ functi<strong>on</strong> was named<br />

with an oci prefix. Although the functi<strong>on</strong>s with the oci prefix are still available, they<br />

are now deprecated.<br />

ODBC functi<strong>on</strong>s<br />

A modified versi<strong>on</strong> of ODBC that provides a unified driver <str<strong>on</strong>g>for</str<strong>on</strong>g> native support <str<strong>on</strong>g>for</str<strong>on</strong>g><br />

several databases is available <str<strong>on</strong>g>for</str<strong>on</strong>g> PHP. ODBC support is integrated with PHP and,<br />

unlike the modules needed <str<strong>on</strong>g>for</str<strong>on</strong>g> ORA and OCI8, no extensi<strong>on</strong>s need <strong>to</strong> be specified.<br />

ODBC has the advantage of allowing applicati<strong>on</strong>s <strong>to</strong> be written which, theoretically,<br />

are independent from the RDBMS. If the RDBMS changes, <strong>on</strong>ly the driver will<br />

need <strong>to</strong> be changed, not the code.<br />

ODBC functi<strong>on</strong> calls are handled by a driver manager that passes the calls <strong>to</strong> a<br />

specific driver <str<strong>on</strong>g>for</str<strong>on</strong>g> the target database <str<strong>on</strong>g>for</str<strong>on</strong>g> executi<strong>on</strong>. The iODBC driver manager is<br />

comm<strong>on</strong>ly used with PHP <strong>to</strong> c<strong>on</strong>nect <strong>to</strong> databases <strong>on</strong> Windows. iODBC<br />

(h ttp://www.iodbc.org) is an open source ODBC driver manager and the SDK is<br />

maintained by Open Link Software (http://www.openlinksw.com). iODBC calls use<br />

an odbc_ prefix. For example, odbc_c<strong>on</strong>nect() utilizes the ODBC driver manager.<br />

Another open source project, named after the unixODBC project, has developed a<br />

driver manager called unixOD BC (http://www.unixodbc.org). The unixODBC calls<br />

use the three-letter <strong>SQL</strong> prefix. For example, <strong>SQL</strong>c<strong>on</strong>nect() uses the unixODBC<br />

driver manager.<br />

Note The functi<strong>on</strong> phpinfo() can be called <strong>to</strong> reveal the extensi<strong>on</strong>s that have been<br />

loaded in<strong>to</strong> PHP. A simple script c<strong>on</strong>taining the following line is sufficient <strong>to</strong> implement<br />

this call:<br />

<br />

Scenario 1: Interoperating PHP <strong>on</strong> <strong>UNIX</strong> with<br />

<strong>SQL</strong> <strong>Server</strong><br />

It is possible <strong>to</strong> interoperate between PHP applicati<strong>on</strong>s in a <strong>UNIX</strong> envir<strong>on</strong>ment and<br />

<strong>SQL</strong> <strong>Server</strong> databases using Microsoft® <strong>SQL</strong> <strong>Server</strong> functi<strong>on</strong>s or through an ODBC<br />

interface. Each API has its own functi<strong>on</strong> calls <strong>to</strong> c<strong>on</strong>nect <strong>to</strong> the database and execute<br />

statements. These APIs vary in support <str<strong>on</strong>g>for</str<strong>on</strong>g> comm<strong>on</strong> functi<strong>on</strong>s such as those related <strong>to</strong><br />

cursors and statements.<br />

Case 1: Interoperating a PHP Applicati<strong>on</strong> Using ORA<br />

Functi<strong>on</strong>s<br />

If the existing PHP soluti<strong>on</strong> uses ORA functi<strong>on</strong>s, then the best alternative is <strong>to</strong> replace<br />

them with Microsoft <strong>SQL</strong> <strong>Server</strong> (MS<strong>SQL</strong>) functi<strong>on</strong>s. This modificati<strong>on</strong> will require<br />

replacing the current driver with <strong>on</strong>e that supports the MS<strong>SQL</strong> functi<strong>on</strong>s. One of the<br />

drivers that can be used is FreeTDS (http://www.freetds.org).<br />

FreeTDS is a set of libraries <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>UNIX</strong> and Linux that allows programs <strong>to</strong> interact with<br />

Microsoft <strong>SQL</strong> <strong>Server</strong>. Using the FreeTDS libraries, PHP's mssql_xxx() functi<strong>on</strong>s can be<br />

used <strong>to</strong> directly access a <strong>SQL</strong> <strong>Server</strong> database<br />

from a <strong>UNIX</strong> or Linux computer. FreeTDS


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 241<br />

is an open source implementati<strong>on</strong> of the Tabular Data Stream pro<strong>to</strong>col used by<br />

<strong>SQL</strong> <strong>Server</strong> <str<strong>on</strong>g>for</str<strong>on</strong>g> its clients. The FreeTDS C libraries are freely available under the terms of<br />

the GNU GPL license.<br />

The pro<strong>to</strong>col versi<strong>on</strong> also affects how database servers interpret commands. Microsoft<br />

<strong>SQL</strong> <strong>Server</strong> 2000 is known <strong>to</strong> behave differently with versi<strong>on</strong>s 4.2 and 8.0 of FreeTDS.<br />

versi<strong>on</strong> 8.0 is recommended <str<strong>on</strong>g>for</str<strong>on</strong>g> compatibility with <strong>SQL</strong> <strong>Server</strong> <strong>to</strong>ols.<br />

To interoperate a PHP applicati<strong>on</strong> using ORA functi<strong>on</strong>ality, follow these<br />

comm<strong>on</strong> steps:<br />

1. Install the FreeTDS <strong>SQL</strong> <strong>Server</strong> libraries.<br />

D ownload the source code from http://www.freetds.org/software.html. The<br />

installati<strong>on</strong> process is very similar <strong>to</strong> that detailed in Appendix D, "Installing<br />

Comm<strong>on</strong> Drivers and Applicati<strong>on</strong>s," except that the installati<strong>on</strong> is occurring in <strong>UNIX</strong><br />

instead of Windows Services <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>UNIX</strong>.<br />

Note FreeTDS should be compiled with the --enable-msdblib opti<strong>on</strong>.<br />

2. Recompile PHP <strong>to</strong> use MS<strong>SQL</strong> functi<strong>on</strong>s.<br />

Refer <strong>to</strong> http://www.free tds.org/userguide/php.htm <str<strong>on</strong>g>for</str<strong>on</strong>g> more in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <strong>on</strong><br />

compiling PHP.<br />

Note PHP should be c<strong>on</strong>figured with the --with-mssql[=DIR] switch, where DIR is<br />

the locati<strong>on</strong> of the FreeTDS libraries. For example, from the PHP source direc<strong>to</strong>ry,<br />

type:<br />

./c<strong>on</strong>figure --with-mssql=/usr/local/freetds<br />

3. Enable MS<strong>SQL</strong> functi<strong>on</strong>s.<br />

Be<str<strong>on</strong>g>for</str<strong>on</strong>g>e MS<strong>SQL</strong> functi<strong>on</strong>s can be used, they must be enabled and initialized <str<strong>on</strong>g>for</str<strong>on</strong>g> use<br />

by uncommenting or adding the following line in the initializati<strong>on</strong> file php.ini.<br />

extensi<strong>on</strong>=php_mssql.dll<br />

4. Verify the installati<strong>on</strong>.<br />

Verify that the module i s installed by executing the phpinfo() functi<strong>on</strong>. MS<strong>SQL</strong><br />

should appear in the list of modules.<br />

5. Change all embedded <strong>SQL</strong> statements <strong>to</strong> T-<strong>SQL</strong>.<br />

Refer <strong>to</strong> chapter 11, "Developing: Applicati<strong>on</strong>s — <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>SQL</strong> and PL/<strong>SQL</strong>," <str<strong>on</strong>g>for</str<strong>on</strong>g> a<br />

detailed discussi<strong>on</strong> <strong>on</strong> modifying <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>SQL</strong> <strong>to</strong> be <strong>SQL</strong> <strong>Server</strong>-compliant.<br />

6. Modify the PHP applicati<strong>on</strong> code.<br />

The following sample sour ce code is used <strong>to</strong> illustrate the changes required when<br />

migrating PHP code from ORA functi<strong>on</strong>s <strong>to</strong> MS<strong>SQL</strong> functi<strong>on</strong>s. Pay special<br />

attenti<strong>on</strong> <strong>to</strong> the differences between these code secti<strong>on</strong>s.<br />

Note MS<strong>SQL</strong> does not have functi<strong>on</strong>s <strong>to</strong> create and drop cursors. Implicit<br />

cursors<br />

are used <strong>to</strong> handle results returned.


242 Developing: Applicati<strong>on</strong>s — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> PHP<br />

The following example is sample ORA-based PHP code that executes a simple<br />

query and retrieves results using a cursor operati<strong>on</strong>:<br />

<br />

The following example is the same code modified <strong>to</strong> MS<strong>SQL</strong>-based PHP code:<br />


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 243<br />

$mycursor = mssql_query($sql);<br />

// Display in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong><br />

while ($row = mssql_fetch_array($mycursor)){<br />

echo "RESULT: " . $row['last_name'] . ", " . $row['salary'] . "\n";<br />

}<br />

// Close c<strong>on</strong>necti<strong>on</strong><br />

mssql_close($c<strong>on</strong>n);<br />

?><br />

Database server in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> can also be referenced from freetds.c<strong>on</strong>f, as shown in<br />

the following c<strong>on</strong>figurati<strong>on</strong> in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong>.<br />

/* freetds.c<strong>on</strong>f<br />

[<strong>SQL</strong><strong>Server</strong>]<br />

host = win2kss1<br />

port = 1433<br />

tds versi<strong>on</strong> = 8. 0<br />

*/<br />

To use the freetds.c<strong>on</strong>f entry, the c<strong>on</strong>necti<strong>on</strong> code will change as follows:<br />

// specify path <strong>to</strong> file<br />

putenv(FREETDSCONF=/usr/local/freetds.c<strong>on</strong>f’)<br />

$c<strong>on</strong>n=mssql_c<strong>on</strong>nect(‘<strong>SQL</strong><strong>Server</strong>’, $username, $password);<br />

The following table provides a mapping between key ORA functi<strong>on</strong>s and the respective<br />

MS<strong>SQL</strong> functi<strong>on</strong>s. ORA functi<strong>on</strong>s that do not have a matching MS<strong>SQL</strong> functi<strong>on</strong> are<br />

denoted with a hyphen. A discussi<strong>on</strong> of handling these disparate functi<strong>on</strong>s appears in the<br />

"Comm<strong>on</strong> Functi<strong>on</strong> Translati<strong>on</strong> Issues" secti<strong>on</strong> later in this chapter.<br />

Table 13.1: Mapping Between ORA and MS<strong>SQL</strong> Functi<strong>on</strong>s<br />

Operati<strong>on</strong> Task ORA functi<strong>on</strong> MS<strong>SQL</strong> functi<strong>on</strong><br />

C<strong>on</strong>necti<strong>on</strong> Open c<strong>on</strong>necti<strong>on</strong> ora_log<strong>on</strong>() mssql_c<strong>on</strong>nect()<br />

Close c<strong>on</strong>necti<strong>on</strong> ora_logoff() mssql_close()<br />

Persistent ora_plog<strong>on</strong>() mssql_pc<strong>on</strong>nect()<br />

c<strong>on</strong>necti<strong>on</strong><br />

Cursor<br />

Open cursor ora_open() -<br />

Close cursor ora_close() -<br />

Pa rsing Parse statement ora_parse( ) -<br />

Binding Bind variable ora_bind() mssql_bind()<br />

Executi<strong>on</strong><br />

Execute statement ora_exec() mssql_execute()<br />

mssql_query()<br />

Prepare and ora_do() mssql_execute()<br />

execute<br />

mssql_query()<br />

Fet ching Fetch row<br />

ora_fetch()<br />

ora_fetch_in<strong>to</strong><br />

mssql_fetch_row()<br />

mssql_fetch_array()<br />

Fetch column ora_getcolumn() mssql_fetch_field<br />

Transacti<strong>on</strong><br />

Commit<br />

ora_commit<strong>on</strong>() -<br />

Management<br />

ora_commi<strong>to</strong>ff()


244 Developing: Applicati<strong>on</strong>s — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> PHP<br />

Operati<strong>on</strong> Task ORA functi<strong>on</strong> MS<strong>SQL</strong> functi<strong>on</strong><br />

ora_commit()<br />

Rollback<br />

ora_rollback() -<br />

Error Handling Error checking ora_error()<br />

-<br />

ora_errorcode()<br />

Others<br />

Name of result ora_columnname() mssql_field_name()<br />

column<br />

Size of result ora_columnsize() mssql_field_length()<br />

column<br />

Datatype of result ora_columntype() mssql_field_type()<br />

column<br />

Number of rows<br />

effected<br />

ora_numrows() mssqp_num_rows()<br />

Number of columns ora_numcols() mssql_num_fields()<br />

returned<br />

Case 2: Interoperating a PHP Applicati<strong>on</strong> Using OCI8<br />

Functi<strong>on</strong>s<br />

To interoperate using OCI8, follow these comm<strong>on</strong> steps:<br />

As with Case 1 "Interoperating a PHP Applicati<strong>on</strong> Using ORA Functi<strong>on</strong>s", the best alternative<br />

<str<strong>on</strong>g>for</str<strong>on</strong>g> OCI8 functi<strong>on</strong>s is <strong>to</strong> replace them with MS<strong>SQL</strong> calls. Most of the steps are the same<br />

between this procedure and the p rocedure in the "Case 1: Interoperating a PHP Applicati<strong>on</strong><br />

Using ORA F uncti<strong>on</strong>s" secti<strong>on</strong> of this scenario. As a result, these steps are not described in<br />

detail here.<br />

1. Install the FreeTDS <strong>SQL</strong> <strong>Server</strong> libraries.<br />

2. Compile PHP <strong>to</strong> use MS<strong>SQL</strong><br />

APIs.<br />

3. Enable MS<strong>SQL</strong> functi<strong>on</strong>s within php.ini.<br />

4. Verify the installati<strong>on</strong> using phpinfo().<br />

5 . Change all embedded <strong>SQL</strong> statements <strong>to</strong> T-<strong>SQL</strong>.<br />

Refer <strong>to</strong> Chapter 11, "Developin g: Applicati<strong>on</strong>s — <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>SQL</strong> and PL/<strong>SQL</strong>," <str<strong>on</strong>g>for</str<strong>on</strong>g> a<br />

detailed discussi<strong>on</strong> <strong>on</strong> modifying <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>SQL</strong> <strong>to</strong> be <strong>SQL</strong> <strong>Server</strong>-compliant.<br />

6. Modify applicati<strong>on</strong> code <strong>to</strong> reflect the new drivers.<br />

The following sample source code is used <strong>to</strong> illustrate the changes required in PHP<br />

code when replacing OCI8 functi<strong>on</strong>s with MS<strong>SQL</strong> functi<strong>on</strong>s.<br />

The following example is the original OCI8-based PHP code:<br />


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 245<br />

$sql1 = OCIParse($c<strong>on</strong>n, "INSERT INTO countries VALUES (‘US‘,‘United States of<br />

America’, 2)");<br />

OCIExecute($sql1);<br />

// Insert <strong>SQL</strong> statement with binding<br />

$var1 = ‘MX’;<br />

$var2 = ‘Mexico”;<br />

$var3 = 3;<br />

$sql2 = OCIParse($c<strong>on</strong>n, "INSERT INTO countries VALUES (:bind1, :bind2,<br />

:bind3); ");<br />

OCIBindByName($sql2, ":bind1", $var1);<br />

OCIBindByName($sql2, ":bind2", $var2);<br />

OCIBindByName($sql2, ":bind3", $var3);<br />

OCIExecute($sql2);<br />

echo OCIRowCount($sql2) . " rows inserted. ";<br />

// Commit<br />

OCICommit($c<strong>on</strong>n);<br />

// Close c<strong>on</strong>necti<strong>on</strong><br />

OCILogoff($c<strong>on</strong>n);<br />

?><br />

The following example is the same PHP source code modified <strong>to</strong> use the MS<strong>SQL</strong><br />

drivers. Note the difference in the commit functi<strong>on</strong>.<br />


246 Developing: Applicati<strong>on</strong>s — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> PHP<br />

// Close c<strong>on</strong>necti<strong>on</strong><br />

mssql_close($c<strong>on</strong>n);<br />

?><br />

Table 13.2 maps the equivalent calls between OCI8 and MS<strong>SQL</strong> functi<strong>on</strong>s. A hyphen is<br />

used when a similar functi<strong>on</strong> does not exist in MS<strong>SQL</strong>. A discussi<strong>on</strong> <strong>on</strong> handling these<br />

disparate functi<strong>on</strong>s is available in the "Comm<strong>on</strong> Functi<strong>on</strong> Translati<strong>on</strong> Is sues" secti<strong>on</strong> later<br />

in this chapter.<br />

Table 13.2: Mapping Between OCI8 and MS<strong>SQL</strong> Functi<strong>on</strong>s<br />

Operati<strong>on</strong> Task OCI8 Functi<strong>on</strong>s MS<strong>SQL</strong> Functi<strong>on</strong>s<br />

C<strong>on</strong>necti<strong>on</strong> Open c<strong>on</strong>necti<strong>on</strong> ociLog<strong>on</strong>() mssql_c<strong>on</strong>nect()<br />

Close c<strong>on</strong>necti<strong>on</strong> ociLogoff() mssql_close()<br />

Persistent ociPLog<strong>on</strong>() mssql_pc<strong>on</strong>nect()<br />

c<strong>on</strong>necti<strong>on</strong><br />

Cursor Open cursor ociNewCursor() -<br />

Close cursor ociFreeCursor() -<br />

Statement Free statement oci_free_statement() mssql_free_statement()<br />

Parsing Parse statement ociParse() -<br />

Executi<strong>on</strong><br />

Execute<br />

ociExecute()<br />

mssql_execute()<br />

statement<br />

mssql_query()<br />

Fetching Fetch row ociFetch() mssql_fetch_row()<br />

Transacti<strong>on</strong><br />

Management<br />

Commit<br />

Rollback<br />

ociCommit()<br />

ociRollback()<br />

-<br />

-<br />

Error Error checking ociError()<br />

-<br />

Handling<br />

Others<br />

Name of result ociColumnName() mssql_field_name()<br />

column<br />

Size of result ociColumnSize() mssql_field_length()<br />

column<br />

Datatype of ociColumnType() mssql_field_type()<br />

result column<br />

Number of rows ociRowCount() mssql_num_rows()<br />

effected<br />

Number of ociNumCols() mssql_num_fields( )<br />

columns returned<br />

Case 3: Interoperating a PHP Applicati<strong>on</strong> Using<br />

ODBC Functi<strong>on</strong>s<br />

While migrating from <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong>, no cha nges will be needed <strong>to</strong> the ODBC<br />

calls themselves; the availability of <strong>SQL</strong> <strong>Server</strong>-specific drivers <str<strong>on</strong>g>for</str<strong>on</strong>g> the <strong>UNIX</strong> envir<strong>on</strong>ment<br />

and the capabilities of the dr iver manager <strong>to</strong> work with these drivers define<br />

the changes<br />

that must be made. The best choice <str<strong>on</strong>g>for</str<strong>on</strong>g> interoperating with <strong>SQL</strong> <strong>Server</strong> is offered by the


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 247<br />

FreeTDS driver, which is supported by the iODBC driver manager of the source<br />

envir<strong>on</strong>ment.<br />

Other opti<strong>on</strong>s available include Easysoft's ODBC-ODBC Bridge (OOB) and OpenLink's<br />

Universal Data Access drivers.<br />

To interoperate using ODBC functi<strong>on</strong>s, follow these comm<strong>on</strong> steps:<br />

The following steps are required <strong>to</strong> interoperate PHP applicati<strong>on</strong>s with <strong>SQL</strong> <strong>Server</strong>.<br />

1. If needed, install ODBC software.<br />

It is assumed that the iODBC driver manager is alre ady installed and is being used<br />

<strong>to</strong> c<strong>on</strong>nect <strong>to</strong> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>. If this is not true, then either the iODBC or the unixODBC<br />

driver manager must be installed.<br />

The iODBC driver manager can be downloade d from<br />

http://www.openlinksw.com/iodbc/. Installati<strong>on</strong> instru cti<strong>on</strong>s are available<br />

in<br />

Appendix D, "Installing Comm<strong>on</strong> Drivers and Applicati<strong>on</strong>s."<br />

The unixODBC driver manager can be downloaded from http://www.u nixodbc.org/ .<br />

Installati<strong>on</strong> instructi<strong>on</strong>s are also available in Appendix D, "Installing Comm<strong>on</strong><br />

Drivers and Applicati<strong>on</strong>s."<br />

2. Install the <strong>SQL</strong> <strong>Server</strong> driver.<br />

The most popular ODBC driver <strong>to</strong> c<strong>on</strong>nect <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> from a <strong>UNIX</strong> operating<br />

system is FreeTDS. FreeTDS is an open source implementati<strong>on</strong> of TDS that allows<br />

<strong>UNIX</strong>-based programs native access <strong>to</strong> <strong>SQL</strong> <strong>Server</strong>. OpenLink also offers drivers<br />

<str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>SQL</strong> <strong>Server</strong> that use the FreeTDS implementati<strong>on</strong> of TDS. Installati<strong>on</strong><br />

instructi<strong>on</strong>s are located in Appendix D, "Installing Comm<strong>on</strong> Drivers and<br />

Applicati<strong>on</strong>s."<br />

An ODBC-ODBC bridge <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> is available from Easysoft. For detailed<br />

instructi<strong>on</strong>s <strong>on</strong> enabling ODBC support under PHP, refer <strong>to</strong><br />

http://www.easysoft.com/produ cts/2002/apache.phtml.<br />

OpenLink (http://www.openlinks w.com) also offers single-tier and multitier<br />

Universal Data Access drivers.<br />

3. Recompile PHP <strong>to</strong> use ODBC functi<strong>on</strong>s.<br />

To be capable <strong>to</strong> use the <strong>SQL</strong> <strong>Server</strong> driver, PHP must be recompiled with ODBC<br />

functi<strong>on</strong>s. This procedure will vary based <strong>on</strong> the ODBC driver that is installed.<br />

Refer the following resources <str<strong>on</strong>g>for</str<strong>on</strong>g> more in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong>.<br />

● FreeTDS — http: //www.freetds.org/userguide/php.htm<br />

● Easysoft — http://www.easysoft.com/products/2002/apache.phtml<br />

● OpenLink — http://docs.openlinksw.com<br />

4. C<strong>on</strong>figure the Data Source Name (DSN).<br />

ODBC needs an ODBC data source <strong>to</strong> c<strong>on</strong>nect <strong>to</strong> the database. The DSN is<br />

generally defined in an odbc.ini file that the driver manager uses <strong>to</strong> load the ODBC<br />

driver.<br />

When using FreeTDS, the DSN can also be c<strong>on</strong>figured by modifying the odbc.ini<br />

file. A <strong>SQL</strong> <strong>Server</strong> DSN should be similarly c<strong>on</strong>figured <strong>to</strong> the following example.<br />

[ODBC Data Sources]<br />

SS_HR_DB=Sample MS <strong>SQL</strong><strong>Server</strong><br />

[SS_HR_DB]<br />

Driver=/usr/local/freetds/lib/libtdsodbc.so<br />

Descripti<strong>on</strong>=<strong>SQL</strong> <strong>Server</strong> 2000<br />

<strong>Server</strong>=win2kdbp1


248 Developing: Applicati<strong>on</strong>s — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> PHP<br />

Port=1433<br />

Database=hrapp<br />

Log<strong>on</strong>ID=daveb<br />

Password=cougar<br />

5. Check the c<strong>on</strong>necti<strong>on</strong>.<br />

In iODBC, the command line query program odbctest can be used <strong>to</strong> test the DSN<br />

c<strong>on</strong>nectivity. If using unixODBC, the isql utility can be used <strong>to</strong> do this.<br />

6. Modify the applicati<strong>on</strong> source code <strong>to</strong> reflect the new data source.<br />

Because ODBC is a generic interface <strong>to</strong> any database, no changes are required in<br />

the applicati<strong>on</strong> code except <strong>to</strong> c<strong>on</strong>nect <strong>to</strong> the <strong>SQL</strong> <strong>Server</strong> database. The proper<br />

DSN has already been set up in an earlier step.<br />

The following PHP code snippet uses the ODBC module <strong>to</strong> c<strong>on</strong>nect <strong>to</strong> an <str<strong>on</strong>g>Oracle</str<strong>on</strong>g><br />

data source, and it should be similar <strong>to</strong> code in the existing soluti<strong>on</strong>.<br />

<br />

When migrated <strong>to</strong> c<strong>on</strong>nect <strong>to</strong> <strong>SQL</strong> <strong>Server</strong>, the c<strong>on</strong>necti<strong>on</strong> string will reflect the<br />

changes that follow.<br />

<br />

Change all embedded <strong>SQL</strong> statements <strong>to</strong> T-<strong>SQL</strong>.<br />

Refer <strong>to</strong> Chapter 11, "Developing: Applicati<strong>on</strong>s — <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>SQL</strong> and PL/<strong>SQL</strong>," <str<strong>on</strong>g>for</str<strong>on</strong>g> a<br />

detailed discussi<strong>on</strong> <strong>on</strong> modifying <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>SQL</strong> <strong>to</strong> be <strong>SQL</strong> <strong>Server</strong>-compliant.<br />

Table 13.3 is a listing of the ODBC functi<strong>on</strong> calls that are used in PHP code <strong>to</strong> work with<br />

databases.<br />

Table 13.3: ODBC Functi<strong>on</strong> Calls in PHP<br />

Operati<strong>on</strong> Task ODBC Functi<strong>on</strong><br />

C<strong>on</strong>necti<strong>on</strong> Open c<strong>on</strong>necti<strong>on</strong> odbc_c<strong>on</strong>nect()<br />

Open persistent c<strong>on</strong>necti<strong>on</strong> odbc_pc<strong>on</strong>nect()<br />

Close c<strong>on</strong>necti<strong>on</strong><br />

odbc_close()<br />

Get c<strong>on</strong>necti<strong>on</strong> in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> odbc_data_source()<br />

Parsing Prepare statement odbc_prepare()<br />

Cursor Get cursor name odbc_cursor()<br />

Executi<strong>on</strong> Execute statement odbc_execute()<br />

Prepare and execute odbc_exec()<br />

odbc_do()


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 249<br />

Operati<strong>on</strong> Task ODBC Functi<strong>on</strong><br />

Fetching Fetch row odbc_fetch_row()<br />

odbc_fetch_array()<br />

odbc_fetch_in<strong>to</strong>()<br />

odbc_fetch_object()<br />

Fetch column -<br />

Transacti<strong>on</strong> Management Commit odbc_commit()<br />

Rollback<br />

odbc_rollback()<br />

Error Handling Error Checking odbc_error()<br />

Get last error odbc_errormsq()<br />

Others Name of result column odbc_field_name()<br />

Name of table column odbc_columns()<br />

Size of result column odbc_field_len()<br />

Datatype of result column odbc_field_type()<br />

Number of rows effected odbc_num_rows()<br />

Number of columns odbc_num_fields()<br />

returned<br />

Comm<strong>on</strong> Functi<strong>on</strong> Translati<strong>on</strong> Issues<br />

Though <strong>SQL</strong> <strong>Server</strong> and <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> share a great deal of functi<strong>on</strong>ality, some database<br />

operati<strong>on</strong>s differ. This secti<strong>on</strong> discusses some of the differences between coding with<br />

PHP extensi<strong>on</strong>s <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong>.<br />

Handling Transacti<strong>on</strong>s<br />

The <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> PHP extensi<strong>on</strong> module supports transacti<strong>on</strong>s using the following functi<strong>on</strong><br />

calls:<br />

● ora_commit()<br />

● ora_commi<strong>to</strong>ff()<br />

● ora_commit<strong>on</strong>()<br />

● ora_rollback()<br />

The OCI PHP extensi<strong>on</strong> module supports transacti<strong>on</strong>s using the following functi<strong>on</strong> calls.<br />

● OCICommit()<br />

● OCIRollBack()<br />

MS<strong>SQL</strong> API does not provide commit or rollback functi<strong>on</strong>s. These functi<strong>on</strong>s can be<br />

achieved using the following example code:<br />

// Here $db is a PHP variable <str<strong>on</strong>g>for</str<strong>on</strong>g> c<strong>on</strong>necti<strong>on</strong> object<br />

//To begin transacti<strong>on</strong><br />

$sql = "begin tran";<br />

$result<br />

= mssql_query($sql,$db);<br />

//To commit transacti<strong>on</strong><br />

$sql = "commit tran";<br />

$result = mssql_query($sql,$db);


250 Developing: Applicati<strong>on</strong>s — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> PHP<br />

//To rollback transacti<strong>on</strong><br />

$sql = "rollback tran";<br />

$result = mssql_query($sql,$db);<br />

<str<strong>on</strong>g>Migrating</str<strong>on</strong>g> Cursors<br />

$c<strong>on</strong>n=mssql_c<strong>on</strong>nect("myhost","user","pwd");<br />

mssql_select_db("hr",$c<strong>on</strong>n);<br />

// create the select statement<br />

$sqlquery="SELECT companyName FROM Cus<strong>to</strong>mers;";<br />

// activate the query and retrieve the result set<br />

$results= mssql_query($sqlquery);<br />

// Do a row fetch from the result set <str<strong>on</strong>g>for</str<strong>on</strong>g> display<br />

while ($row=mssql_fetch_array($results)){<br />

echo $row['companyName']."\n";<br />

}<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> requires using cursors with SELECT statements, regardless of the number of<br />

rows requested from the database. In <strong>SQL</strong> <strong>Server</strong>, a SELECT statement that is not<br />

disclosed <strong>on</strong> a cursor returns rows <strong>to</strong> the client as a default result set. This is an efficient<br />

way <strong>to</strong> return data <strong>to</strong> a client applicati<strong>on</strong>.<br />

When porting a PL/<strong>SQL</strong> procedure from <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>, first determine whether cursors are<br />

needed <strong>to</strong> per<str<strong>on</strong>g>for</str<strong>on</strong>g>m the same functi<strong>on</strong> in Transact-<strong>SQL</strong>. If the cursor is used <strong>on</strong>ly <strong>to</strong> return<br />

a set of rows <strong>to</strong> the client applicati<strong>on</strong>, use a n<strong>on</strong>-cursor SELECT statement in Transact-<br />

local procedure variables, use cursors in Transact-<strong>SQL</strong>.<br />

Unlike <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and OCI8 (which have methods <str<strong>on</strong>g>for</str<strong>on</strong>g> explicit use of cursors), MS<strong>SQL</strong> uses<br />

<strong>SQL</strong> <strong>to</strong> return a default result set. If the cursor is used <strong>to</strong> load data a row at a time in<strong>to</strong><br />

implicit cursors. Functi<strong>on</strong>s such as mssql_query() and mssql_execute() associate a<br />

handle <strong>to</strong> the returned result, which can be traversed similar <strong>to</strong> an explicit cursor. The<br />

following code shows the use of result set <strong>to</strong> achieve the same functi<strong>on</strong>ality as that of a<br />

cursor.<br />

<strong>SQL</strong> <strong>Server</strong> cursors may also be used <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>on</strong>e of the following reas<strong>on</strong>s:<br />

● Updateable cursors<br />

● Scrollable, read-<strong>on</strong>ly cursors<br />

Note ODBC Cursor Library cursors build <strong>on</strong> <strong>to</strong>p of default result sets. Be sure <strong>to</strong> fetch<br />

<strong>to</strong> the end of the result set quickly <strong>to</strong> free up locks.<br />

When you use server cursors, use <strong>SQL</strong>ExtendedFetch <strong>to</strong> fetch in blocks of rows<br />

instead of a single row at a time. This is the same thing as array-type fetching in<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g>. This saves <strong>on</strong> round-trip fetches <strong>to</strong> the server. For more in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <strong>on</strong><br />

<strong>SQL</strong>ExtendedFetch, refer <strong>to</strong><br />

http://msdn.microsoft.com/library/default.asp?url=/library/en-<br />

us/odbc/htm/odbcsqlextendedfetch.asp.<br />

Use result sets when you think it will fetch all rows at <strong>on</strong>e time, but use server cursors<br />

when<br />

you know a result set would not fetch all rows at <strong>on</strong>ce.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 251<br />

C<strong>on</strong>necti<strong>on</strong> Pooling<br />

While PHP does not offer c<strong>on</strong>necti<strong>on</strong> pooling, persistent <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> c<strong>on</strong>necti<strong>on</strong>s can<br />

opened with the following API functi<strong>on</strong> calls.<br />

● <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> API: ora_plog<strong>on</strong>()<br />

● OCI8 API: ociPLog<strong>on</strong>()<br />

To interoperate with <strong>SQL</strong> <strong>Server</strong>, these functi<strong>on</strong>s should be replaced by <strong>on</strong>e of the<br />

following functi<strong>on</strong>s, depending up<strong>on</strong> the API used:<br />

● ODBC API: odbc_pc<strong>on</strong>nect()<br />

● MS<strong>SQL</strong> API: mssql_pc<strong>on</strong>nect()<br />

Unlike c<strong>on</strong>necti<strong>on</strong> pooling, a persistent c<strong>on</strong>necti<strong>on</strong> is local <strong>to</strong> a process and cannot be<br />

shared between different processes.<br />

S<strong>to</strong>red Procedures<br />

S<strong>to</strong> red procedures can be handled by the MS<strong>SQL</strong> API as well as the ORA and OCI8<br />

APIs. The following example shows sample s<strong>to</strong>red procedures using MS<strong>SQL</strong> calls.<br />

// Create Query <str<strong>on</strong>g>for</str<strong>on</strong>g> S<strong>to</strong>red Procedure In Code<br />

// S<strong>to</strong>red procedure name: CustOrdersDetail from Northwind database<br />

$stmt = mssql_init("CustOrdersDetail",$c<strong>on</strong>n);<br />

be<br />

mssql_select_db("Northwind", $c<strong>on</strong>n);<br />

// Parameter values<br />

$orderid = 1;<br />

// Binding parameter value <strong>to</strong> s<strong>to</strong>red procedure<br />

mssql_bind($stmt, "@OrderID", $orderid, <strong>SQL</strong>INT4);<br />

// Execute <strong>SQL</strong> Statement & Capture Results<br />

$result = mssql_execute($stmt);<br />

// Fetch return data and place in<strong>to</strong> array <str<strong>on</strong>g>for</str<strong>on</strong>g> access<br />

while($row = mssql_fetch_array($result)){<br />

// Assign Variables<br />

$unitprice = $row["UnitPrice"];<br />

echo "Unit Price" . $unitprice;<br />

$quantity = $row["Quantity"];<br />

echo "Quantity" . $quantity;<br />

$discount = $row["Discount"];<br />

echo "Discount" . $discount;<br />

$price = $row["ExtendedPrice"];<br />

echo "Price" . $price;<br />

}


252 Developing: Applicati<strong>on</strong>s — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> PHP<br />

Scenario 2: Porting the Applicati<strong>on</strong> <strong>to</strong> Win32<br />

Because PHP is a cross-plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m language, porting applicati<strong>on</strong>s from a <strong>UNIX</strong><br />

envir<strong>on</strong>ment <strong>to</strong> Windows is not much more complex than the steps required <str<strong>on</strong>g>for</str<strong>on</strong>g><br />

interoperati<strong>on</strong>. The strategy, steps, and actual changes required are very similar <strong>to</strong> those<br />

discussed <str<strong>on</strong>g>for</str<strong>on</strong>g> interoperati<strong>on</strong>. The <strong>on</strong>ly additi<strong>on</strong>al step is installing PHP and the applicati<strong>on</strong><br />

code in the Windows envir<strong>on</strong>ment.<br />

Case 1: Porting a PHP Applicati<strong>on</strong> using ORA Functi<strong>on</strong>s<br />

Most of the following steps are covered in more detail in the "Case 1: Interoperating a<br />

PHP Applicati<strong>on</strong> Using ORA Functi<strong>on</strong>s" secti<strong>on</strong> of Scenario 1.<br />

To port the applicati<strong>on</strong> using ORA functi<strong>on</strong>s, follow these comm<strong>on</strong> steps:<br />

1. Install PHP <strong>on</strong> target Windows server.<br />

For more in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <strong>on</strong> installing PHP, refer <strong>to</strong><br />

http://uk2.php.net/manual/en/install.php.<br />

2. Install <strong>SQL</strong> <strong>Server</strong> libraries.<br />

Instead of the FreeTDS libraries, the Windows-based libraries offered by Microsoft<br />

in <strong>SQL</strong> Client Tools can be installed <strong>on</strong> the system where PHP is installed. The<br />

Client Tools can be installed from the MS <strong>SQL</strong> <strong>Server</strong> CD or by copying<br />

ntwdblib.dll from \winnt\system32 <strong>on</strong> the server <strong>to</strong> \winnt\system32 <strong>on</strong> the target<br />

Windows server. However, copying ntwdblib.dll will <strong>on</strong>ly provide access.<br />

C<strong>on</strong>figurati<strong>on</strong> of the client will require installati<strong>on</strong> of all the <strong>to</strong>ols.<br />

3. Compile PHP <strong>to</strong> use the MS<strong>SQL</strong> module.<br />

4. Enable MS<strong>SQL</strong> functi<strong>on</strong>s in php.ini.<br />

5. Verify the installati<strong>on</strong> using phpinfo().<br />

6. Transport source code <strong>to</strong> target server.<br />

7. Modify the applicati<strong>on</strong>'s source code <strong>to</strong> reflect the MS<strong>SQL</strong> API instead of ORA<br />

functi<strong>on</strong>s..<br />

Case 2: Porting a PHP Applicati<strong>on</strong> Using OCI8 Functi<strong>on</strong>s<br />

Most of the steps needed <strong>to</strong> migrate this applicati<strong>on</strong> are discussed in more detail in the<br />

"Case 2: Interoperating a PHP Applicati<strong>on</strong> Using OC18 Functi<strong>on</strong>s" secti<strong>on</strong> of Scenario 1.<br />

The following steps are required <strong>to</strong> migrate PHP applicati<strong>on</strong>s <strong>to</strong> Windows using OC18<br />

functi<strong>on</strong>s.<br />

To port the applicati<strong>on</strong> using OCI8 functi<strong>on</strong>s, follow these comm<strong>on</strong> steps:<br />

1. Install PHP <strong>on</strong> target Windows server.<br />

2. Install <strong>SQL</strong> <strong>Server</strong> libraries from <strong>SQL</strong> Client Tools.<br />

3. Compile PHP <strong>to</strong> use the MS<strong>SQL</strong> module.<br />

4. Enable MS<strong>SQL</strong> functi<strong>on</strong>s in php.ini.<br />

5. Verify the installati<strong>on</strong> using phpinfo().<br />

6. Transport the source code <strong>to</strong> the target Windows server.<br />

7. Modify the applicati<strong>on</strong> code <strong>to</strong> reflect the MS<strong>SQL</strong> API instead of OCI functi<strong>on</strong>s.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 253<br />

Case 3: Porting a PHP Applicati<strong>on</strong> Using ODBC Functi<strong>on</strong>s<br />

Most of the steps listed as follows are discussed in more detail in the "Case 3:<br />

Interoperating a PHP Applicati<strong>on</strong> Using ODBC Functi<strong>on</strong>s" secti<strong>on</strong> of scenario 1. The<br />

following steps are required <strong>to</strong> migrate PHP applicati<strong>on</strong>s <strong>to</strong> Windows using ODBC<br />

functi<strong>on</strong>s.<br />

To port the applicati<strong>on</strong> using ODBC functi<strong>on</strong>s, follow these comm<strong>on</strong> steps:<br />

1. Install PHP <strong>on</strong> target Windows server.<br />

2. Install ODBC software.<br />

For installati<strong>on</strong> instructi<strong>on</strong>s, refer <strong>to</strong><br />

http://support.microsoft.com/default.aspx?scid=kb;en-us;313008.<br />

3. Install the <strong>SQL</strong> <strong>Server</strong> driver.<br />

In additi<strong>on</strong> <strong>to</strong> the drivers menti<strong>on</strong>ed <str<strong>on</strong>g>for</str<strong>on</strong>g> interoperati<strong>on</strong>, the Microsoft ODBC driver<br />

<str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>SQL</strong> <strong>Server</strong> may also be used. This driver is available al<strong>on</strong>g with the<br />

<strong>SQL</strong> <strong>Server</strong> client CD. Installati<strong>on</strong> instructi<strong>on</strong>s are available at<br />

http://msdn.microsoft.com/library/default.asp?url=/library/enus/how<strong>to</strong>sql/ht_install_029l.asp.<br />

4. Compile PHP <strong>to</strong> use ODBC in the php.ini file.<br />

5. C<strong>on</strong>figure the DSN <strong>to</strong> c<strong>on</strong>nect with the <strong>SQL</strong> <strong>Server</strong> database.<br />

6. Check the c<strong>on</strong>necti<strong>on</strong> using command line utilities.<br />

7. Transport the source code <strong>to</strong> the target Windows envir<strong>on</strong>ment.<br />

8. Modify the applicati<strong>on</strong> source code <strong>to</strong> reflect the MS<strong>SQL</strong> API.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 255<br />

14<br />

Developing: Applicati<strong>on</strong>s —<br />

<str<strong>on</strong>g>Migrating</str<strong>on</strong>g> Java<br />

Introducti<strong>on</strong> and Goals<br />

This chapter c<strong>on</strong>tains a detailed discussi<strong>on</strong> of changes that must be made <strong>to</strong> Java<br />

applicati<strong>on</strong>s when the database is migrated from <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>to</strong> Microsoft® <strong>SQL</strong> <strong>Server</strong>. At<br />

the c<strong>on</strong>clusi <strong>on</strong> of this chapter, the Java applicati<strong>on</strong> should be capable <strong>to</strong> successfully<br />

c<strong>on</strong>nect <strong>to</strong> t he <strong>SQL</strong> <strong>Server</strong> database that was migrated from <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>. The soluti<strong>on</strong> can<br />

then be tested.<br />

Java is a po rtable language. The capability <str<strong>on</strong>g>for</str<strong>on</strong>g> the Java programming language <strong>to</strong><br />

interact with an RDBMS such as <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong> is provided by the Java<br />

Database C<strong>on</strong>nectivity (JDBC) API. Applicati<strong>on</strong>s written in Java can execute <strong>SQL</strong><br />

statements, retrieve results, and propagate changes back <strong>to</strong> the underlying data source<br />

using the JDBC API.<br />

The combinati<strong>on</strong> of the Java plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m and JDBC API allows a program <strong>to</strong> operate <strong>on</strong> a<br />

number of plat<str<strong>on</strong>g>for</str<strong>on</strong>g>ms, and with any number of <strong>SQL</strong>-supported databases, without<br />

modifying the source code.<br />

When migrating from an <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>to</strong> a <strong>SQL</strong> <strong>Server</strong> envir<strong>on</strong>ment, there will still be some<br />

alterati<strong>on</strong>s made <strong>to</strong> the applicati<strong>on</strong>. These basic changes will need <strong>to</strong> be made whether<br />

the Java applicati<strong>on</strong> interoperates with <strong>SQL</strong> <strong>Server</strong> from a <strong>UNIX</strong> envir<strong>on</strong>ment, or if the<br />

Java applicati<strong>on</strong> is ported <strong>to</strong> Windows®.<br />

As discussed in the "Define the <str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> C<strong>on</strong>cept" secti<strong>on</strong> of Chapter 2, "Envisi<strong>on</strong>ing<br />

Phase," there are four different strategies available <str<strong>on</strong>g>for</str<strong>on</strong>g> transiti<strong>on</strong>ing applicati<strong>on</strong>s in an<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> migrati<strong>on</strong> project. The strategies are:<br />

● Interoperate the applicati<strong>on</strong> with <strong>UNIX</strong><br />

● Port or rewrite the applicati<strong>on</strong> <strong>to</strong> the Microsoft .NET plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m<br />

● Port or rewrite the applicati<strong>on</strong> <strong>to</strong> the Microsoft Win32® plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m<br />

● Quick p ort using the Microsoft Windows Services <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>UNIX</strong> 3.5 plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m<br />

Because of some of the unique characteristics of Java, some of these strategies are<br />

more logical than others. For instance, because Java can be ported <strong>to</strong> Windows, there is<br />

no need <strong>to</strong> rewrite the applicati<strong>on</strong> in the .NET framework or <str<strong>on</strong>g>for</str<strong>on</strong>g> the Win32 envir<strong>on</strong>ment.


256 Developing: Applicati<strong>on</strong>s — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> Java<br />

Based <strong>on</strong> the available migrati<strong>on</strong> strategies, two scenarios can be developed <strong>to</strong> migrate<br />

the Java applicati<strong>on</strong>. These scenarios are:<br />

● Scenario 1: Interoperating Java <strong>on</strong> <strong>UNIX</strong> with <strong>SQL</strong> <strong>Server</strong><br />

If the business requirements do not include eliminating the <strong>UNIX</strong> envir<strong>on</strong>ment, an<br />

interoperati<strong>on</strong> strategy can be implemented quickly. Few, if any, changes need <strong>to</strong><br />

be made <strong>to</strong> the source code and it may be necessary <strong>to</strong> install a new driver <strong>to</strong><br />

allo w the Java applicati<strong>on</strong> <strong>to</strong> c<strong>on</strong>nect <strong>to</strong> a <strong>SQL</strong> <strong>Server</strong> database. If the migrati<strong>on</strong> is<br />

per<str<strong>on</strong>g>for</str<strong>on</strong>g>med in phases or <str<strong>on</strong>g>for</str<strong>on</strong>g> multiple applicati<strong>on</strong>s, interoperati<strong>on</strong> can be used as an<br />

interim step.<br />

● Scenario 2: Porting the Applicati<strong>on</strong> <strong>to</strong> Win32<br />

Java applicati<strong>on</strong>s can also be ported <strong>to</strong> run natively <strong>on</strong> the Windows plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m. As<br />

with interoperati<strong>on</strong>, few changes need <strong>to</strong> be made <strong>to</strong> the source code.<br />

Scenario 1: Interoperating Java <strong>on</strong> <strong>UNIX</strong> with<br />

<strong>SQL</strong> <strong>Server</strong><br />

Interoperati<strong>on</strong> between a <strong>UNIX</strong>-based Java applicati<strong>on</strong> and a <strong>SQL</strong> <strong>Server</strong> database is<br />

possible because of the availability of a driver that interfaces between these<br />

technologies. The JDBC driver provides the cross-RDBMS c<strong>on</strong>nectivity needed.<br />

Case 1: Interoperating a Java Applicati<strong>on</strong> Using the JDBC<br />

Driver<br />

Because of the c<strong>on</strong>structi<strong>on</strong> of the JDBC API, which exposes a comm<strong>on</strong> set of methods<br />

that are not affected by the change of source database, this type of migrati<strong>on</strong> is usually a<br />

simple process. Most changes made relate <strong>to</strong> the c<strong>on</strong>nectivity.<br />

To interoperate a Java applicati<strong>on</strong> using the existing JDBC driver, follow<br />

these steps:<br />

1. Evaluate the current driver.<br />

Be<str<strong>on</strong>g>for</str<strong>on</strong>g>e beginning the migrati<strong>on</strong> process, evaluate the existing JDBC driver that is in<br />

use and its capability <strong>to</strong> operate with <strong>SQL</strong> <strong>Server</strong>. Some c<strong>on</strong>siderati<strong>on</strong>s include:<br />

● Will the current JDBC driver interoperate with <strong>SQL</strong> <strong>Server</strong>? If this in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> is<br />

not known, check with the vendor. Sun Microsystems also maintains a<br />

database of <strong>SQL</strong> <strong>Server</strong> compliant JDBC drivers. For more in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong>, refer<br />

<strong>to</strong> http://servlet.java.sun.com/products/jdbc/drivers.<br />

● If the current JDBC driver will interoperate with <strong>SQL</strong> <strong>Server</strong>, what are the<br />

per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance characteristics of the driver in the <strong>SQL</strong> <strong>Server</strong> envir<strong>on</strong>ment?<br />

Try <strong>to</strong> per<str<strong>on</strong>g>for</str<strong>on</strong>g>m pro<strong>to</strong>type tests of the driver <strong>to</strong> ensure that the level of<br />

per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance is acceptable.<br />

● What features of the driver are utilized by the Java applicati<strong>on</strong>, and are<br />

these supported <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>SQL</strong> <strong>Server</strong>? For more in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <strong>on</strong> specific Java<br />

extensi<strong>on</strong>s used by your JDBC driver, refer <strong>to</strong> your vendor documentati<strong>on</strong>.<br />

● What type of JDBC driver is required (Type 1, 2, 3, 4)?<br />

If a new driver is needed, there are several different JDBC drivers<br />

commercially available. Each has slightly different features and characteristics.<br />

Some comm<strong>on</strong>ly used JDBC drivers include:<br />

● J<strong>SQL</strong>C<strong>on</strong>nect from J<strong>Net</strong>Direct, which is available at<br />

http://www.jnetdirect.com/products.php?op=jsqlc<strong>on</strong>nect.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 257<br />

●<br />

<strong>SQL</strong> <strong>Server</strong> 2000 Driver <str<strong>on</strong>g>for</str<strong>on</strong>g> JDBC. Microsoft offers this native driver which<br />

will work <strong>on</strong> both <strong>UNIX</strong> and Windows. This driver is available at<br />

http://www.microsoft.com/downloads/details.aspx?FamilyId=07287B11-<br />

0502-461A-B138-2AA54BFDC03A&displaylang=en.<br />

2. Determine how the applicati<strong>on</strong> c<strong>on</strong>nects <strong>to</strong> the data source. C<strong>on</strong>necti<strong>on</strong>s can be<br />

achieved using the DriverManager class or with a datasource implementati<strong>on</strong>.<br />

●<br />

If c<strong>on</strong>nectivity is obtained using the DriverManager class, two changes are<br />

needed <strong>to</strong> c<strong>on</strong>nect with the <strong>SQL</strong> <strong>Server</strong> database. These changes are:<br />

● Loading the JDBC driver<br />

● Making the c<strong>on</strong>necti<strong>on</strong><br />

The following example shows these changes:<br />

// Loading the driver<br />

Class.<str<strong>on</strong>g>for</str<strong>on</strong>g>Name("DriverClassName");<br />

// Making the C<strong>on</strong>necti<strong>on</strong><br />

String url = "jdbc:odbc:DSN";<br />

String user = "sUser";<br />

String password = "sPwd";<br />

C<strong>on</strong>necti<strong>on</strong> c<strong>on</strong> = DriverManager.getC<strong>on</strong>necti<strong>on</strong>(url, user, password);<br />

//……………<br />

//…………<br />

// Closing the C<strong>on</strong>necti<strong>on</strong><br />

c<strong>on</strong>.close();<br />

In this example code, the URL uses the syntax<br />

jdbc::. Using the c<strong>on</strong>necti<strong>on</strong> object c<strong>on</strong>, you can<br />

create JDBC statements and pass them <strong>to</strong> the RDBMS.<br />

●<br />

If c<strong>on</strong>nectivity is obtained through a datasource, the applicati<strong>on</strong> server should<br />

be appropriately c<strong>on</strong>figured.<br />

Be<str<strong>on</strong>g>for</str<strong>on</strong>g>e using a datasource object, it must be deployed. The following list<br />

describes the deployment steps:<br />

1. Create an instance of the DataSource class.<br />

2. Set the datasource properties.<br />

3. Register the datasource with a naming service that uses the Java Naming<br />

and Direc<strong>to</strong>ry Interface (JNDI) API.<br />

Datasource deployment is usually per<str<strong>on</strong>g>for</str<strong>on</strong>g>med by the system administra<strong>to</strong>r.<br />

A JDBC driver that supports JDBC 2.0 API will provide different types of<br />

datasource implementati<strong>on</strong>s which can be used <str<strong>on</strong>g>for</str<strong>on</strong>g> c<strong>on</strong>necti<strong>on</strong> pooling and<br />

distributed transacti<strong>on</strong>s.<br />

To obtain c<strong>on</strong>nectivity, the Java applicati<strong>on</strong> per<str<strong>on</strong>g>for</str<strong>on</strong>g>ms a lookup of the<br />

logicalName. This in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> can be retrieved by passing the user name<br />

and password through the getC<strong>on</strong>necti<strong>on</strong>() method. An example of this<br />

method is presented as follows:<br />

C<strong>on</strong>text ctx = new InitialC<strong>on</strong>text();<br />

DataSource ds = (DataSource)ctx.lookup("jdbc/db<strong>Server</strong>");<br />

C<strong>on</strong>necti<strong>on</strong> c<strong>on</strong> = ds.getC<strong>on</strong>necti<strong>on</strong>("sUser", "sPwd");<br />

3. C<strong>on</strong>figure the applicati<strong>on</strong> server.<br />

If third-party JDBC drivers are used <strong>to</strong> c<strong>on</strong>nect <strong>to</strong> <strong>SQL</strong> <strong>Server</strong>, the drivers must be<br />

set in the CLASSPATH variable so the driver classes can be loaded. The JDBC


258 Developing: Applicati<strong>on</strong>s — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> Java<br />

driver installed <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>SQL</strong> <strong>Server</strong> will install a driver jar file, which c<strong>on</strong>tains driver<br />

classes <str<strong>on</strong>g>for</str<strong>on</strong>g> the database interacti<strong>on</strong>. If the jar file is missing in the classpath, then<br />

the applicati<strong>on</strong> will flag a 'class not found' excepti<strong>on</strong>.<br />

Based <strong>on</strong> the applicati<strong>on</strong>'s architecture, the CLASSPATH must be set. The syntax<br />

of this setting can vary between applicati<strong>on</strong>s, servlets, JSPs, EJBs, and applets.<br />

a. For applicati<strong>on</strong>s run directly from the operating system prompt, make sure that<br />

the driver can be found in the system's CLASSPATH. This can be per<str<strong>on</strong>g>for</str<strong>on</strong>g>med<br />

by moving the file <strong>to</strong> its original locati<strong>on</strong>, which is already listed in the<br />

classpath, or adding the driver's current locati<strong>on</strong> <strong>to</strong> the CLASSPATH.<br />

b. For applicati<strong>on</strong>s run within the IDE, the driver classpath has <strong>to</strong> be set in the<br />

vendor's IDE classpath. Refer <strong>to</strong> your vendor’s IDE documentati<strong>on</strong>.<br />

c. For servlets and JSPs run within a servlet/JSP engine such as Tomcat, the<br />

classpath can be set in the vendor's classpath setup screens or by copying the<br />

driver jar file in<strong>to</strong> the LIB folder of the engine’s installati<strong>on</strong>.<br />

d. For EJBs, the JDBC driver jar file should also be set in the EJB vendor's<br />

classpath.<br />

e. For applets that run within a Web browser, copy the JDBC driver jar <strong>to</strong> the<br />

Web server root and specify the driver jar file in the applet’s HTML archive tab.<br />

The following HTML code example shows this opti<strong>on</strong> used <strong>on</strong> an applet tag.<br />

<br />

4. If the <strong>SQL</strong> statements passed <strong>to</strong> the JDBC methods use any <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>-specific<br />

syntax, then these items will need <strong>to</strong> be updated <strong>to</strong> reflect T-<strong>SQL</strong> syntax. Migrati<strong>on</strong><br />

of PL/<strong>SQL</strong> <strong>to</strong> T-<strong>SQL</strong> is covered in detail in Chapter 11, "Developing: Applicati<strong>on</strong>s<br />

— <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>SQL</strong> and PL/<strong>SQL</strong>."<br />

5. The metadata in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> returned by the metadata methods should refer <strong>to</strong><br />

<strong>SQL</strong> <strong>Server</strong> and the new JDBC Driver.<br />

To discover in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> about a database, a DatabaseMetaData object must be<br />

obtained. ResultSetMetaData provides in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> about the ResultSet, such as<br />

number of columns returned, an individual column's suggested display size,<br />

column names, and column types. If any of these metadata are used in the<br />

applicati<strong>on</strong>, they have <strong>to</strong> be validated <str<strong>on</strong>g>for</str<strong>on</strong>g> integrity of the return values.<br />

To discover in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> about a database, a DatabaseMetaData object must be<br />

obtained. The getMetaData method <strong>on</strong> the C<strong>on</strong>necti<strong>on</strong> object returns a<br />

DatabaseMetaData object.<br />

DatabaseMetaData dbmd = c<strong>on</strong>.getMetaData();<br />

ResultSetMetaData provides in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> about the ResultSet. Use the<br />

getMetaData method <strong>on</strong> the resultSet <strong>to</strong> get the ResultSetMetaData.<br />

ResultSetMetaData rsmd = rs.getMetaData();<br />

6. After the applicati<strong>on</strong> changes are complete, create a new release build and fully<br />

test the applicati<strong>on</strong>.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 259<br />

Scenario 2 —<br />

Porting the Applicati<strong>on</strong> <strong>to</strong> Win32<br />

Java is portable, so when the applicati<strong>on</strong> is migrated <strong>to</strong> Windows, the Java language<br />

features remain the same. Changes should be minimal. Most of the changes listed in the<br />

following procedure are similar <strong>to</strong> those per<str<strong>on</strong>g>for</str<strong>on</strong>g>med under the interoperati<strong>on</strong> scenario<br />

described in the "Scenario 1: Interoperating Java <strong>on</strong> <strong>UNIX</strong> with <strong>SQL</strong> <strong>Server</strong> " secti<strong>on</strong><br />

earlier in this chapter.<br />

To port the applicati<strong>on</strong> <strong>to</strong> Win32, follow these comm<strong>on</strong> steps:<br />

1. Install Java <strong>on</strong> the Windows server.<br />

If the migrati<strong>on</strong> path includes porting the Java applicati<strong>on</strong> <strong>to</strong> the Windows<br />

envir<strong>on</strong>ment, then the Java applicati<strong>on</strong> server should be installed <strong>on</strong> Windows.<br />

Ensure that the hardware satisfies the installati<strong>on</strong> prerequisites <str<strong>on</strong>g>for</str<strong>on</strong>g> the applicati<strong>on</strong><br />

server.<br />

2. Determine if the existing JDBC driver will per<str<strong>on</strong>g>for</str<strong>on</strong>g>m the needed functi<strong>on</strong>s, or if a new<br />

JDBC driver will be required.<br />

3. C<strong>on</strong>figure the applicati<strong>on</strong> server <str<strong>on</strong>g>for</str<strong>on</strong>g> use with Windows. Update the path and<br />

classpath in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong>.<br />

4. Test the installati<strong>on</strong> of the applicati<strong>on</strong> server using the test utility provided with the<br />

applicati<strong>on</strong> server.<br />

5. Determine how the applicati<strong>on</strong> c<strong>on</strong>nects <strong>to</strong> the data source.<br />

<strong>SQL</strong> <strong>Server</strong> has two types of authenticati<strong>on</strong>, Windows authenticati<strong>on</strong> and<br />

<strong>SQL</strong> <strong>Server</strong> authenticati<strong>on</strong>. When the applicati<strong>on</strong> exists <strong>on</strong> the <strong>UNIX</strong> plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m, the<br />

Windows authenticati<strong>on</strong> method is not possible without the installati<strong>on</strong> of additi<strong>on</strong>al<br />

software such as the Vintela Authenticati<strong>on</strong> Services (VAS) product from Vintela<br />

(http://www.vintela.com/products/vas/). However, with the applicati<strong>on</strong> migrated <strong>to</strong><br />

the Windows plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m, the Windows authenticati<strong>on</strong> feature of <strong>SQL</strong> <strong>Server</strong> can be<br />

taken advantage of.<br />

Windows authenticati<strong>on</strong> is specified using the c<strong>on</strong>necti<strong>on</strong> property<br />

trustedAuthenticati<strong>on</strong>. The property may be set in either a driver manager<br />

c<strong>on</strong>necti<strong>on</strong> string or a datasource. There is no need <strong>to</strong> specify the user and<br />

password properties when using trusted authenticati<strong>on</strong>.<br />

Windows authenticati<strong>on</strong> can be used by the JDBC clients <strong>on</strong> Windows <strong>on</strong>ly.<br />

6. Move the Java code from <strong>UNIX</strong> <strong>to</strong> Windows. All the files and folders which the<br />

Java applicati<strong>on</strong> interacts with should be migrated <strong>to</strong> Windows. Make sure that the<br />

paths in the Java applicati<strong>on</strong> and the c<strong>on</strong>figurati<strong>on</strong> files point <strong>to</strong> the corresp<strong>on</strong>ding<br />

folders in the Windows file system. If the Java applicati<strong>on</strong> uses any native code<br />

written in other languages, then that code also has <strong>to</strong> be migrated <strong>to</strong> Windows.<br />

7. <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>-specific <strong>SQL</strong> and s<strong>to</strong>red programs will need <strong>to</strong> be rewritten in T-<strong>SQL</strong><br />

syntax. Migrati<strong>on</strong> of PL/<strong>SQL</strong> <strong>to</strong> T-<strong>SQL</strong> is covered in detail in Chapter 11,<br />

"Developing: Applicati<strong>on</strong>s — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>SQL</strong> and PL/<strong>SQL</strong>."<br />

8. The metadata in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> returned by the metadata methods should refer <strong>to</strong><br />

<strong>SQL</strong> <strong>Server</strong> and the new JDBC Driver.<br />

9. After the applicati<strong>on</strong> changes are complete, create a new release build and fully<br />

test the applicati<strong>on</strong>.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 261<br />

15<br />

Developing: Applicati<strong>on</strong>s —<br />

<str<strong>on</strong>g>Migrating</str<strong>on</strong>g> Pyth<strong>on</strong><br />

Introducti<strong>on</strong> and Goals<br />

This chapter c<strong>on</strong>tains a detailed discussi<strong>on</strong> of changes that must be made <strong>to</strong> existing<br />

Pyth<strong>on</strong> applicati<strong>on</strong>s <strong>to</strong> work with Microsoft® <strong>SQL</strong> <strong>Server</strong>. At the c<strong>on</strong>clusi<strong>on</strong> of this<br />

chapter, the Pyth<strong>on</strong> applicati<strong>on</strong> should be capable <strong>to</strong> successfully c<strong>on</strong>nect <strong>to</strong> the<br />

<strong>SQL</strong> <strong>Server</strong> database that was migrated from <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>. The soluti<strong>on</strong> can then be tested.<br />

As discussed in the "Define the <str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> C<strong>on</strong>cept" secti<strong>on</strong> of Chapter 2, "Envisi<strong>on</strong>ing<br />

Phase," there are four different strategies available <str<strong>on</strong>g>for</str<strong>on</strong>g> transiti<strong>on</strong>ing applicati<strong>on</strong>s in an<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> migrati<strong>on</strong> project. The strategies are:<br />

● Interoperate the applicati<strong>on</strong> with <strong>UNIX</strong><br />

● Port or rewrite the applicati<strong>on</strong> <strong>to</strong> the Microsoft .NET plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m<br />

● Port or rewrite the applicati<strong>on</strong> <strong>to</strong> Microsoft Win32® Plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m<br />

● Quick port using the Microsoft Windows® Services <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>UNIX</strong> 3.5 plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m<br />

Pyt h<strong>on</strong> is a portable, plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m-independent, and general-purpose language with support<br />

<str<strong>on</strong>g>for</str<strong>on</strong>g> writing database client applicati<strong>on</strong>s. Database capabilities are modularized, and they<br />

can be augmented through the use of additi<strong>on</strong>al APIs.<br />

Pyth<strong>on</strong> database modules that are based <strong>on</strong> the Database API (DB-API) specificati<strong>on</strong><br />

can be used <strong>to</strong> access relati<strong>on</strong>al databases, including <strong>SQL</strong> <strong>Server</strong> and <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>. As l<strong>on</strong>g as<br />

the data base module used <strong>to</strong> access the <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> database adheres <strong>to</strong> the DB-API<br />

specificati<strong>on</strong>, porting <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> is straight<str<strong>on</strong>g>for</str<strong>on</strong>g>ward and can be d<strong>on</strong>e with minimal<br />

changes. If the existing database drivers do not meet DB-API specificati<strong>on</strong>s, the driver<br />

will need <strong>to</strong> be replaced and c<strong>on</strong>figured.<br />

Because of the cross-plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m capabilities and the use of modular database drivers,<br />

some of the migrati<strong>on</strong> strategies are more feasible than others. For example, because<br />

Pyth<strong>on</strong> can be ported <strong>to</strong> Windows, there is no need <strong>to</strong> rewrite the applicati<strong>on</strong> in the .NET<br />

framework or <str<strong>on</strong>g>for</str<strong>on</strong>g> the Win32 envir<strong>on</strong>ment. Also, because the applicati<strong>on</strong> can run within the<br />

Windows envir<strong>on</strong>ment, a quick port using Windows Services <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>UNIX</strong> is not necessary in<br />

most cases.<br />

Based <strong>on</strong> the available migrati<strong>on</strong> strategies, two scenarios can be developed <strong>to</strong> migrate<br />

the Pyth<strong>on</strong> applicati<strong>on</strong>. These scenarios include:


262 Developing: Applicati<strong>on</strong>s — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> Pyth<strong>on</strong><br />

●<br />

●<br />

Scenario 1: Interoperating Pyth<strong>on</strong> <strong>on</strong> <strong>UNIX</strong> with <strong>SQL</strong> <strong>Server</strong><br />

If the business requirements do not include eliminating the <strong>UNIX</strong> envir<strong>on</strong>ment, an<br />

interoperati<strong>on</strong> strategy can be implemented quickly. Few changes need <strong>to</strong> be<br />

made <strong>to</strong> the source code, and installing a new driver allows the Pyth<strong>on</strong> applicati<strong>on</strong><br />

<strong>to</strong> c<strong>on</strong>nect <strong>to</strong> a <strong>SQL</strong> <strong>Server</strong> database. Interoperati<strong>on</strong> can also be used as an<br />

interim step, if the migrati<strong>on</strong> is per<str<strong>on</strong>g>for</str<strong>on</strong>g>med in phases.<br />

Scenario 2: Port the Pyth<strong>on</strong> Applicati<strong>on</strong> <strong>to</strong> Win32<br />

Pyth<strong>on</strong> applicati<strong>on</strong>s can also be ported <strong>to</strong> run natively <strong>on</strong> the Windows plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m. As<br />

with interoperati<strong>on</strong>, few changes need <strong>to</strong> be made <strong>to</strong> the source code. These<br />

changes are usually related <strong>to</strong> c<strong>on</strong>nectivity issues.<br />

Note: If your Pyth<strong>on</strong> applicati<strong>on</strong>s use <strong>UNIX</strong> system calls extensively (such as<br />

frequently calling exec), porting them <strong>to</strong> Windows Services <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>UNIX</strong>/Interix may be a<br />

suitable opti<strong>on</strong> because Interix has more support <str<strong>on</strong>g>for</str<strong>on</strong>g> the desired system calls. Chapter<br />

2, " Envisi<strong>on</strong>ing Phase," provides a more detailed discussi<strong>on</strong> of when choosing<br />

Windows Services <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>UNIX</strong> would be more appropriate when moving <strong>to</strong> a Windowsbased<br />

plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m.<br />

You will need the following <strong>to</strong> implement this opti<strong>on</strong> (porting Pyth<strong>on</strong> applicati<strong>on</strong>s <strong>to</strong><br />

SFU/<strong>SQL</strong> <strong>Server</strong>):<br />

● A port of Pyth<strong>on</strong> <str<strong>on</strong>g>for</str<strong>on</strong>g> interix has been made available by Interop Systems and can<br />

be downloaded from http://www.interopsystems.com/<strong>to</strong>ols/warehouse.htm.<br />

● A c <strong>on</strong>nectivity driver <strong>to</strong> the <strong>SQL</strong> <strong>Server</strong> database. This is provided by the port of<br />

FreeTDS <strong>on</strong> Interix and is downloadable from Interop Systems at<br />

http://www.interopsystems .com/<strong>to</strong>ols/db.htm. FreeTDS provides two c<strong>on</strong>nectivity<br />

opti<strong>on</strong>s <str<strong>on</strong>g>for</str<strong>on</strong>g> the Pyth<strong>on</strong> applicati<strong>on</strong>s <strong>to</strong> c<strong>on</strong>nect <strong>to</strong> the <strong>SQL</strong> <strong>Server</strong> database. One is<br />

a library called CTlib, The other is an ODBC driver.<br />

● If you chose the CTLib opti<strong>on</strong> <str<strong>on</strong>g>for</str<strong>on</strong>g> your database c<strong>on</strong>nectivity driver, you will need<br />

the Sybase C<strong>on</strong>nectivity Module <str<strong>on</strong>g>for</str<strong>on</strong>g> your Pyth<strong>on</strong> applicati<strong>on</strong> <strong>to</strong> make appropriate<br />

calls <strong>to</strong> CTLib. The source code <str<strong>on</strong>g>for</str<strong>on</strong>g> this Sybase C<strong>on</strong>nectivity Module can obtain<br />

from Object Craft at http://www.object-craft.com.au/projects/sybase/ . This soluti<strong>on</strong><br />

is not available pre-compiled from Interop Systems but is a simple port <str<strong>on</strong>g>for</str<strong>on</strong>g> a <strong>UNIX</strong><br />

developer.<br />

● If you chose ODBC <str<strong>on</strong>g>for</str<strong>on</strong>g> your database c<strong>on</strong>nectivity, you will need an additi<strong>on</strong>al<br />

interface <str<strong>on</strong>g>for</str<strong>on</strong>g> the Pyth<strong>on</strong> applicati<strong>on</strong> <strong>to</strong> make ODBC calls. This is available as a<br />

commercial package called mxODBC and can be obtained from<br />

http://www.egenix.com.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 263<br />

● If you use the ODBC driver, you will also need an ODBC driver manager. Two<br />

different ODBC driver managers iODBC and unixODBC are available <str<strong>on</strong>g>for</str<strong>on</strong>g><br />

Windows Services <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>UNIX</strong> from<br />

http://www.interopsystems.com/<strong>to</strong>ols/warehouse.htm.<br />

This technology opti<strong>on</strong> (porting Pyth<strong>on</strong> applicati<strong>on</strong>s <strong>to</strong> SFU), however, has not been<br />

fully tested as a part of development of this soluti<strong>on</strong> and there<str<strong>on</strong>g>for</str<strong>on</strong>g>e has not been<br />

detailed further.<br />

Scenario 1: Interoperating Pyth<strong>on</strong> <strong>on</strong> <strong>UNIX</strong> with<br />

<strong>SQL</strong> <strong>Server</strong><br />

Two com m<strong>on</strong> modules used <str<strong>on</strong>g>for</str<strong>on</strong>g> c<strong>on</strong>necting a Pyth<strong>on</strong> applicati<strong>on</strong> <strong>to</strong> an <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> database in<br />

the <strong>UNIX</strong> envir<strong>on</strong>ment are:<br />

● DC<str<strong>on</strong>g>Oracle</str<strong>on</strong>g>2<br />

● mxODBC<br />

DC<str<strong>on</strong>g>Oracle</str<strong>on</strong>g>2 (http://www.zope.org/Products/DC<str<strong>on</strong>g>Oracle</str<strong>on</strong>g>/) does not support <strong>SQL</strong> <strong>Server</strong>, but<br />

mxODBC ( http://www.egenix.com/) supports the ODBC interface and can be used with<br />

<strong>SQL</strong> <strong>Server</strong>. If the existing applicati<strong>on</strong> uses DC<str<strong>on</strong>g>Oracle</str<strong>on</strong>g>2, this interface will need <strong>to</strong> be<br />

replaced <strong>to</strong> allow c<strong>on</strong>nectivity with <strong>SQL</strong> <strong>Server</strong>.<br />

Because ODBC is not database-specific, <strong>on</strong>ly minor modificati<strong>on</strong>s are needed <strong>to</strong> c<strong>on</strong>nect<br />

<strong>to</strong> the migrated database.<br />

Case 1: Interoperating Using the mxODBC Module<br />

To interoperate a Pyth<strong>on</strong>-based applicati<strong>on</strong> using DC<str<strong>on</strong>g>Oracle</str<strong>on</strong>g>2 module with<br />

<strong>SQL</strong> <strong>Server</strong>, follow these steps:<br />

Note that these steps assume that a DC<str<strong>on</strong>g>Oracle</str<strong>on</strong>g>2 module will be replaced with the mxODBC<br />

module.<br />

1. Install the ODBC driver.<br />

In order <str<strong>on</strong>g>for</str<strong>on</strong>g> mxODBC <strong>to</strong> c<strong>on</strong>nect <strong>to</strong> <strong>SQL</strong> <strong>Server</strong>, an ODBC driver manager must be<br />

installed. Two available driver managers are:<br />

● iODBC, available at http://www.iodbc.org/.<br />

● DataDirect ODBC <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>UNIX</strong> Plat<str<strong>on</strong>g>for</str<strong>on</strong>g>ms, available at<br />

http://www.datadirect.com/techz<strong>on</strong>e/use_case/odbc-unix-sqlservermain/index.ssp.<br />

For detailed installati<strong>on</strong> instructi<strong>on</strong>s, refer <strong>to</strong><br />

http://www.datadirect.com/techz<strong>on</strong>e/use_case/odbc-unix-sqlserverinstall/index.ssp.<br />

2. Install the mxODBC module based <strong>on</strong> the Pyth<strong>on</strong> versi<strong>on</strong> being used.<br />

For installati<strong>on</strong> instructi<strong>on</strong>s, refer <strong>to</strong> http://www.egenix.com/files/pyth<strong>on</strong>/mxODBC-<br />

Zope-DA.html#Installati<strong>on</strong>.<br />

3. C<strong>on</strong>figure the ODBC driver <strong>to</strong> work with mxODBC through the driver manager.<br />

4. Create a <strong>SQL</strong> <strong>Server</strong> data source.<br />

To functi<strong>on</strong>, ODBC needs a data source <strong>to</strong> c<strong>on</strong>nect <strong>to</strong> the database. The Data<br />

Source Name (DSN) is generally defined in an odbc.ini file that is used by the<br />

driver ma nager. The DSN is used by the driver manager <strong>to</strong> load the ODBC driver.<br />

iODBC offers a graphical user interface <strong>to</strong> set up the DSN. Complete instructi<strong>on</strong>s<br />

are available at http://www.iodbc.org/index.php?page=docs/odbcs<strong>to</strong>ry.


264 Developing: Applicati<strong>on</strong>s — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> Pyth<strong>on</strong><br />

The DSN can also be c<strong>on</strong>figured by manually modifying the odbc.ini file. The<br />

following example file uses a <strong>SQL</strong> <strong>Server</strong> DSN.<br />

[ODBC Data Sources]<br />

SS_ HR_DB=Sample MS <strong>SQL</strong><strong>Server</strong><br />

[SS_HR_DB]<br />

Driver=/opt/odbc/lib/mxODBC.so<br />

Descripti<strong>on</strong>=<strong>SQL</strong> <strong>Server</strong> 2000<br />

Database=hrapp<br />

Log<strong>on</strong>ID=daveb<br />

Password=cougar<br />

Address=win2kdbp1,1433<br />

5. Test the c<strong>on</strong>nectivity.<br />

iODBC c<strong>on</strong>tains a utility named odbctest which can be used <strong>to</strong> test DSN entries<br />

and interact with the database by c<strong>on</strong>necting and issuing queries directly without<br />

any code.<br />

The mxODBC package c<strong>on</strong>sists of a test script that can also be used <strong>to</strong> verify the<br />

database c<strong>on</strong>nectivity. To per<str<strong>on</strong>g>for</str<strong>on</strong>g>m the test, execute the following command:<br />

pyth<strong>on</strong> mx/ODBC/Misc/test.py<br />

6. Modify the applicati<strong>on</strong> <strong>to</strong> use mxODBC instead of the existing DC<str<strong>on</strong>g>Oracle</str<strong>on</strong>g>2 API.<br />

Note The examples in this secti<strong>on</strong> use the iODBC driver. Syntax may vary slightly<br />

based <strong>on</strong> the ODBC driver that is used in your soluti<strong>on</strong>.<br />

There are several, minor changes that may need <strong>to</strong> be made <strong>to</strong> the existing Pyth<strong>on</strong><br />

applicati<strong>on</strong> <strong>to</strong> allow c<strong>on</strong>nectivity with the <strong>SQL</strong> <strong>Server</strong> database. These comm<strong>on</strong><br />

issues that should be modified include:<br />

● Import statements<br />

The import statement, generally found at the head of the applicati<strong>on</strong> code,<br />

should be modified <strong>to</strong> include the new database module.<br />

If the applicati<strong>on</strong> currently uses the DC<str<strong>on</strong>g>Oracle</str<strong>on</strong>g>2 module, the import statement is<br />

as follows:<br />

●<br />

import DC<str<strong>on</strong>g>Oracle</str<strong>on</strong>g>2<br />

This entry should be modified <strong>to</strong> allow <str<strong>on</strong>g>for</str<strong>on</strong>g> the mxODBC module. The import<br />

statement should be changed as follows:<br />

import mx.ODBC.iODBC<br />

C<strong>on</strong>necti<strong>on</strong> objects<br />

The c<strong>on</strong>necti<strong>on</strong> object will also need <strong>to</strong> be modified <strong>to</strong> point <strong>to</strong> the new data<br />

source. The current entry should be similar <strong>to</strong> the following example:<br />

db = DC<str<strong>on</strong>g>Oracle</str<strong>on</strong>g>2.C<strong>on</strong>nect('scott/tiger@orahrdb')<br />

This entry should be modified <strong>to</strong> reflect the new data source. In the following<br />

example, the DriverC<strong>on</strong>nect() API is used <strong>to</strong> pass additi<strong>on</strong>al in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <strong>to</strong><br />

<strong>SQL</strong> <strong>Server</strong>.<br />

db = mx.ODBC.iODBC.DriverC<strong>on</strong>nect('DSN=sqlserverDSN;UID=scott;PWD=tiger')<br />

This iODBC string will have <strong>to</strong> be modified based <strong>on</strong> the driver manager in use.<br />

There are other c<strong>on</strong>necti<strong>on</strong> methods, such as ODBC() and c<strong>on</strong>nect(), which<br />

are also supported by mxODBC. The advantage with DriverC<strong>on</strong>nect() is that it<br />

allows more c<strong>on</strong>figurati<strong>on</strong> in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong>, such as the log file name, <strong>to</strong> be passed<br />

as part of the c<strong>on</strong>necti<strong>on</strong> string.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 265<br />

●<br />

Cursor Executi<strong>on</strong><br />

Change the cursor object execute() and executemany() method calls <strong>to</strong> use a<br />

questi<strong>on</strong> mark (?) <str<strong>on</strong>g>for</str<strong>on</strong>g> parameters instead of numeric parameters (:1) or named<br />

parameters (:column_name). The following example should be similar <strong>to</strong> your<br />

existing Pyth<strong>on</strong> code being used with <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>.<br />

c = db.cursor()<br />

custId = "ALFKI"<br />

c.execute("Select * from cus<strong>to</strong>mers where cus<strong>to</strong>merID = :1", custId)<br />

...<br />

id = "123"<br />

name = "Bill"<br />

desc = "CoffeeShop"<br />

●<br />

c.execute("insert in<strong>to</strong> categories " + \<br />

" (categoryid, categoryName, descripti<strong>on</strong>)" + \<br />

"values (:cid,:cname,:cdesc)" \<br />

,cid = id , cname = name ,cdesc= desc \<br />

)<br />

The code should be modified <str<strong>on</strong>g>for</str<strong>on</strong>g> use with <strong>SQL</strong> <strong>Server</strong>. In the following code,<br />

note that numeric and named parameters have been replaced.<br />

c= db.cursor()<br />

custId = "ALFKI"<br />

c.execute("Select * from cus<strong>to</strong>mers where cus<strong>to</strong>merID = ?",(custId,))<br />

...<br />

id = "123"<br />

name = "Bill"<br />

desc = "CoffeeShop"<br />

c.execute("insert in<strong>to</strong> categories" + \<br />

" (categoryid, categoryName, descripti<strong>on</strong>)" + \<br />

"values (?,?,?)" \<br />

,(id, name, desc) \<br />

)<br />

Cursors — multiple executi<strong>on</strong>s<br />

The executemany() functi<strong>on</strong> is used with DC<str<strong>on</strong>g>Oracle</str<strong>on</strong>g>2 <strong>to</strong> per<str<strong>on</strong>g>for</str<strong>on</strong>g>m multiple inserts<br />

with a single call by passing a list of parameters. For example,<br />

cursor.executemany("insert in<strong>to</strong> inven<strong>to</strong>ryinfo values (:1,:2)",\<br />

[('Bill','Dallas'),('Bob','Atlanta'),('David','Chicago'), \<br />

('Ann','Miami'),('Fin','Detroit'),('Paul','Dallas'),\<br />

('Scott','Dallas'),('Mike','Dallas'),('Leigh','Dallas')])<br />

For using multiple cursors <strong>on</strong> a c<strong>on</strong>necti<strong>on</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong>, use the<br />

setc<strong>on</strong>nec<strong>to</strong>pti<strong>on</strong>() method <strong>to</strong> set the <strong>SQL</strong>.CURSOR_TYPE <strong>to</strong><br />

<strong>SQL</strong>.CURSOR_DYNAMIC as shown as follows and replace the parameter<br />

specificati<strong>on</strong> style in the executemany() call:<br />

# C<strong>on</strong>nect <strong>to</strong> the database<br />

db = mx.ODBC.iODBC.DriverC<strong>on</strong>nect('DSN=sqlserverDSN;UID=scott;PWD=tiger'<br />

# Set <strong>SQL</strong> <strong>Server</strong> c<strong>on</strong>necti<strong>on</strong> opti<strong>on</strong><br />

DB.setc<strong>on</strong>nec<strong>to</strong>pti<strong>on</strong>(<strong>SQL</strong>.CURSOR_TYPE, <strong>SQL</strong>.CURSOR_DYNAMIC)<br />

cursor = db.cursor ()<br />

cursor.executemany("insert in<strong>to</strong> inven<strong>to</strong>ryinfo values (?,?)",\<br />

[('Bill','Dallas'),('Bob','Atlanta'),('David','Chicago'), \


266 Developing: Applicati<strong>on</strong>s — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> Pyth<strong>on</strong><br />

●<br />

('Ann','Miami'),('Fin','Detroit'),('Paul','Dallas'),\<br />

('Scott','Dallas'),('Mike','Dallas'),('Leigh','Dallas')])<br />

S<strong>to</strong>red Procedures<br />

The DB API 2.0 callProc() method <str<strong>on</strong>g>for</str<strong>on</strong>g> executing s<strong>to</strong>red procedures is not<br />

implemented in mxODBC. To overcome this deficiency, a s<strong>to</strong>red procedure<br />

can be executed similar <strong>to</strong> a <strong>SQL</strong> statement using <strong>on</strong>e of the execute methods.<br />

However, a requirement in this case is that the s<strong>to</strong>red procedure returns some<br />

result. All calls <strong>to</strong> callProc() need <strong>to</strong> change <strong>to</strong> use cursor.execute, as shown<br />

in the following example:<br />

c.execute("{call proc_name(?,?)}", (1,2)})<br />

7. Change all embedded <strong>SQL</strong> statements <strong>to</strong> T-<strong>SQL</strong>.<br />

This is a step comm<strong>on</strong> <strong>to</strong> all migrati<strong>on</strong>s. Refer <strong>to</strong> Chapter 11, "Developing:<br />

Applicati<strong>on</strong>s — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>SQL</strong> and PL/<strong>SQL</strong>," <str<strong>on</strong>g>for</str<strong>on</strong>g> a detailed discussi<strong>on</strong> <strong>on</strong><br />

modifying <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>SQL</strong> <strong>to</strong> be <strong>SQL</strong> <strong>Server</strong>-compliant.<br />

Scenario 2: Port the Pyth<strong>on</strong> Applicati<strong>on</strong> <strong>to</strong> Win32<br />

Because Pyth<strong>on</strong> is a cross-plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m language, porting applicati<strong>on</strong>s from a <strong>UNIX</strong><br />

envir<strong>on</strong>ment <strong>to</strong> Windows is not much more complex than the steps required <str<strong>on</strong>g>for</str<strong>on</strong>g><br />

interoperati<strong>on</strong>. The API used in the discussi<strong>on</strong> <strong>on</strong> porting <strong>to</strong> the Windows envir<strong>on</strong>ment is<br />

the mxODBC. The strategy, steps, and actual changes required are very similar <strong>to</strong> those<br />

discussed <str<strong>on</strong>g>for</str<strong>on</strong>g> interoperati<strong>on</strong>. Zope offers an ADO adapter <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> the<br />

Windows plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m which can give better per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance than the use of ODBC. Details <strong>on</strong><br />

this can be obtained from http://zope.org/Members/freiser/ZADODA.<br />

Case 1: Porting a Pyth<strong>on</strong> Applicati<strong>on</strong> using mxODBC<br />

Most of the following steps are covered in more detail in the "Case 1: Interoperating<br />

Using the mxODBC Module" secti<strong>on</strong> discussed in scenario 1.<br />

To port the applicati<strong>on</strong> <strong>to</strong> Windows, follow these steps:<br />

1. Download Pyth<strong>on</strong> <str<strong>on</strong>g>for</str<strong>on</strong>g> Windows from http://www.pyth<strong>on</strong>.org.<br />

2. Install Pyth<strong>on</strong> <strong>on</strong> Windows.<br />

3. Add the Pyth<strong>on</strong> folder <strong>to</strong> the Windows CLASSPATH envir<strong>on</strong>ment variable.<br />

4. Install the appropriate mxODBC <str<strong>on</strong>g>for</str<strong>on</strong>g> the versi<strong>on</strong> of Pyth<strong>on</strong> installed.<br />

5. Create an ODBC DSN <str<strong>on</strong>g>for</str<strong>on</strong>g> the target database.<br />

Create an ODBC data source <strong>to</strong> c<strong>on</strong>nect <strong>to</strong> <strong>SQL</strong> <strong>Server</strong>. After the DSN is created,<br />

a Pyth<strong>on</strong> applicati<strong>on</strong> using mxODBC can c<strong>on</strong>nect <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> and run queries.<br />

6. Transport source code <strong>to</strong> the target server.<br />

7. Update the applicati<strong>on</strong> code.<br />

If your applicati<strong>on</strong> uses DC<str<strong>on</strong>g>Oracle</str<strong>on</strong>g>2, then the applicati<strong>on</strong> changes required will be<br />

similar <strong>to</strong> those discussed in the "Scenario 1: Interoperating Pyth<strong>on</strong> <strong>on</strong> <strong>UNIX</strong> with<br />

<strong>SQL</strong> <strong>Server</strong>" secti<strong>on</strong> earlier in this chapter. Some variati<strong>on</strong>s based <strong>on</strong> the Windows<br />

envir<strong>on</strong>ment include the import statement and the c<strong>on</strong>necti<strong>on</strong> object as shown in<br />

the following examples.<br />

● The import statement should be changed from:<br />

import DC<str<strong>on</strong>g>Oracle</str<strong>on</strong>g>2<br />

<strong>to</strong><br />

import mx.ODBC.Windows


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 267<br />

●<br />

The c<strong>on</strong>necti<strong>on</strong> object must be initialized as in the following example:<br />

db = mx.ODBC.Windows.DriverC<strong>on</strong>nect('DSN=sqlserverDS')<br />

Note This DSN uses Windows Authenticati<strong>on</strong> Mode <strong>to</strong> c<strong>on</strong>nect <strong>to</strong> <strong>SQL</strong> <strong>Server</strong>.<br />

8. Change all embedded <strong>SQL</strong> statements <strong>to</strong> T-<strong>SQL</strong>.<br />

This is a step comm<strong>on</strong> <strong>to</strong> all migrati<strong>on</strong>s. Refer <strong>to</strong> Chapter 11, "Developing:<br />

Applicati<strong>on</strong>s— <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>SQL</strong> and PL/<strong>SQL</strong>" <str<strong>on</strong>g>for</str<strong>on</strong>g> a detailed discussi<strong>on</strong> <strong>on</strong><br />

modifying <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>SQL</strong> <strong>to</strong> be <strong>SQL</strong> <strong>Server</strong>-compliant.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 269<br />

16<br />

Developing: Applicati<strong>on</strong>s —<br />

<str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Pro*C<br />

Introducti<strong>on</strong> and Goals<br />

Thir d generati<strong>on</strong> languages (3GL) such as C and C++ do not have the capability <strong>to</strong><br />

interface with databases. Databases can <strong>on</strong>ly communicate using the <strong>SQL</strong> fourth<br />

generati<strong>on</strong> language (4GL). Using embedded <strong>SQL</strong> allows a database <strong>to</strong> interface directly<br />

with the 3GL languages. Pro*C is <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>'s proprietary interface <strong>to</strong> the C language which<br />

permits the use of embedded <strong>SQL</strong>.<br />

As discussed in the "Define the <str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> C<strong>on</strong>cept" secti<strong>on</strong> of Chapter 2, "Envisi<strong>on</strong>ing<br />

Phase," there are four different strategies available <str<strong>on</strong>g>for</str<strong>on</strong>g> transiti<strong>on</strong>ing applicati<strong>on</strong>s in an<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>to</strong> Microsoft® <strong>SQL</strong> <strong>Server</strong> migrati<strong>on</strong> project. The strategies are:<br />

● Interoperate the applicati<strong>on</strong> with <strong>UNIX</strong><br />

● Port or rewrite the applicati<strong>on</strong> <strong>to</strong> the Microsoft .NET plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m<br />

● Port or rewrite the applicati<strong>on</strong> <strong>to</strong> the Microsoft Win32® plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m<br />

● Quick port using the Microsoft Windows® Services <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>UNIX</strong> 3.5 plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m<br />

Because Pro*C is specific <strong>to</strong> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>, migrati<strong>on</strong> strategies are limited. Interoperati<strong>on</strong> and<br />

porting cannot be utilized because no methods exist that allow Pro*C <strong>to</strong> communicate<br />

with <strong>SQL</strong> <strong>Server</strong>. A complete rewrite is the <strong>on</strong>ly opti<strong>on</strong>.<br />

This chapter focuses <strong>on</strong> the preferred scenario that can be used in Pro*C applicati<strong>on</strong><br />

migrati<strong>on</strong>s: Scenario 1: Rewriting the applicati<strong>on</strong> <strong>to</strong> the .NET plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m.<br />

Rewriting an applicati<strong>on</strong> is a challenging endeavor because a <strong>on</strong>e-<strong>to</strong>-<strong>on</strong>e mapping from<br />

the source envir<strong>on</strong>ment <strong>to</strong> the target envir<strong>on</strong>ment is very difficult <strong>to</strong> achieve. When an<br />

applicati<strong>on</strong> is rewritten, there is always a risk that some functi<strong>on</strong>ality from the original<br />

applicati<strong>on</strong> may be lost during the transiti<strong>on</strong>. Comm<strong>on</strong>ly, Pro*C programs are procedural<br />

and do not have a graphical user interface. <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> procedural code is easier than<br />

migrating GUI-based applicati<strong>on</strong>s. Extensive testing needs <strong>to</strong> be per<str<strong>on</strong>g>for</str<strong>on</strong>g>med <strong>on</strong> the<br />

rewritten applicati<strong>on</strong> <strong>to</strong> ensure that all of the business logic and functi<strong>on</strong>ality has<br />

accurately been recreated.<br />

This chapter <strong>on</strong>ly discusses the trans<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> that needs <strong>to</strong> occur <strong>to</strong> the most comm<strong>on</strong><br />

database-related comp<strong>on</strong>ents when rewriting a Pro*C applicati<strong>on</strong> <str<strong>on</strong>g>for</str<strong>on</strong>g> the .NET<br />

envir<strong>on</strong>ment. A comprehensive study of the entire rewrite is bey<strong>on</strong>d the scope of this<br />

guidance.


270 Developing: Applicati<strong>on</strong>s — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Pro*C<br />

Understanding the Technology<br />

Pro*C is available <strong>on</strong> the Windows plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m. Un<str<strong>on</strong>g>for</str<strong>on</strong>g>tunately, there are no methods<br />

available <strong>to</strong> allow Pro*C code <strong>to</strong> interface with <strong>SQL</strong> <strong>Server</strong>. Microsoft offers a product<br />

similar <strong>to</strong> Pro*C called Embedded <strong>SQL</strong> <str<strong>on</strong>g>for</str<strong>on</strong>g> C (E<strong>SQL</strong>/ C) which allows Transact-<strong>SQL</strong><br />

statements <strong>to</strong> be embedded in C language programs. E<strong>SQL</strong>/C can be used as the target<br />

language <str<strong>on</strong>g>for</str<strong>on</strong>g> rewriting Pro*C programs because of its close resemblance <strong>to</strong> Pro*C.<br />

However, using this language is not recommended because Microsoft no l<strong>on</strong>ger develops<br />

this product, and future versi<strong>on</strong>s of <strong>SQL</strong> <strong>Server</strong> will not support E<strong>SQL</strong>/C.<br />

Visual Basic .NET is recommended <str<strong>on</strong>g>for</str<strong>on</strong>g> rewriting the applicati<strong>on</strong>. Visual Basic .NET<br />

provides a robust scripting language and can easily be interfaced with <strong>SQL</strong> <strong>Server</strong>.<br />

When migrating the database from <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong>, the Pro* C code and its<br />

interacti<strong>on</strong>s with <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> should be examined <strong>to</strong> ensure that the functi<strong>on</strong>s can be<br />

recreated in the rewritten applicati<strong>on</strong>.<br />

Understanding Pro*C<br />

Be<str<strong>on</strong>g>for</str<strong>on</strong>g>e the applicati<strong>on</strong> can be rewritten, you must evaluate the functi<strong>on</strong>ality currently<br />

provided by the Pro*C applicati<strong>on</strong>. While the computati<strong>on</strong>al and business logic is<br />

provided by the host C language, Pro*C provides the syntax <strong>to</strong> implement the database<br />

transacti<strong>on</strong>s. The embedded <strong>SQL</strong> in Pro*C offers the following functi<strong>on</strong>ality that will have<br />

<strong>to</strong> be migrated:<br />

● C<strong>on</strong>nect <strong>to</strong> and maintain a c<strong>on</strong>necti<strong>on</strong> <strong>to</strong> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> database.<br />

● Declare, open, and use cursors <strong>to</strong> manipulate data.<br />

● Interact with <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> databases through <strong>SQL</strong> statements.<br />

● Provide mechanisms (host variables) <strong>to</strong> interface between the host code and the<br />

database code.<br />

● Close any open cursors.<br />

● Handle any database excepti<strong>on</strong>s.<br />

● Close the c<strong>on</strong>necti<strong>on</strong> <strong>to</strong> the database.<br />

Each of these functi<strong>on</strong>s will need <strong>to</strong> be recreated in the new applicati<strong>on</strong>. Pro*C is mostly<br />

used as an imperative programming language and is used <str<strong>on</strong>g>for</str<strong>on</strong>g> c<strong>on</strong>structing programs<br />

which involve computati<strong>on</strong>. The target programming envir<strong>on</strong>ment should have<br />

programming capabilities and features that are similar <strong>to</strong> those of C/C++ and also<br />

interface with <strong>SQL</strong> <strong>Server</strong> <str<strong>on</strong>g>for</str<strong>on</strong>g> retrieving and manipulating data. The GUI capabilities will<br />

not be discussed in this guide.<br />

Understanding .NET and ADO.NET<br />

The Microsoft .NET Framework provides a programming infrastructure <str<strong>on</strong>g>for</str<strong>on</strong>g> building,<br />

deploying, and operating applicati<strong>on</strong>s and services. When working with databases,<br />

ADO.NET is a key comp<strong>on</strong>ent.<br />

ADO.NET is a set of libraries included with the Microsoft .NET Framework that enables<br />

communicati<strong>on</strong> with various data s<strong>to</strong>res from .NET applicati<strong>on</strong>s. The ADO.NET libraries<br />

include classes <str<strong>on</strong>g>for</str<strong>on</strong>g> c<strong>on</strong>necting <strong>to</strong> a data source, submitting queries, and processing<br />

results. ADO.NET provides the <strong>to</strong>ols <strong>to</strong> efficiently implement data access and<br />

functi<strong>on</strong>ality provided by Pro*C. Data access in ADO.NET relies <strong>on</strong> the following two<br />

entities:<br />

● DataSet


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 271<br />

●<br />

Data provider<br />

DataSet<br />

The DataSet is a copy of the data retrieved from the database cached in memory. Data<br />

can be loaded in<strong>to</strong> a DataSet from any valid data source, such as a <strong>SQL</strong> <strong>Server</strong><br />

database, or an XML file. The DataSet persists in memory, and the data therein can be<br />

manipulated and updated independent of the database. When appropriate, the DataSet<br />

can then be used <str<strong>on</strong>g>for</str<strong>on</strong>g> updating the database.<br />

Data Provider<br />

A data provider <str<strong>on</strong>g>for</str<strong>on</strong>g>ms the link between the Visual Basic .NET program and the database.<br />

A data provider is not a single comp<strong>on</strong>ent; rather it is a set of related comp<strong>on</strong>ents that<br />

work <strong>to</strong>gether <strong>to</strong> provide data in an efficient, per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance-driven manner.<br />

Two data providers are available <str<strong>on</strong>g>for</str<strong>on</strong>g> Visual Basic .NET. The <strong>SQL</strong> <strong>Server</strong> Data Provider is<br />

designed specifically <strong>to</strong> work with <strong>SQL</strong> <strong>Server</strong> 7 or later, and the OLE DB Data Provider,<br />

which can also c<strong>on</strong>nect <strong>to</strong> other types of databases. Each data provider c<strong>on</strong>sists of<br />

versi<strong>on</strong>s of the following generic comp<strong>on</strong>ent classes:<br />

● The C<strong>on</strong>necti<strong>on</strong> object provides the c<strong>on</strong>necti<strong>on</strong> <strong>to</strong> the database.<br />

● The Command object executes a command against a data source. It can execute<br />

n<strong>on</strong>-query commands, such as INSERT, UPDATE, or DELETE, or return a<br />

DataReader with the results of a SELECT command.<br />

● The DataReader object provides a <str<strong>on</strong>g>for</str<strong>on</strong>g>ward-<strong>on</strong>ly, read-<strong>on</strong>ly, c<strong>on</strong>nected recordset.<br />

● The DataAdapter object populates a disc<strong>on</strong>nected DataSet or DataTable with data<br />

and per<str<strong>on</strong>g>for</str<strong>on</strong>g>ms updates.<br />

The following classes are also offered: Transacti<strong>on</strong>, CommandBuilder, Parameter,<br />

Excepti<strong>on</strong>, Error, and ClientPermissi<strong>on</strong>.<br />

For more in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <strong>on</strong> data provider comp<strong>on</strong>ents, refer <strong>to</strong><br />

http://msdn.microsoft.com/library/default.asp?url=/library/en-<br />

us/cpguide/html/cpc<strong>on</strong>usingad<strong>on</strong>etproviders<strong>to</strong>a ccessdata.asp.<br />

Even though the syntax and use of the functi<strong>on</strong>s differ, ADO.NET provides equivalent<br />

database functi<strong>on</strong>s <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>SQL</strong> <strong>Server</strong>. It is important <strong>to</strong> ensure that these functi<strong>on</strong>s are<br />

translated <strong>to</strong> the new envir<strong>on</strong>ment during the rewriting process.<br />

Scenario 1: Rewriting Pro*C <strong>to</strong> the .NET Plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m<br />

Rewriting the applicati<strong>on</strong> <str<strong>on</strong>g>for</str<strong>on</strong>g> Windows makes use of native <strong>SQL</strong> <strong>Server</strong> APIs, ADO.NET,<br />

Microsoft ActiveX Data Objects (ADO), or Open Database C<strong>on</strong>nectivity (ODBC) running<br />

natively in the Windows subsystem. Rewriting the applicati<strong>on</strong> can result in a more stable<br />

and integrated c<strong>on</strong>figurati<strong>on</strong> after the project is complete.<br />

Case 1: Rewrite the Applicati<strong>on</strong> using Visual Basic.NET<br />

Visual Basic.NET provides all the functi<strong>on</strong>ality of the C programming language as well as<br />

several interfaces <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> databases <strong>to</strong> execute <strong>SQL</strong> statements. This scenario<br />

describes how <strong>to</strong> rewrite a Pro*C applicati<strong>on</strong> with Visual Basic .NET.<br />

The figure that follows shows a graphical representati<strong>on</strong> of how<br />

the Pro*C code will<br />

migrate over <strong>to</strong> Visual Basic .NET during the rewrite.


272 Developing: Applicati<strong>on</strong>s — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Pro*C<br />

Figure 16.1<br />

Database access in Pro*C and Visual Basic .NET<br />

Each functi<strong>on</strong> that currently resides in Pro*C code will need <strong>to</strong> be rewritten, from the user<br />

interface <strong>to</strong> the database c<strong>on</strong>necti<strong>on</strong>. There are two opti<strong>on</strong>s available <strong>to</strong> c<strong>on</strong>nect <strong>to</strong> the<br />

<strong>SQL</strong> <strong>Server</strong> data source from the .NET framework.<br />

These opti<strong>on</strong>s are:<br />

● The <strong>SQL</strong> <strong>Server</strong> .NET Data Provider is implemented in the <strong>SQL</strong>Client namespace.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 273<br />

● The OLE DB provider is in the OLE DB namespace. There are OLE DB providers<br />

<str<strong>on</strong>g>for</str<strong>on</strong>g> both <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong>.<br />

To rewrite an applicati<strong>on</strong> using Visual Basic .NET, follow these steps:<br />

For more in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <strong>on</strong> data access services available with ADO.NET, refer <strong>to</strong><br />

http://msdn.microsoft.com/library/default.asp?url=/library/enus/cpguide/html/cpc<strong>on</strong>accessingdatawithad<strong>on</strong>et.asp.<br />

The examples used in these procedures are based <strong>on</strong> <strong>SQL</strong> <strong>Server</strong> .NET DataProvider and<br />

DataReader objects. If an OLE DB provider is used, there may be slight variati<strong>on</strong>s <strong>to</strong> the<br />

following steps.<br />

1. Install the .NET Framework SDK and redistributi<strong>on</strong>. The SDK c<strong>on</strong>tains the<br />

reso urces <str<strong>on</strong>g>for</str<strong>on</strong>g> building, testing, and deploying .NET Framework applicati<strong>on</strong>s. For<br />

access <strong>to</strong> the latest SDK, refer <strong>to</strong><br />

http://msdn.microsoft.com/netfram ework/downloads/updates/default.aspx.<br />

The Microsoft Visual Basic .NET software is required <str<strong>on</strong>g>for</str<strong>on</strong>g> programming the<br />

applicati<strong>on</strong>. For more in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong>, refer <strong>to</strong><br />

http ://www.microsoft.com/downloads/details.aspx?FamilyID=dd6ec730-fd9a-4e36-<br />

8552-8accc4cd8fb3&DisplayLang=en.<br />

At t his point, it is assumed that you have all the comp<strong>on</strong>ents in place <strong>to</strong> write a VB<br />

.NET applicati<strong>on</strong> using the <strong>SQL</strong> <strong>Server</strong> .NET DataProvider. It is also assumed that<br />

the migrated <strong>SQL</strong> <strong>Server</strong> database is in place.<br />

For access <strong>to</strong> several references <str<strong>on</strong>g>for</str<strong>on</strong>g> creating Windows <str<strong>on</strong>g>for</str<strong>on</strong>g>ms applicati<strong>on</strong>s, refer <strong>to</strong><br />

http://msdn.microsoft.com/library/default.asp?url=/library/en-<br />

us/cpguide/html/cpc<strong>on</strong>CreatingWindowsFormsApplicat i<strong>on</strong>s.asp.<br />

2. Rewrite c<strong>on</strong>nectivity statements within applicati<strong>on</strong> code.<br />

● In Pro*C, database open and close statements are similar <strong>to</strong> the following<br />

example:<br />

/* assign username and password <strong>to</strong> host variables */<br />

strcpy(username.arr,"SCOTT");<br />

username.len=strlen(username.arr);<br />

strcpy(password.arr,"TIGER");<br />

password.len=strlen(password.arr);<br />

/* execute c<strong>on</strong>nect statement */<br />

EXEC <strong>SQL</strong> CONNECT :username IDENTIFIED BY :password;<br />

●<br />

/* execute close statements */<br />

EXEC <strong>SQL</strong> COMMIT WORK RELEASE;<br />

These same functi<strong>on</strong>s can be recreated using ADO.NET. Here are examples<br />

of the same functi<strong>on</strong>s as written <str<strong>on</strong>g>for</str<strong>on</strong>g> .NET.<br />

' declare a c<strong>on</strong>necti<strong>on</strong> object<br />

Dim cn As New SqlC<strong>on</strong>necti<strong>on</strong><br />

' define a c<strong>on</strong>necti<strong>on</strong> string<br />

Dim strC<strong>on</strong>n As String<br />

'This is the c<strong>on</strong>necti<strong>on</strong> string<br />

strC<strong>on</strong>n = "Data Source=(local)\DataSourceName;" & _<br />

"Initial Catalog=databaseName;" & _<br />

"Trusted_C<strong>on</strong>necti<strong>on</strong>=Yes;"<br />

' instantiate c<strong>on</strong>necti<strong>on</strong> object


274 Developing: Applicati<strong>on</strong>s — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Pro*C<br />

cn = SqlC<strong>on</strong>necti<strong>on</strong>(strC<strong>on</strong>n)<br />

' open c<strong>on</strong>necti<strong>on</strong>s<br />

cn.Open()<br />

' close c<strong>on</strong>necti<strong>on</strong>s<br />

cn.Close()<br />

For more details <strong>on</strong> SqlC<strong>on</strong>necti<strong>on</strong>, refer <strong>to</strong><br />

http://msdn.microsoft.com/library/default.asp?url=/library/enus/cpref/html/frlrfsystemdatasqlclientsqlc<strong>on</strong>necti<strong>on</strong>class<strong>to</strong>pic.asp<br />

3. Rewrite the queries and cursor functi<strong>on</strong>s.<br />

Pro*C uses embedded <strong>SQL</strong> <strong>to</strong> s<strong>to</strong>re the output of a query statement in a cursor<br />

from which rows can be fetched. Visual Basic.NET does not support cursors;<br />

instead, it uses several other methods <str<strong>on</strong>g>for</str<strong>on</strong>g> retrieving data sets from <strong>SQL</strong> queries.<br />

One of these data retrieval methods is the DataReader object, which is a<br />

ligh tweight object that is read-<strong>on</strong>ly and, hence, ideal <str<strong>on</strong>g>for</str<strong>on</strong>g> queries. The following link<br />

provides access <strong>to</strong> more in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <strong>on</strong> retrieving data using DataReader object:<br />

http://msdn.microsoft.com/library/default.asp?url=/library/en-<br />

us/cpguide/html/cpc<strong>on</strong>thead<strong>on</strong>etdatareader.asp.<br />

● Here are some comm<strong>on</strong> cursor operati<strong>on</strong>s encountered in Pro*C applicati<strong>on</strong>s:<br />

Defining a cursor:<br />

●<br />

EXEC <strong>SQL</strong> DECLARE cust_cursor FOR<br />

SELECT Cus<strong>to</strong>merID, CompanyName FROM Cus<strong>to</strong>mers;<br />

Opening the cursor:<br />

EXEC <strong>SQL</strong> OPEN cust_cursor;<br />

Fetching rows using the cursor:<br />

<str<strong>on</strong>g>for</str<strong>on</strong>g> (;;){<br />

EXEC <strong>SQL</strong> WHENEVER NOT FOUND DO break;<br />

EXEC <strong>SQL</strong> FETCH cust_cursor INTO :cus<strong>to</strong>merid, :companyname;<br />

printf("Cus<strong>to</strong>merID: %s – CompanyName: %s\n", cus<strong>to</strong>merid,<br />

companyname);<br />

}<br />

Closing the cursor:<br />

EXEC <strong>SQL</strong> CLOSE cust_cursor;<br />

Although <strong>SQL</strong> <strong>Server</strong> does not support cursors, equivalent functi<strong>on</strong>s can be<br />

created using ADO.NET:<br />

Defining the query:<br />

str<strong>SQL</strong> = "SELECT Cus<strong>to</strong>merID, CompanyName FROM Cus<strong>to</strong>mers"<br />

Creating a command object:<br />

Dim cmd As New SqlCommand(str<strong>SQL</strong>, cn)<br />

Creating a data reader object:<br />

Dim rdr As SqlDataReader = cmd.ExecuteReader()<br />

Displaying the data reader result set:<br />

While rdr.Read()<br />

C<strong>on</strong>sole.WriteLine(rdr("Cus<strong>to</strong>merID") & " – " & rdr("CompanyName"))<br />

End While<br />

Do While rdr.Read()<br />

C<strong>on</strong>sole.WriteLine(rdr.GetInt32(0) & " " & _<br />

“ rdr.GetString(1) & " " & rdr.GetFloat(2))


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 275<br />

For more in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <strong>on</strong> implementing a DataReader, refer <strong>to</strong><br />

http://msdn.microsoft.com/library/default.asp?url=/library/en-<br />

us/cpguide/html/cpc<strong>on</strong>implementingdatareader.asp.<br />

4. Rewrite the embedded DML statements<br />

The embedded DML is used <strong>to</strong> insert, update, and delete data. The SqlCommand<br />

object can be used <strong>to</strong> per<str<strong>on</strong>g>for</str<strong>on</strong>g>m these <strong>SQL</strong> operati<strong>on</strong>s. The DataAdapter and<br />

DataSet objects are required <str<strong>on</strong>g>for</str<strong>on</strong>g> executing DML and s<strong>to</strong>red procedures. Migrati<strong>on</strong><br />

of these operati<strong>on</strong>s is shown in the following examples:<br />

● The DML operati<strong>on</strong>s using Pro*C:<br />

Executing an INSERT DML statement:<br />

Loop<br />

Closing the data reader object:<br />

rdr.Close()<br />

●<br />

EXEC <strong>SQL</strong> INSERT INTO Cus<strong>to</strong>mer VALUES (:newcompanyname, :cus<strong>to</strong>merid);<br />

Executing an UPDATE DML statement:<br />

EXEC <strong>SQL</strong> UPDATE Cus<strong>to</strong>mer<br />

SET CompanyName = :newcompanyname<br />

WHERE Cus<strong>to</strong>merID = 'ACME';<br />

Executing a DELETE DML statement:<br />

EXEC <strong>SQL</strong> DELETE FROM Cus<strong>to</strong>mer<br />

WHERE Cus<strong>to</strong>merID = 'ACME';<br />

For each of the DML operati<strong>on</strong>s shown, the equivalent operati<strong>on</strong>s can be<br />

per<str<strong>on</strong>g>for</str<strong>on</strong>g>med using ADO.NET:<br />

Executing an INSERT DML statement:<br />

Dim str<strong>SQL</strong> As String<br />

str<strong>SQL</strong> = " INSERT INTO Cus<strong>to</strong>mer VALUES " & _<br />

" (@newcompanyname,@cus<strong>to</strong>merid)"<br />

Dim cmd As New SqlCommand(str<strong>SQL</strong>, cn)<br />

Dim param1, param2 As SqlParameter<br />

Param1 = cmd.Parameters.Add("@newcompanyname",<br />

SqlDbType.VarChar, 10)<br />

Param2 = cmd.Parameters.Add("@cus<strong>to</strong>merid", SqlDbType.NChar, 5)<br />

Param1.Value = ”COMPANY1"<br />

Param1.Value = "VALUE1"<br />

cmd.ExecuteN<strong>on</strong>Query()<br />

Executing an UPDATE DML statement:<br />

Dim str<strong>SQL</strong> As String<br />

str<strong>SQL</strong> = "UPDATE Cus<strong>to</strong>mer SET CompanyName = @newcompanyname " & _<br />

"WHERE Cus<strong>to</strong>merID = 'ACME'"<br />

Dim cmd As New SqlCommand(str<strong>SQL</strong>, cn)<br />

Dim param1 As SqlParameter<br />

Param1 = cmd.Parameters.Add("@newcompanyname", SqlDbType.VarChar, 10)<br />

Param1.Value = "NewName"<br />

Dim InsertRecordsAffected As Integer = cmd.ExecuteN<strong>on</strong>Query()<br />

Executing a DELETE DML statement:<br />

Dim str<strong>SQL</strong> As String<br />

str<strong>SQL</strong> = " DELETE FROM Cus<strong>to</strong>mer WHERE Cus<strong>to</strong>merID = 'ACME'"<br />

Dim cmd As New SqlCommand(str<strong>SQL</strong>, cn)<br />

Dim InsertRecordsAffected As Integer = cmd.ExecuteN<strong>on</strong>Query()


276 Developing: Applicati<strong>on</strong>s — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Pro*C<br />

5. Rewrite Transacti<strong>on</strong> Management operati<strong>on</strong>s<br />

●<br />

The Transacti<strong>on</strong> Management operati<strong>on</strong>s in Pro*C are:<br />

Beginning a transacti<strong>on</strong>:<br />

EXEC <strong>SQL</strong> SET TRANSACTION READ ONLY;<br />

Committing a transacti<strong>on</strong>:<br />

EXEC <strong>SQL</strong> COMMIT WORK RELEASE;<br />

Setting a savepoint:<br />

EXEC <strong>SQL</strong> SAVEPOINT save_point;<br />

Rollback a transacti<strong>on</strong>:<br />

EXEC <strong>SQL</strong> ROLLBACK WORK RELEASE;<br />

Rollback <strong>to</strong> a savepoint:<br />

EXEC <strong>SQL</strong> ROLLBACK TO SAVEPOINT save_point;<br />

● Transacti<strong>on</strong> Management in ADO.NET<br />

Changes are made through the DataSet object. The Update method is used <str<strong>on</strong>g>for</str<strong>on</strong>g><br />

copying the changes made <strong>to</strong> the dataset back <strong>to</strong> the database which implicitly<br />

commits the changes.<br />

6. Rewrite calls <strong>to</strong> s<strong>to</strong>red procedures.<br />

● S<strong>to</strong>red procedures are executed in Pro*C using the syntax shown in the<br />

following example. In this example, the host variables represent IN or OUT<br />

parameters.<br />

EXEC <strong>SQL</strong> EXECUTE<br />

●<br />

BEGIN<br />

GET_ROOM_DETAILS(:HotelId, :RoomType, :AvailableRooms,<br />

:StandardRate);<br />

END;<br />

END-EXEC;<br />

S<strong>to</strong>red procedure calls in ADO.NET: SqlCommand objects can be used <strong>to</strong> call<br />

<strong>SQL</strong> <strong>Server</strong> and MSDE s<strong>to</strong>red procedures. The SqlCommand object exposes<br />

a CommandType property that can be used <strong>to</strong> help simplify the code <strong>to</strong> call<br />

s<strong>to</strong>red procedures. Set SqlCommand object’s CommandText property <strong>to</strong> the<br />

s<strong>to</strong>red procedure name, and the CommandType property <strong>to</strong> S<strong>to</strong>redProcedure,<br />

and then call the s<strong>to</strong>red procedure, as shown in the following code:<br />

Dim strC<strong>on</strong>n As String<br />

strC<strong>on</strong>n = "Data Source=(local)\<strong>Net</strong>SDK;Initial Catalog=Northwind;" & _<br />

"Trusted_C<strong>on</strong>necti<strong>on</strong>=Yes;"<br />

Dim cn As New SqlC<strong>on</strong>necti<strong>on</strong>(strC<strong>on</strong>n)<br />

Dim cmd As New SqlCommand("GET_ROOM_DETAILS", cn)<br />

cmd.CommandType = CommandType.S<strong>to</strong>redProcedure<br />

Dim param As SqlParameter<br />

param = cmd.Parameters.Add("@HotelId", SqlDbType.NChar, 5)<br />

param.Value = "HOTEL1"<br />

………<br />

………<br />

cn.Open()<br />

Dim rdr As SqlDataReader = cmd.ExecuteReader()<br />

Do While rdr.Read()<br />

C<strong>on</strong>sole.WriteLine(rdr("OrderID"))<br />

…………<br />

Loop


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 277<br />

rdr.Close()<br />

A more detailed discussi<strong>on</strong> <strong>on</strong> using s<strong>to</strong>red procedures in Visual Basic.NET is<br />

available at http://msdn.microsoft.com/library/default.asp?url=/library/enus/dnadvnet/html/vbnet09102002.asp.<br />

7. Rewrite excepti<strong>on</strong> handling.<br />

●<br />

●<br />

There are two ways <strong>to</strong> handle <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> errors in Pro*C:<br />

●<br />

●<br />

<strong>SQL</strong><br />

EXEC<br />

embedded statements. The syntax is:<br />

<strong>SQL</strong> WHENEVER [c<strong>on</strong>diti<strong>on</strong>] [acti<strong>on</strong>];<br />

Checking error codes in <strong>SQL</strong>CA<br />

The generic syntax is<br />

if ( sqlca.sqlcode == [a value i.e., -1] )<br />

{<br />

Handler code<br />

}<br />

Excepti<strong>on</strong> handling in Visual Basic .NET<br />

Use a Try block <strong>to</strong> add excepti<strong>on</strong> handling <strong>to</strong> a block of code. Add Catch<br />

blocks, as necessary, <strong>to</strong> trap individual excepti<strong>on</strong>s. The .NET runtime handles<br />

Catch blocks in order, looking <str<strong>on</strong>g>for</str<strong>on</strong>g> an "is a" match against the current excepti<strong>on</strong>.<br />

It uses the first block it finds that matches. You can nest Try blocks, making it<br />

easy <strong>to</strong> effectively push and pop excepti<strong>on</strong>-handling states. Add a Finally block<br />

<strong>to</strong> your Try block <strong>to</strong> run code unc<strong>on</strong>diti<strong>on</strong>ally, regardless of whether an error<br />

occurs or not.<br />

You can create your own excepti<strong>on</strong> classes that inherit from the base<br />

excepti<strong>on</strong> class (or any class that inherits from that class) <strong>to</strong> add your own<br />

functi<strong>on</strong>ality:<br />

Try<br />

' Code that throws excepti<strong>on</strong>s<br />

Catch E As OverflowExcepti<strong>on</strong><br />

' Catch a specific excepti<strong>on</strong><br />

Catch E As Excepti<strong>on</strong><br />

' Catch the generic excepti<strong>on</strong>s<br />

Finally<br />

' Execute some cleanup code<br />

End Try<br />

A more detailed discussi<strong>on</strong> of error handling in VB.NET can be found at<br />

http://msdn.microsoft.com/library/default.asp?url=/library/enus/dnvbdev01/html/vb01f1.asp.<br />

8. Change all embedded <strong>SQL</strong> statements <strong>to</strong> T-<strong>SQL</strong>. This is a step comm<strong>on</strong> <strong>to</strong> all<br />

migrati<strong>on</strong>s. Refer <strong>to</strong> Chapter 11, "Developing: Applicati<strong>on</strong>s — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g><br />

<strong>SQL</strong> and PL/<strong>SQL</strong>," <str<strong>on</strong>g>for</str<strong>on</strong>g> a detailed discussi<strong>on</strong> <strong>on</strong> modifying <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>SQL</strong> <strong>to</strong> be<br />

<strong>SQL</strong> <strong>Server</strong>-compliant.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 279<br />

17<br />

Developing: Applicati<strong>on</strong>s —<br />

<str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms<br />

Introducti<strong>on</strong> and Goals<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms are applicati<strong>on</strong>s built using <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Developer, a Rapid Applicati<strong>on</strong><br />

Development (RAD) envir<strong>on</strong>ment available from <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>. <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms-based<br />

applicati<strong>on</strong>s can retrieve and manipulate data in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> databases. These <str<strong>on</strong>g>for</str<strong>on</strong>g>ms can also<br />

be deployed across the Web.<br />

It is not possible <strong>to</strong> modify an <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms applicati<strong>on</strong> <str<strong>on</strong>g>for</str<strong>on</strong>g> interoperati<strong>on</strong> with a<br />

Microsoft® <strong>SQL</strong> <strong>Server</strong> database, and it is recommended that applicati<strong>on</strong>s of this type<br />

are rewritten. Microsoft Visual Basic® .NET is an ideal choice <str<strong>on</strong>g>for</str<strong>on</strong>g> rewriting an <str<strong>on</strong>g>Oracle</str<strong>on</strong>g><br />

Forms applicati<strong>on</strong> because it is very similar in nature <strong>to</strong> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Developer, both in terms<br />

of the development <strong>to</strong>ols and wizards, as well as the end product itself.<br />

This chapter is <str<strong>on</strong>g>for</str<strong>on</strong>g> developers who want <strong>to</strong> migrate their <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms applicati<strong>on</strong> running<br />

<strong>on</strong> an <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> database <strong>to</strong> Visual Basic .NET running <strong>on</strong> <strong>SQL</strong> <strong>Server</strong>. The <strong>to</strong>ols,<br />

processes, and techniques required <str<strong>on</strong>g>for</str<strong>on</strong>g> a successful c<strong>on</strong>versi<strong>on</strong> are described.<br />

In this guide, the <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms applicati<strong>on</strong> is first analyzed <str<strong>on</strong>g>for</str<strong>on</strong>g> its comp<strong>on</strong>ents, and then<br />

a similar analysis of the Visual Basic .NET applicati<strong>on</strong> envir<strong>on</strong>ment is c<strong>on</strong>ducted.<br />

Strategies <str<strong>on</strong>g>for</str<strong>on</strong>g> migrating from <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms <strong>to</strong> Visual Basic .NET are then examined. A<br />

detailed discussi<strong>on</strong> <strong>on</strong> how <strong>to</strong> per<str<strong>on</strong>g>for</str<strong>on</strong>g>m the migrati<strong>on</strong> is bey<strong>on</strong>d the scope of this guide.<br />

The goal of this chapter is <strong>to</strong> provide a blueprint <str<strong>on</strong>g>for</str<strong>on</strong>g> per<str<strong>on</strong>g>for</str<strong>on</strong>g>ming the migrati<strong>on</strong>.<br />

Migrati<strong>on</strong> Approach<br />

<str<strong>on</strong>g>Migrating</str<strong>on</strong>g> an <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms applicati<strong>on</strong> <strong>to</strong> Visual Basic .NET is complex, and the<br />

treatment of the subject here should be seen as a design sketch from which a detailed<br />

analysis and plans <str<strong>on</strong>g>for</str<strong>on</strong>g> an applicati<strong>on</strong> migrati<strong>on</strong> can be made.<br />

The basic approach is feasible <str<strong>on</strong>g>for</str<strong>on</strong>g> the following two reas<strong>on</strong>s:<br />

1. <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms and Visual Basic user interfaces share many comm<strong>on</strong> elements.<br />

2. The <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms Designer is capable <strong>to</strong> generate Visual Basic code.<br />

The <str<strong>on</strong>g>for</str<strong>on</strong>g>m is the basis <str<strong>on</strong>g>for</str<strong>on</strong>g> the user interface (UI) in both <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms and Visual Basic.<br />

The <str<strong>on</strong>g>for</str<strong>on</strong>g>m is graphical in nature and is used <strong>to</strong> present data and accept user input, and the<br />

<str<strong>on</strong>g>for</str<strong>on</strong>g>m can c<strong>on</strong>tain elements which are both graphical and n<strong>on</strong>-graphical in nature. <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>


280 Developing: Applicati<strong>on</strong>s — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms<br />

Forms and Visual Basic have several comm<strong>on</strong> elements between them. However, their<br />

organizati<strong>on</strong>, naming, and properties differ.<br />

Figure 17.1 illustrates how different comp<strong>on</strong>ents of <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms map <strong>to</strong> comp<strong>on</strong>ents in<br />

Visual Basic .NET.<br />

Figure 17.1<br />

Mapping of <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms <strong>to</strong> Visual Basic .NET WinForm<br />

This diagram shows how all the high-level comp<strong>on</strong>ents of an <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms applicati<strong>on</strong><br />

map <strong>to</strong> comp<strong>on</strong>ents in Visual Basic .NET. This mapping serves as a c<strong>on</strong>venient guide <str<strong>on</strong>g>for</str<strong>on</strong>g><br />

the work <strong>to</strong> be d<strong>on</strong>e and also helps maintain the logical compositi<strong>on</strong> of the applicati<strong>on</strong>.<br />

The mapping also helps avoid introducing <strong>to</strong>o many unintended side effects, such as<br />

firing of triggers at the wr<strong>on</strong>g time and complicating the migrati<strong>on</strong>. This diagram is used in<br />

this chapter <strong>to</strong><br />

document the source <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms applicati<strong>on</strong>, define the target<br />

Visual Basic .NET applicati<strong>on</strong>, and plan <str<strong>on</strong>g>for</str<strong>on</strong>g> per<str<strong>on</strong>g>for</str<strong>on</strong>g>ming the migrati<strong>on</strong>.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 281<br />

Examining <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms applicati<strong>on</strong>s are <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> database optimized transacti<strong>on</strong>al applicati<strong>on</strong>s built<br />

using the <strong>to</strong>ols provided by <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>'s Developer Suite. <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms Builder, a part of<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Developer suite, enables you <strong>to</strong> quickly and easily create database <str<strong>on</strong>g>for</str<strong>on</strong>g>ms and<br />

business logic. The development is d<strong>on</strong>e using wizards, drag-and-drop comp<strong>on</strong>ents, and<br />

built-in functi<strong>on</strong>s. A visual edi<strong>to</strong>r can be used <strong>to</strong> refine the <str<strong>on</strong>g>for</str<strong>on</strong>g>ms with graphics and other<br />

comp<strong>on</strong>ents. The coding language is PL/<strong>SQL</strong>. A client/server Forms applicati<strong>on</strong> can run<br />

<strong>on</strong> the Web with very little or no modificati<strong>on</strong>.<br />

Like most GUI applicati<strong>on</strong>s, an <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms applicati<strong>on</strong> is composed of two parts: the<br />

applicati<strong>on</strong> logic and the user interface. <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms maintains this separati<strong>on</strong><br />

throughout its design. Hence the Forms Runtime is the same in both the two-tier and<br />

three-tier architectures.<br />

An understanding of the basic c<strong>on</strong>cepts and comp<strong>on</strong>ents that make up a <str<strong>on</strong>g>for</str<strong>on</strong>g>m is<br />

important <strong>to</strong> planning an applicati<strong>on</strong> migrati<strong>on</strong>. Figure 17.2 shows a simplified view of the<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms envir<strong>on</strong>ment.<br />

Figure 17.2<br />

High-level organizati<strong>on</strong> of <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms comp<strong>on</strong>ents<br />

An <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms applicati<strong>on</strong> is an organizati<strong>on</strong> of items. The organizati<strong>on</strong> of the items<br />

has two perspectives: that of the developer, called the <str<strong>on</strong>g>for</str<strong>on</strong>g>m view; and that of the user,<br />

called the visual (or presentati<strong>on</strong>) view. In the <str<strong>on</strong>g>for</str<strong>on</strong>g>m view, the items are organized in<strong>to</strong><br />

logical blocks and have no visual structure. The visual structure is provided by<br />

c<strong>on</strong>structing the visual view where items are placed <strong>on</strong> a canvas and presented <strong>to</strong> the<br />

user in windows. It is very important <strong>to</strong> maintain the same visual view when an <str<strong>on</strong>g>Oracle</str<strong>on</strong>g><br />

Forms applicati<strong>on</strong> is migrated. The Visual Basic .NET developers need <strong>to</strong> look at the<br />

visual view <strong>to</strong> understand how many screen layouts they need in Visual Basic .NET.<br />

Each item in a canvas will corresp<strong>on</strong>d <strong>to</strong> <strong>on</strong>e c<strong>on</strong>trol in .NET.<br />

The migrati<strong>on</strong> should be attempted by creating two models: <strong>on</strong>e is based <strong>on</strong> the<br />

<str<strong>on</strong>g>for</str<strong>on</strong>g>m<br />

view, called the Form Model; and the other is based <strong>on</strong> the visual view, called the Visual<br />

Model. Figure 17.1 shows the <str<strong>on</strong>g>for</str<strong>on</strong>g>m view of the mapping from <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms <strong>to</strong><br />

Visual Basic .NET. The equivalent visual view is shown in Figure 17.3.


282 Developing: Applicati<strong>on</strong>s — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms<br />

Figure 17.3<br />

Mapping of visual view of <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms <strong>to</strong> Visual Basic .NET<br />

The <str<strong>on</strong>g>for</str<strong>on</strong>g>m view is used by the developer <strong>to</strong> access the business logic and the data<br />

access. The visual view is used <strong>to</strong> build the user interface.<br />

Note Providing a complete descripti<strong>on</strong> of how <strong>to</strong> trans<str<strong>on</strong>g>for</str<strong>on</strong>g>m every item and every piece<br />

of code from an <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms applicati<strong>on</strong> <strong>to</strong> a Visual Basic .NET applicati<strong>on</strong> is bey<strong>on</strong>d<br />

the scope of this guide.<br />

In this secti<strong>on</strong>, the entire <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms applicati<strong>on</strong> is examined, with an emphasis <strong>on</strong><br />

understanding the database-related comp<strong>on</strong>ents.<br />

An <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms applicati<strong>on</strong> is built using comp<strong>on</strong>ents called modules. The following four<br />

types of modules are visible when a <str<strong>on</strong>g>for</str<strong>on</strong>g>m applicati<strong>on</strong> is opened up in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms<br />

Builder:<br />

1. Object Library<br />

2. PL/<strong>SQL</strong> Library<br />

3. Form Module<br />

4. Menu Module<br />

Figure 17.4 shows the details of an <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms applicati<strong>on</strong> as seen in the Ownership<br />

View using <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms Builder. This <strong>to</strong>ol will be employed in documenting the current<br />

applicati<strong>on</strong>.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 283<br />

Figure 17.4<br />

An <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Form as visible in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms Builder<br />

An applicati<strong>on</strong> can be built using multiple <str<strong>on</strong>g>for</str<strong>on</strong>g>ms, menus, and library modules. The <str<strong>on</strong>g>Oracle</str<strong>on</strong>g><br />

Forms Builder can be used <strong>to</strong> browse the comp<strong>on</strong>ent model and understand the modules<br />

and their characteristics so that the Forms Model can be built. The elements offered by<br />

these modules account <str<strong>on</strong>g>for</str<strong>on</strong>g> the capabilities, features, and functi<strong>on</strong>ing of the applicati<strong>on</strong><br />

and should be the focus of the developer involved in migrating an applicati<strong>on</strong>.


284 Developing: Applicati<strong>on</strong>s — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms<br />

Table 17.1 is a compilati<strong>on</strong> of the files that make up an <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms applicati<strong>on</strong>.<br />

Table 17.1: <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms File Extensi<strong>on</strong>s<br />

Module Extensi<strong>on</strong> Characteristic<br />

Form .fmb Form design file<br />

.fmx<br />

.fmt<br />

Form executable runfile<br />

Form text export file<br />

Menu .mmb Menu design file<br />

.mmx<br />

Menu executable runfile<br />

.mmt Menu text export file<br />

PL/<strong>SQL</strong> Library .pll PL/<strong>SQL</strong> library design file (can also be executed<br />

— c<strong>on</strong>tains both source and executable code)<br />

.plx<br />

PL/<strong>SQL</strong> library executable runfile (c<strong>on</strong>tains no<br />

source code)<br />

.pld<br />

PL/<strong>SQL</strong> library text export file<br />

Object Library .olb Object library design file<br />

.olt<br />

Object library text export file<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms Builder can be used <strong>to</strong> view all the comp<strong>on</strong>ents in a Forms applicati<strong>on</strong> by<br />

opening the <str<strong>on</strong>g>for</str<strong>on</strong>g>m and clicking View, and then Show PL/<strong>SQL</strong> <strong>on</strong>ly.<br />

Object Library<br />

The object-oriented programming c<strong>on</strong>cept of reusing code is implemented in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g><br />

Forms by the object library and PL/<strong>SQL</strong> library modules. The Object library c<strong>on</strong>tains<br />

reusable objects and the PL/<strong>SQL</strong> library c<strong>on</strong>tains reusable code. Hence, these are<br />

examined first <str<strong>on</strong>g>for</str<strong>on</strong>g> a migrati<strong>on</strong>.<br />

The Object library is a collecti<strong>on</strong> of <str<strong>on</strong>g>for</str<strong>on</strong>g>ms objects that can be used in other <str<strong>on</strong>g>for</str<strong>on</strong>g>m, menu, or<br />

library modules. The Object Library is used <strong>to</strong> s<strong>to</strong>re, maintain, and distribute standard<br />

<str<strong>on</strong>g>for</str<strong>on</strong>g>ms objects, which can then be reused across the entire applicati<strong>on</strong>. They also help<br />

c<strong>on</strong>serve runtime memory and encourage reuse. The objects in an Object Library are<br />

comm<strong>on</strong>ly organized as folders. The organizati<strong>on</strong> may be by type of item or by<br />

applicati<strong>on</strong> functi<strong>on</strong>al area.<br />

A good example of the use of an object library is a c<strong>on</strong>trol block used <strong>to</strong> enter complex<br />

search criteria in a query-<strong>on</strong>ly <str<strong>on</strong>g>for</str<strong>on</strong>g>m. This c<strong>on</strong>trol block is then used in multiple <str<strong>on</strong>g>for</str<strong>on</strong>g>ms.<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms Builder allows creati<strong>on</strong> of a subclassed versi<strong>on</strong> of a library object <str<strong>on</strong>g>for</str<strong>on</strong>g> reuse<br />

in any desired module. To be able <strong>to</strong> tell whether an object is subclassed or not, look at<br />

the subclass in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> property of the data block.<br />

The object-oriented features of Visual Basic .NET allow you <strong>to</strong> model library object<br />

inheritance closely <strong>to</strong> maintain<br />

the same structure. The object library can be viewed as a<br />

DLL.<br />

PL/<strong>SQL</strong> Library<br />

The PL/<strong>SQL</strong> library c<strong>on</strong>tains reusable code invoked by other <str<strong>on</strong>g>for</str<strong>on</strong>g>m, menu, or library<br />

modules. The code, also called a program unit, can be user-named functi<strong>on</strong>s,<br />

procedures, or packages. The program unit is s<strong>to</strong>red and executed <strong>on</strong> the client. The<br />

program units are not <str<strong>on</strong>g>for</str<strong>on</strong>g> database-related code al<strong>on</strong>e. They may c<strong>on</strong>tain purely business<br />

logic. For example, the code could be used <strong>to</strong> check the validity of a user input in a <str<strong>on</strong>g>for</str<strong>on</strong>g>m.<br />

Any <strong>SQL</strong> c<strong>on</strong>tained in these program units is passed <strong>to</strong> the database.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 285<br />

Libraries make all the PL/<strong>SQL</strong> code available <strong>to</strong> the <str<strong>on</strong>g>for</str<strong>on</strong>g>m without being part of the <str<strong>on</strong>g>for</str<strong>on</strong>g>m.<br />

The libraries are loaded dynamically. Multiple <str<strong>on</strong>g>for</str<strong>on</strong>g>ms can attach the same PL/<strong>SQL</strong> library.<br />

Table 17.1 identifies the files that are related <strong>to</strong> the PL/<strong>SQL</strong><br />

needs <strong>to</strong> be migrated.<br />

Form Module<br />

Library that c<strong>on</strong>tain code that<br />

A <str<strong>on</strong>g>for</str<strong>on</strong>g>m (or <str<strong>on</strong>g>for</str<strong>on</strong>g>m module) is the main comp<strong>on</strong>ent that anchors an applicati<strong>on</strong> and provides<br />

the necessary code <strong>to</strong> interact with the datasource and the user interface. The underlying<br />

database data is reflected in multiple items, including fields, check boxes, and radio<br />

groups. A <str<strong>on</strong>g>for</str<strong>on</strong>g>m is logically organized in<strong>to</strong> blocks.<br />

Blocks<br />

A block is a c<strong>on</strong>tainer <str<strong>on</strong>g>for</str<strong>on</strong>g> a group of related items such as text boxes, lists, and butt<strong>on</strong>s.<br />

The block itself does not have a visual representati<strong>on</strong>.<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms Builder c<strong>on</strong>sists of two main types of blocks. These are:<br />

1. Data blocks<br />

2. C<strong>on</strong>trol blocks<br />

These two kinds of blocks are very different from each other. The data block serves as a<br />

bridge <strong>to</strong> the underlying data and provides an abstracti<strong>on</strong> <str<strong>on</strong>g>for</str<strong>on</strong>g> how the data is reached.<br />

The c<strong>on</strong>trol blocks are more like programming units that can organize c<strong>on</strong>trols in<strong>to</strong> logical<br />

groups <str<strong>on</strong>g>for</str<strong>on</strong>g>ming part of the same user interface navigati<strong>on</strong> cycle. Whether a block is a<br />

data block or a c<strong>on</strong>trol block can be determined by verifying the Database Data Block<br />

property <str<strong>on</strong>g>for</str<strong>on</strong>g> the block. It is a data block if the setting is "Yes" and a c<strong>on</strong>trol block if the<br />

setting is "No."<br />

Data Block<br />

A data block can be associated with a specific database table (or a view), a s<strong>to</strong>red<br />

procedure, a FROM clause query, or a transacti<strong>on</strong>al triggers. By default, the associati<strong>on</strong><br />

between a data block and the database allows <str<strong>on</strong>g>for</str<strong>on</strong>g> au<strong>to</strong>matic access and manipulati<strong>on</strong> of<br />

data in the database. Triggers are used when a data block needs access <strong>to</strong> tables not<br />

directly associated with it (n<strong>on</strong>-base tables).<br />

Various relati<strong>on</strong>ships can exist between data blocks and their underlying base tables. A<br />

comm<strong>on</strong> relati<strong>on</strong>ship is the master-detail relati<strong>on</strong>ship where each row in the master table<br />

corresp<strong>on</strong>ds <strong>to</strong> <strong>on</strong>e or more rows in the detail table. The master-detail relati<strong>on</strong>ship<br />

allows the primary key and <str<strong>on</strong>g>for</str<strong>on</strong>g>eign key values <strong>to</strong> be linked across data blocks. <str<strong>on</strong>g>Oracle</str<strong>on</strong>g><br />

Forms Builder au<strong>to</strong>matically generates the objects and the PL/<strong>SQL</strong> code needed <strong>to</strong><br />

support the master-detail relati<strong>on</strong>ships when these blocks are built using the Data Block<br />

Wizard.


286 Developing: Applicati<strong>on</strong>s — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms<br />

Figure 17.5 shows the different comp<strong>on</strong>ents that make up a master-detail block as<br />

created by the Data Block Wizard.<br />

Figure 17.5<br />

Code generated by <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms Builder Data Block Wizard in creating a master-detail block<br />

By capturing a query <strong>on</strong> a table, a block can also be designed <strong>to</strong> show <strong>on</strong>e or more<br />

records at a time. These are called single-record blocks or multi-record blocks,<br />

respectively.<br />

Visual Basic .NET developers can use <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms Builder <strong>to</strong> look at the generated<br />

code <strong>to</strong> find out about the relati<strong>on</strong>ships between the blocks. For example, in Figure 17. 5,<br />

code in the ON-POPULATE-DETAILS trigger <strong>on</strong> the DEPT block suggests that it is the<br />

master block of the EMP block.<br />

In Visual Basic .NET, the equivalent of an <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Form data block is a Dataset in<strong>to</strong> which<br />

data can be read from the database, and <strong>on</strong> the visual side, a DataGrid c<strong>on</strong>trol bound <strong>to</strong><br />

the Dataset will be capable <strong>to</strong> display the data. Dataset is just <strong>on</strong>e opti<strong>on</strong>. In additi<strong>on</strong> <strong>to</strong><br />

the Dataset, ADO.NET offers DataReader <str<strong>on</strong>g>for</str<strong>on</strong>g> read-<strong>on</strong>ly data access.<br />

Additi<strong>on</strong>al properties c<strong>on</strong>vey the associati<strong>on</strong> between a data block and a table, such as<br />

the WHERE clause and ORDER BY clause that will be used <strong>to</strong> create <strong>SQL</strong> <str<strong>on</strong>g>for</str<strong>on</strong>g> the<br />

Visual Basic .NET Dataset. The Insert Allowed, Update Allowed, and Delete Allowed<br />

properties will tell the Visual Basic .NET developer whether the block will insert, update,<br />

or delete any records.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 287<br />

Figure 17.6 shows all the properties of a data block.<br />

Figure 17.6<br />

Properties of a data block<br />

C<strong>on</strong>trol Block<br />

The sec<strong>on</strong>d type of block is the c<strong>on</strong>trol block. The items in a c<strong>on</strong>trol block are not<br />

associated with the database, and its items do not relate <strong>to</strong> any columns within any<br />

database table. The items in a c<strong>on</strong>trol block are called c<strong>on</strong>trol items. For example,<br />

butt<strong>on</strong>s in a module can initiate certain acti<strong>on</strong>s and can be logically grouped in a c<strong>on</strong>trol<br />

block. The c<strong>on</strong>trol block is <strong>on</strong>ly a logical grouping and the physical or visual placement<br />

may differ. It is also a mechanism <strong>to</strong> segregate the c<strong>on</strong>trol block items from the items that<br />

are dependent <strong>on</strong> the database. C<strong>on</strong>trol items are used <strong>to</strong> per<str<strong>on</strong>g>for</str<strong>on</strong>g>m functi<strong>on</strong>s, such as<br />

accepting input from the user and displaying calculated values and look values.<br />

Program Units<br />

Program units are part of <str<strong>on</strong>g>for</str<strong>on</strong>g>ms modules and they c<strong>on</strong>tain named procedures, functi<strong>on</strong>s,<br />

or packages. The program units are similar <strong>to</strong> the program units created in the libraries<br />

but are local <strong>to</strong> the <str<strong>on</strong>g>for</str<strong>on</strong>g>m in which they are created. They are s<strong>to</strong>red and executed <strong>on</strong> the<br />

client with any embedded <strong>SQL</strong> passed <strong>to</strong> the database <str<strong>on</strong>g>for</str<strong>on</strong>g> processing. If this code<br />

c<strong>on</strong>tains database interacti<strong>on</strong>s, then it needs <strong>to</strong> be c<strong>on</strong>verted <strong>to</strong> T-<strong>SQL</strong>. If it c<strong>on</strong>tains <strong>on</strong>ly<br />

n<strong>on</strong>-database related code, then it needs <strong>to</strong> be c<strong>on</strong>verted <strong>to</strong> its equivalent in<br />

Visual Basic .NET.<br />

Triggers<br />

The trigger object is a PL/<strong>SQL</strong> block executed <strong>on</strong> an event. Triggers can be owned by the<br />

<str<strong>on</strong>g>for</str<strong>on</strong>g>m module, a data block, or an item, depending up<strong>on</strong> their scope.


288 Developing: Applicati<strong>on</strong>s — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms<br />

If this code c<strong>on</strong>tains database interacti<strong>on</strong>s, then it needs <strong>to</strong> be c<strong>on</strong>verted <strong>to</strong> T-<strong>SQL</strong>. If it<br />

c<strong>on</strong>tains <strong>on</strong>ly n<strong>on</strong>-database code, then it needs <strong>to</strong> be c<strong>on</strong>verted <strong>to</strong> its equivalent in<br />

Visual Basic .NET.<br />

When a trigger is activated, it executes the code it c<strong>on</strong>tains. Each trigger’s name defines<br />

what event will fire it; <str<strong>on</strong>g>for</str<strong>on</strong>g> example, a WHEN-BUTTON-PRESSED trigger executes its<br />

code each time the user clicks the butt<strong>on</strong> <strong>to</strong> which the trigger is attached.<br />

A trigger can be replaced by an equivalent event in Visual Basic .NET. The equivalent of<br />

an <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms WHEN-BUTTON_PRESSED trigger in Visual Basic .NET is the Click<br />

event procedure. Double-click the page Butt<strong>on</strong> c<strong>on</strong>trol in design view <strong>to</strong> open the code<br />

behind the page and create a Click event procedure.<br />

List of Values (LOV)<br />

A LOV is a pop-up window that provides the user with a selecti<strong>on</strong> of values. The values<br />

can be static or populated by querying the database. LOVs are populated using columns<br />

returned by record groups. Check the Record Group property of the LOV <str<strong>on</strong>g>for</str<strong>on</strong>g> the record<br />

group which is used <strong>to</strong> provide values. Visual Basic .NET offers pop-up windows that can<br />

be programmed <strong>to</strong> display a list of values obtained by the DataReader.<br />

Record Groups<br />

A record group is a data structure in the <str<strong>on</strong>g>for</str<strong>on</strong>g>m module which behaves like a local table <str<strong>on</strong>g>for</str<strong>on</strong>g><br />

data retrieved from the databases. Record groups are a way <strong>to</strong> share small List of Values<br />

(LOV). The values can be retrieved using a query or a subprogram. Look in<strong>to</strong> the<br />

property Record Group Query <strong>to</strong> see the <strong>SQL</strong> statement up<strong>on</strong> which the record group is<br />

based. A record group can be replaced by DataReader in Visual Basic .NET.<br />

Menu Module<br />

The menu module c<strong>on</strong>sists of a hierarchy of menus. Each menu c<strong>on</strong>sists of the items that<br />

can be selected. Menu modules are usually attached <strong>to</strong> <str<strong>on</strong>g>for</str<strong>on</strong>g>m modules. Every <str<strong>on</strong>g>for</str<strong>on</strong>g>m<br />

module has a default menu that includes the commands <str<strong>on</strong>g>for</str<strong>on</strong>g> all basic database<br />

operati<strong>on</strong>s, such as insert, update, delete, and query. Visual Basic .NET offers a wide<br />

range of functi<strong>on</strong>ality involving menus.<br />

After inserting, updating, or deleting records from an <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g>m, changes are not made<br />

in the underlying database until the changes are committed with a save command. While<br />

rewriting this module in Visual Basic .NET, it is important <strong>to</strong> know whether inserts,<br />

updates, and deletes are permitted <strong>on</strong> a data block. The data block properties of Insert<br />

Allowed, Update Allowed, and Delete Allowed determine these.<br />

Any item in a menu can also be referenced through PL/<strong>SQL</strong> code <strong>to</strong> enable/disable menu<br />

items, attach commands <strong>to</strong> menu items, initialize check or radio menu items, and change<br />

menu start-up code.<br />

Windows and Canvases<br />

Windows and canvases <str<strong>on</strong>g>for</str<strong>on</strong>g>m the basis <str<strong>on</strong>g>for</str<strong>on</strong>g> the visual presentati<strong>on</strong> of the <str<strong>on</strong>g>for</str<strong>on</strong>g>m. The visual<br />

model is built by looking at the windows and canvases through Form Builder. The<br />

developer can then create an identical representati<strong>on</strong> in Visual Basic .NET based <strong>on</strong> the<br />

visual model using <str<strong>on</strong>g>for</str<strong>on</strong>g>ms.<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms has two types of windows: document windows (the main applicati<strong>on</strong> areas)<br />

and dialog windows (messages and other acti<strong>on</strong>s).The end user interacts with the<br />

applicati<strong>on</strong> using these windows. In additi<strong>on</strong> <strong>to</strong> incorporating all the functi<strong>on</strong>ality in the<br />

original applicati<strong>on</strong>, it is also important <strong>to</strong> maintain the general look and feel of the<br />

applicati<strong>on</strong>.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 289<br />

The document window is composed of work areas called canvases where visual objects<br />

such as graphics and items are arranged. Several canvases can be located in a <str<strong>on</strong>g>for</str<strong>on</strong>g>m<br />

module. All canvases may appear in a single window (by default) or spread across<br />

multiple windows (<strong>to</strong> view simultaneously).<br />

From the start, a new document window or dialog has a relati<strong>on</strong>ship with a <str<strong>on</strong>g>for</str<strong>on</strong>g>m in which<br />

relati<strong>on</strong>ships <strong>to</strong> blocks tie the visual representati<strong>on</strong> <strong>to</strong>gether with the underlying database<br />

data. Figure 17.7 shows a window which displays the master-detail view of the data. The<br />

Dept part is the header and the Employees part is the detail.<br />

Figure 17.7<br />

Sample applicati<strong>on</strong> window<br />

Frames<br />

A frame is a visual object found <strong>on</strong> a canvas. Frames are used <strong>to</strong> arrange items in terms<br />

of blocks. The frame defines visual characteristics such as margins, offsets, and<br />

distances between items. Frames may also be defined in the Object Library <strong>to</strong> en<str<strong>on</strong>g>for</str<strong>on</strong>g>ce<br />

standards across the applicati<strong>on</strong>. The equivalent of frames in Visual Basic .NET is the<br />

panel.<br />

Item<br />

Items are interface objects that present the data values <strong>to</strong> the users. Items also enable<br />

the user <strong>to</strong> interact with the <str<strong>on</strong>g>for</str<strong>on</strong>g>m. The type of interacti<strong>on</strong> varies according <strong>to</strong> the type of<br />

item. Visual Basic .NET offers a wide range of equivalents <str<strong>on</strong>g>for</str<strong>on</strong>g> the <str<strong>on</strong>g>for</str<strong>on</strong>g>m items called<br />

c<strong>on</strong>trols.<br />

The type of an item can be examined by locating the Item Type property of the item.<br />

Items have both a visual representati<strong>on</strong> and a <str<strong>on</strong>g>for</str<strong>on</strong>g>ms representati<strong>on</strong> (code) and will<br />

appear in both models. However, the properties captured in each of the models will differ.<br />

Only the comm<strong>on</strong> items, such as text item, check box, and radio groups, which could be<br />

dependent <strong>on</strong> the database are discussed here. For each of the items, the visual and<br />

functi<strong>on</strong>al characteristics are attached <strong>to</strong> the visual model and the logical characteristics<br />

are captured in the <str<strong>on</strong>g>for</str<strong>on</strong>g>m model. For example, the height, width, f<strong>on</strong>t size, and <str<strong>on</strong>g>for</str<strong>on</strong>g>mat<br />

mas k are the visual characteristics. The database item (table and column) that is used <strong>to</strong><br />

populate the text item is the <str<strong>on</strong>g>for</str<strong>on</strong>g>m characteristic.<br />

Text Item<br />

Text items allow <str<strong>on</strong>g>for</str<strong>on</strong>g> text <strong>to</strong> be displayed and manipulated. Text items are called by the<br />

name TextBox in Visual Basic .NET. When examining text items, Visual Basic .NET<br />

developers need <strong>to</strong> determine whether this item corresp<strong>on</strong>ds <strong>to</strong> a column in a database<br />

tabl e by looking at the Database Item property. If so, it needs <strong>to</strong> be tied <strong>to</strong> a dataset or<br />

other data source in Visual Basic .NET. The name of the text item is not necessarily the<br />

same as the name of the database column. Look at the Column Name property <str<strong>on</strong>g>for</str<strong>on</strong>g> the<br />

name of database column.


290 Developing: Applicati<strong>on</strong>s — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms<br />

Check Box Item<br />

A check box provides the user with a Boolean c<strong>on</strong>trol that has just two values, such as<br />

true and false, or <strong>on</strong> and off. The check box values can be set by fetching from the<br />

database. When creating the equivalent Check Box c<strong>on</strong>trol, Visual Basic .NET<br />

developers need <strong>to</strong> look at the following three properties of a check box item: Value<br />

When Checked, Value When Unchecked, and Check Box Mapping of Other Values.<br />

Radio Group Item<br />

A radio group provides the user with a fixed set of opti<strong>on</strong>s that are mutually exclusive,<br />

Radio group item values can also be set using database columns. Under the radio<br />

butt<strong>on</strong>, the developer should look at the Radio Butt<strong>on</strong> Value property <str<strong>on</strong>g>for</str<strong>on</strong>g> the value<br />

assigned <strong>to</strong> the butt<strong>on</strong>. In Visual Basic .NET the radio group can be replaced by a<br />

combinati<strong>on</strong> of GroupBox and RadioButt<strong>on</strong>s.<br />

Butt<strong>on</strong>s<br />

Butt<strong>on</strong>s are interface items that can display list of values, commit data in a <str<strong>on</strong>g>for</str<strong>on</strong>g>m, query<br />

the database, or invoke PL/<strong>SQL</strong> blocks. The WHEN-BUTTON-PRESSED trigger holds<br />

the code <str<strong>on</strong>g>for</str<strong>on</strong>g> these acti<strong>on</strong>s. Butt<strong>on</strong>s are also found in Visual Basic .NET.<br />

Understanding Visual Basic .NET<br />

Visu al Basic.NET offers Windows® Forms (WinForms) Designer, which is very similar in<br />

natu re <strong>to</strong> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms Builder. The product of the Windows Forms Designer is a<br />

Windows-based <str<strong>on</strong>g>for</str<strong>on</strong>g>m applicati<strong>on</strong> that is similar in nature <strong>to</strong> an <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms applicati<strong>on</strong>.<br />

Forms are the fundamental elements of the applicati<strong>on</strong> <strong>on</strong> which c<strong>on</strong>trols (same as items<br />

in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms) can be placed <str<strong>on</strong>g>for</str<strong>on</strong>g> user interacti<strong>on</strong>. As in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms, menus and<br />

<strong>to</strong>olbars provide a structure <str<strong>on</strong>g>for</str<strong>on</strong>g> the user <strong>to</strong> c<strong>on</strong>trol the applicati<strong>on</strong>. For readers who are<br />

unfamiliar with VB.NET, there is a lot of in-depth technical in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> available at<br />

http://msdn.microsoft.com/vbasic/using/<br />

If the c<strong>on</strong>versi<strong>on</strong> of the <str<strong>on</strong>g>for</str<strong>on</strong>g>ms is d<strong>on</strong>e correctly, then the WinForm is simply the<br />

presentati<strong>on</strong> layer with all of the database access logic and rules put in<strong>to</strong> a business<br />

object layer. The c<strong>on</strong>versi<strong>on</strong> <strong>to</strong> a Web Form soluti<strong>on</strong>, as a result, <strong>on</strong>ly requires<br />

associating the appropriate Web server c<strong>on</strong>trol <strong>to</strong> an object holding the data retrieved<br />

from the business object layer.<br />

The c<strong>on</strong>trols <strong>on</strong> a <str<strong>on</strong>g>for</str<strong>on</strong>g>m simply provide an interface <strong>to</strong> the event-driven model that is the<br />

equ ivalent of the triggers system in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms. As changes are made <strong>to</strong> textbox input,<br />

the pressing of butt<strong>on</strong>s, or the selecti<strong>on</strong> of items in a list, additi<strong>on</strong>al code is triggered (see<br />

"Triggers" in the "Form Module" secti<strong>on</strong> earlier in this chapter). The code is in the <str<strong>on</strong>g>for</str<strong>on</strong>g>m of<br />

subroutines that handle the call from the raised event <strong>to</strong> provide some specific acti<strong>on</strong>.<br />

The PL/<strong>SQL</strong> routines will map <strong>to</strong> these subroutines. The acti<strong>on</strong> is typically defined as an<br />

algorithm or a business rule. In most applicati<strong>on</strong>s, the business rules extract in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong><br />

from the database.<br />

A summary of the entire array of c<strong>on</strong>trols in WinForms is available at<br />

http://msdn.microsoft.com/library/en-us/vbc<strong>on</strong>/html/vboriC<strong>on</strong>trolsForWinForms.asp.<br />

The .NET Framework is so extensible that numerous Independent Software Vendors<br />

(ISVs) have created unique c<strong>on</strong>trols or have enhanced the functi<strong>on</strong>s in existing .NET<br />

c<strong>on</strong> trols. Developers themselves can generate their own c<strong>on</strong>trols <str<strong>on</strong>g>for</str<strong>on</strong>g> pers<strong>on</strong>al needs.<br />

Man y of the most comm<strong>on</strong> c<strong>on</strong>trols emulate functi<strong>on</strong>ality that has been used in visual<br />

<str<strong>on</strong>g>for</str<strong>on</strong>g>m s <str<strong>on</strong>g>for</str<strong>on</strong>g> years, whether in classic Visual Basic, Delphi, or <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>. One of the most<br />

beneficial properties of most c<strong>on</strong>trols is the capability <strong>to</strong> bind them <strong>to</strong> data sources.<br />

Data


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 291<br />

sources do not have <strong>to</strong> be ADO.NET objects. Sources can come from arrays and other<br />

collecti<strong>on</strong>-type objects.<br />

Scenario 1: Rewriting <strong>to</strong> Visual Basic .NET<br />

C<strong>on</strong> verting from <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms <strong>to</strong> Visual Basic .NET is n<strong>on</strong>-trivial. There is no <strong>to</strong>ol that<br />

au<strong>to</strong>mates the c<strong>on</strong>versi<strong>on</strong> <strong>to</strong> VB.NET. In <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms, an applicati<strong>on</strong> can be separated<br />

in<strong>to</strong> a visual or presentati<strong>on</strong> comp<strong>on</strong>ent and a code comp<strong>on</strong>ent. This separati<strong>on</strong> makes<br />

the migrati<strong>on</strong> easier and is the approach used in this guidance.<br />

Two methods are available <strong>to</strong> c<strong>on</strong>vert <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms <strong>to</strong> Visual Basic.NET:<br />

● Case 1: Using <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Designer<br />

● Case 2: Manually Redesigning the applicati<strong>on</strong><br />

Case 1: Using <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Designer<br />

Visual Basic code is generated from the <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Form applicati<strong>on</strong> using the Visual Basic<br />

Genera<strong>to</strong>r, which is a functi<strong>on</strong> of <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Designer. The Visual Basic code is then<br />

upgraded <strong>to</strong> Visual Basic.NET using the guidance available from Microsoft at<br />

http://msdn.microsoft.com/library/default.asp?url=/library/en-<br />

us/vbc<strong>on</strong>/html/vbc<strong>on</strong>upgradingapplicati<strong>on</strong>screatedinpreviousversi<strong>on</strong>sofvisualbasic.asp.<br />

At the time of publicati<strong>on</strong>, this method is not perfect. Many manual changes will still need<br />

<strong>to</strong> be made after the au<strong>to</strong>mated c<strong>on</strong>versi<strong>on</strong>. Using <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Designer is still a useful<br />

exe rcise because it provides a valuable template structure of the migrated Visual Basic<br />

applicati<strong>on</strong> even though subsequent changes <strong>to</strong> the code will be necessary.<br />

Case 2: Manually Redesigning the Applicati<strong>on</strong><br />

In this method, the entire <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms applicati<strong>on</strong> is documented and the new<br />

applicati<strong>on</strong> is built in an orderly fashi<strong>on</strong>.<br />

To document and redesign the applicati<strong>on</strong>, follow these steps:<br />

1. Create a list of <str<strong>on</strong>g>for</str<strong>on</strong>g>ms found in the applicati<strong>on</strong> and note the relati<strong>on</strong>ship between<br />

them.<br />

2. Create two models <str<strong>on</strong>g>for</str<strong>on</strong>g> each <str<strong>on</strong>g>for</str<strong>on</strong>g>m.<br />

The first model, which is called the Forms Model, will c<strong>on</strong>tain all the <str<strong>on</strong>g>for</str<strong>on</strong>g>ms comp<strong>on</strong>ents. The<br />

Forms Model will document the four modules: <str<strong>on</strong>g>for</str<strong>on</strong>g>ms module, menu module, object libraries,<br />

and PL/<strong>SQL</strong> libraries. The sec<strong>on</strong>d model, called the Visual Model, will document all the<br />

layout-related comp<strong>on</strong>ents: windows, canvases, frames, and items<br />

3. Document the Forms Model.<br />

Open a <str<strong>on</strong>g>for</str<strong>on</strong>g>m in the Ownership View using <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms Designer and note the<br />

comp<strong>on</strong>ents under each module with their hierarchy from module down <strong>to</strong> items.<br />

Per<str<strong>on</strong>g>for</str<strong>on</strong>g>m the following acti<strong>on</strong>s:<br />

a. Start with documenting all the modules: <str<strong>on</strong>g>for</str<strong>on</strong>g>ms modules, menu modules, object<br />

libraries, and PL/<strong>SQL</strong> libraries using Figure 17. 1 as reference.<br />

b. For each module, incrementally refine the model with the next level of detail<br />

using multiple passes.<br />

c. Document all the supporting comp<strong>on</strong>ents, such as LOVs, record groups, and<br />

program units, found under the <str<strong>on</strong>g>for</str<strong>on</strong>g>m module.<br />

d. Based <strong>on</strong> the size of the <str<strong>on</strong>g>for</str<strong>on</strong>g>m, submodels or documents may be prepared <str<strong>on</strong>g>for</str<strong>on</strong>g><br />

subsecti<strong>on</strong>s of the model.


292 Developing: Applicati<strong>on</strong>s — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms<br />

e. A block document may be created <str<strong>on</strong>g>for</str<strong>on</strong>g> just the data blocks and c<strong>on</strong>trol blocks.<br />

Use <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> runtime in debug mode <strong>to</strong> understand the flow. When you run<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms in debug mode, the runtime envir<strong>on</strong>ment displays the name of<br />

each trigger when it fires. Operate the <str<strong>on</strong>g>for</str<strong>on</strong>g>m as a user and document the flow of<br />

executi<strong>on</strong> in the blocks document.<br />

f. A procedures document c<strong>on</strong>taining a compilati<strong>on</strong> of PL/<strong>SQL</strong> code or program<br />

unit found in triggers, user-named subprograms, packages, PL/<strong>SQL</strong>-type menu<br />

items, and menu startup code. All places in a <str<strong>on</strong>g>for</str<strong>on</strong>g>m which c<strong>on</strong>tained PL/<strong>SQL</strong><br />

code can be c<strong>on</strong>veniently viewed by switching the <str<strong>on</strong>g>for</str<strong>on</strong>g>m view <strong>to</strong> Show PL/<strong>SQL</strong><br />

Only. For each program unit, note the existence of <strong>SQL</strong> or calls <strong>to</strong> database<br />

s<strong>to</strong>red programs.<br />

4. Document the Visual Model.<br />

Open the <str<strong>on</strong>g>for</str<strong>on</strong>g>m in the Visual View using <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms Designer and note the<br />

comp<strong>on</strong>ents under each module, capturing the hierarchical relati<strong>on</strong>ship as<br />

shown in Figure 17.3. Document all the visual characteristics <str<strong>on</strong>g>for</str<strong>on</strong>g> each of the<br />

comp<strong>on</strong>ents.<br />

5. C<strong>on</strong>vert the shared code.<br />

Start the migrati<strong>on</strong> by c<strong>on</strong>verting the shared comp<strong>on</strong>ents that are under the object<br />

libraries and PL/<strong>SQL</strong> libraries. While migrating from <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms <strong>to</strong><br />

Visual Basic .NET, c<strong>on</strong>tinue <strong>to</strong> maintain the same logical grouping and<br />

organizati<strong>on</strong> of the various <str<strong>on</strong>g>for</str<strong>on</strong>g>ms comp<strong>on</strong>ents, including the shared libraries.<br />

In Visual Basic .NET, create a class library project, <strong>on</strong>e each <str<strong>on</strong>g>for</str<strong>on</strong>g> the object libraries<br />

and the PL/<strong>SQL</strong> libraries.<br />

● Migrate the PL/<strong>SQL</strong> libraries.<br />

The procedures document c<strong>on</strong>tains the required in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <str<strong>on</strong>g>for</str<strong>on</strong>g> migrating the<br />

PL/<strong>SQL</strong> libraries. For each PL/<strong>SQL</strong> library, create a Visual Basic .NET class in<br />

the target project. Each program unit in a library can be migrated in<strong>to</strong> methods<br />

with the equivalent functi<strong>on</strong>ality.<br />

● Migrate the object libraries.<br />

The migrati<strong>on</strong> of the object libraries can be per<str<strong>on</strong>g>for</str<strong>on</strong>g>med using the Forms Model.<br />

For each object library, create a Visual Basic .NET class in the target project.<br />

Each object in a library can be migrated in<strong>to</strong> an equivalent method in the class.<br />

6.<br />

C<strong>on</strong>vert the Visual Model.<br />

Create a Visual Basic .NET Windows applicati<strong>on</strong> project. The goal in this step is<br />

<strong>on</strong>ly <strong>to</strong> build the shell visually identical <strong>to</strong> the <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms applicati<strong>on</strong>. In this step,<br />

you are c<strong>on</strong>cerned with the <str<strong>on</strong>g>for</str<strong>on</strong>g>m and not the functi<strong>on</strong>. The functi<strong>on</strong>ality will be<br />

addressed in the next step. For example, a DataGrid c<strong>on</strong>trol will be added <strong>to</strong> a<br />

<str<strong>on</strong>g>for</str<strong>on</strong>g>m in this step while the tasks <strong>to</strong> c<strong>on</strong>nect <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> and access data are<br />

per<str<strong>on</strong>g>for</str<strong>on</strong>g>med in the next step.<br />

For each window found in the Visual Model, create a <str<strong>on</strong>g>for</str<strong>on</strong>g>m in the project. In<br />

Visual Basic .NET, the c<strong>on</strong>cept of canvas is handled by the <str<strong>on</strong>g>for</str<strong>on</strong>g>m itself. The frames<br />

in the <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms applicati<strong>on</strong> should be c<strong>on</strong>verted <strong>to</strong> panels in<br />

Visual Basic .NET. The items in a frame should be replaced with its equivalent<br />

c<strong>on</strong>trols. Also add the menu c<strong>on</strong>trols <strong>to</strong> match the <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms applicati<strong>on</strong>.<br />

For steps <strong>on</strong> adding <str<strong>on</strong>g>for</str<strong>on</strong>g>ms <strong>to</strong> a project, refer <strong>to</strong><br />

http://msdn. microsoft.com/library/default.asp?url=/library/enus/vbc<strong>on</strong>/html/vbtskadding<str<strong>on</strong>g>for</str<strong>on</strong>g>m<strong>to</strong>project.asp.<br />

For more in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <strong>on</strong> how <strong>to</strong> add Windows Forms C<strong>on</strong>trols, refer <strong>to</strong><br />

http://msdn.microsoft.com/library/default.asp?url=/library/enus/vbc<strong>on</strong>/html/vboriwin<str<strong>on</strong>g>for</str<strong>on</strong>g>msc<strong>on</strong>trols.asp.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 293<br />

For more in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> about learning the techniques <str<strong>on</strong>g>for</str<strong>on</strong>g> arranging the various<br />

c<strong>on</strong>trols <strong>on</strong> a Windows Form, refer <strong>to</strong><br />

http://msdn.microsoft.com/library/default.asp?url= /library/en-<br />

us/vbc<strong>on</strong>/html/vbc<strong>on</strong><str<strong>on</strong>g>for</str<strong>on</strong>g>msdesigner.asp.<br />

For guidance <strong>on</strong> adding menus, refer <strong>to</strong><br />

http://msdn.microsoft.com/library/default.asp?url=/library/enus/vbc<strong>on</strong>/html/vbc<strong>on</strong>windowsaccessories.asp.<br />

7. C<strong>on</strong>vert the Form Model.<br />

At this stage, all the pieces are in place <strong>to</strong> code the business logic and applicati<strong>on</strong><br />

functi<strong>on</strong>ality. The majority of the work is related <strong>to</strong> c<strong>on</strong>verting the code in the<br />

blocks and items, which was documented in the block document. Because an<br />

almost <strong>on</strong>e-<strong>to</strong>-<strong>on</strong>e mapping of the shared libraries and its objects has been<br />

per<str<strong>on</strong>g>for</str<strong>on</strong>g>med, the code in Visual Basic .NET can be written as a parallel <strong>to</strong> the code in<br />

the source applicati<strong>on</strong>.<br />

a. Start by c<strong>on</strong>verting the comp<strong>on</strong>ents, such as c<strong>on</strong>trol blocks, program units,<br />

record groups, LOVs, and triggers that could be tied <strong>to</strong> multiple c<strong>on</strong>trols.<br />

b. Code all the data comp<strong>on</strong>ents in the <str<strong>on</strong>g>for</str<strong>on</strong>g>m because these could be possibly<br />

associated with multiple c<strong>on</strong>trols. A detailed account <strong>on</strong> how <strong>to</strong> per<str<strong>on</strong>g>for</str<strong>on</strong>g>m this is<br />

provided in the "Adding Data Comp<strong>on</strong>ents <strong>to</strong> a Windows Form" secti<strong>on</strong> later in<br />

this chapter.<br />

c. Complete the migrati<strong>on</strong> of the data block by adding code <strong>to</strong> read data and bind<br />

the grid.<br />

d. Although the grid is bound <strong>to</strong> the dataset you created, the dataset itself is not<br />

au<strong>to</strong>matically filled in. Instead, you must fill the dataset by calling a datas<br />

class file in the<br />

adapter method. Double-click the page <strong>to</strong> display the page'<br />

Code Edi<strong>to</strong>r. In the <str<strong>on</strong>g>for</str<strong>on</strong>g>m's event handler, call the data adapter's Fill method,<br />

passing it the dataset you want <strong>to</strong> populate: SqlDataAdapter1.Fill(dsDept).<br />

e. For more details <strong>on</strong> data binding and Windows Forms, refer <strong>to</strong><br />

http://msdn.microsoft.com/library/default.asp?url=/library/enus/vbc<strong>on</strong>/html/vboriwindows<str<strong>on</strong>g>for</str<strong>on</strong>g>msdataarchitecture.asp.<br />

f. The number of lines of code generated by the Data wizard is far in excess of<br />

what would be required if using Data Access Applicati<strong>on</strong> Block (DAAB) <str<strong>on</strong>g>for</str<strong>on</strong>g><br />

.NET.<br />

g. Examine every c<strong>on</strong>trol and add code <strong>to</strong> the c<strong>on</strong>trol and its event.<br />

h. Achieve the proper flow of executi<strong>on</strong> through navigati<strong>on</strong> rules similar <strong>to</strong> that<br />

seen when executing the <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Form applicati<strong>on</strong> in the debug mode.<br />

Adding Data Comp<strong>on</strong>ents <strong>to</strong> a Windows Form<br />

You do not directly add a dataset <strong>to</strong> a page. Access <strong>to</strong> the dataset can be created in <strong>on</strong>e<br />

of several ways. There are two preferred methods. One method is <strong>to</strong> use the set of visual<br />

objects available in the Toolbox under the Data tab. The other is <strong>to</strong> take advantage of<br />

the Microsoft Data Access Applicati<strong>on</strong> Block <str<strong>on</strong>g>for</str<strong>on</strong>g> .NET.


294 Developing: Applicati<strong>on</strong>s — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms<br />

Using the Visual Studio .NET Data Wizards<br />

Visual Studio® .NET Data Wizards are ADO.NET code genera<strong>to</strong>rs <str<strong>on</strong>g>for</str<strong>on</strong>g> creating access<br />

<strong>to</strong> <strong>SQL</strong> <strong>Server</strong>, OLEDB, <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>, and ODBC data soluti<strong>on</strong>s. There is a small series of data<br />

objects needed <strong>to</strong> generate datasets <strong>to</strong> sources under ADO.NET. They are<br />

DataAdapters, c<strong>on</strong>necti<strong>on</strong>s, commands, and the datasets themselves. C<strong>on</strong>necti<strong>on</strong>s<br />

provide the necessary in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> about data sources, authenticati<strong>on</strong>, and pooling<br />

opti<strong>on</strong>s. Commands define whether the source is queried through s<strong>to</strong>red procedures,<br />

direct table access, or through T-<strong>SQL</strong> Statements. DataAdapters provide a specific pipe<br />

<str<strong>on</strong>g>for</str<strong>on</strong>g> accessing data and trans<str<strong>on</strong>g>for</str<strong>on</strong>g>ming it back <strong>to</strong> the source by creating the Select, Update,<br />

Insert, and Delete commands; creating s<strong>to</strong>red procedures; or using existing s<strong>to</strong>red<br />

procedures. DataSets act as the virtual database <strong>to</strong> the client.<br />

To use the wizards <strong>to</strong> access <strong>SQL</strong> <strong>Server</strong>, follow these steps:<br />

1. Create the SqlAdapter.<br />

From the Toolbox within VS.NET, choose the Data tab and drag the<br />

SqlDataAdapter <strong>on</strong><strong>to</strong> the <str<strong>on</strong>g>for</str<strong>on</strong>g>m area. If other data providers are needed, choose the<br />

appropriate OLEDB or ODBC Data Adapter. The wizard will start, and a<br />

SqlDataAdapter1 object will be created in the Comp<strong>on</strong>ent Tray area beneath the<br />

<str<strong>on</strong>g>for</str<strong>on</strong>g>m.<br />

2. Reference the c<strong>on</strong>necti<strong>on</strong>.<br />

The next step of the wizard is <strong>to</strong> choose from a drop-down list of pre-existing<br />

c<strong>on</strong>necti<strong>on</strong>s used with VS.NET or <strong>to</strong> generate a new c<strong>on</strong>necti<strong>on</strong>. Clicking New<br />

C<strong>on</strong>necti<strong>on</strong> brings up the DataLink Properties dialog box <strong>to</strong> create the new<br />

c<strong>on</strong>necti<strong>on</strong> object.<br />

3. Choose a query type.<br />

The wizard then allows the developer <strong>to</strong> choose between <strong>SQL</strong> statements or<br />

s<strong>to</strong>red procedures. As previously menti<strong>on</strong>ed, it is best <strong>to</strong> use s<strong>to</strong>red procedures<br />

when possible.<br />

4. Generate the <strong>SQL</strong> statements, s<strong>to</strong>red procedures, or bind the commands.<br />

Depending <strong>on</strong> the choice in the previous step, the developer will be given the<br />

opportunity <strong>to</strong> provide or create an appropriate <strong>SQL</strong> statement. Inspecting the<br />

PL/<strong>SQL</strong> code is described earlier in the secti<strong>on</strong> "PL/<strong>SQL</strong> Library."<br />

5. Finish the wizard.<br />

Now the Comp<strong>on</strong>ent Tray c<strong>on</strong>tains both the SqlDataAdapter1 and SqlC<strong>on</strong>necti<strong>on</strong>1<br />

objects. The in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> created from the wizard can be viewed in from the<br />

Properties window of the designer or by looking at the generated code. The<br />

Properties window of the DataAdapter shows the commands chosen (Delete,<br />

Insert, Select, Update) and their respective properties.<br />

6. Generate the DataSet.<br />

Now that the reference has been made <strong>to</strong> the source and the pipe has been<br />

created <strong>to</strong> work with the source, it is necessary <strong>to</strong> provide the client with the result.<br />

The c<strong>on</strong>tainer necessary <str<strong>on</strong>g>for</str<strong>on</strong>g> this is a dataset. Because the dataset is based <strong>on</strong> the<br />

in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> provided by the adapter, Visual Studio .NET has a wizard <strong>to</strong> take<br />

advantage of the in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> s<strong>to</strong>red within the adapter. This is d<strong>on</strong>e by rightclicking<br />

the SqlDataAdapter1 inside the comp<strong>on</strong>ent tray, clicking Generate<br />

dataset, and then choosing most of the defaults (except when the object is<br />

renamed).<br />

Using the Microsoft Data Access Applicati<strong>on</strong> Block<br />

The Data Access Applicati<strong>on</strong> Block encapsulates per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance and resource<br />

management preferred practices <str<strong>on</strong>g>for</str<strong>on</strong>g> accessing <strong>SQL</strong> <strong>Server</strong> databases. If used, it will<br />

reduce the amount of cus<strong>to</strong>m code needed <strong>to</strong> create, test, and maintain.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 295<br />

Specifically, the Data Access Applicati<strong>on</strong> Block helps you:<br />

●<br />

●<br />

●<br />

Call s<strong>to</strong>red procedures or <strong>SQL</strong> text commands.<br />

Specify parameter details.<br />

Return SqlDataReader, DataSet or XMLReader objects.<br />

Instead of using the wizards (which create numerous references <strong>to</strong> adapter, command,<br />

and c<strong>on</strong>necti<strong>on</strong> objects), the Data Access Applicati<strong>on</strong> Block (DAAB) helps limit the<br />

creati<strong>on</strong> of datasets <strong>to</strong> as little as <strong>on</strong>e line of code.<br />

The Data Access Applicati<strong>on</strong> Block is available at<br />

http://www.microsoft.com/downloads/details.aspx?FamilyId=F63D1F0A-9877-4A7B-<br />

88EC-0426B48DF275&displaylang=en. After downloading, compile the assembly in the<br />

VB assembly. It will now be available <strong>to</strong> be referenced by any Visual Basic .NET<br />

applicati<strong>on</strong>.<br />

Calling T-<strong>SQL</strong> S<strong>to</strong>red Procedures from Windows Forms<br />

To call a s<strong>to</strong>red procedure, you first need <strong>to</strong> identify the s<strong>to</strong>red procedure, and then<br />

create a DataReader or DataAdapter object. Each requires a database c<strong>on</strong>necti<strong>on</strong> and a<br />

reference <strong>to</strong> the s<strong>to</strong>red procedure name through the CommandText property. Next, you<br />

set the CommandType property <strong>to</strong> CommandType.S<strong>to</strong>redProcedure. Finally, any<br />

s<strong>to</strong>red procedure parameters need <strong>to</strong> be defined <str<strong>on</strong>g>for</str<strong>on</strong>g> input and/or output in a collecti<strong>on</strong> of<br />

parameter objects. If the DataReader is used, then the developer must fill the appropriate<br />

c<strong>on</strong>trols by iterating though the collecti<strong>on</strong> of rows returned and applying the values <strong>to</strong> the<br />

c<strong>on</strong>trols. If the DataAdapter is used, then a DataSet must be filled and the c<strong>on</strong>trols must<br />

be bound through the DataSource or DataBinding properties.<br />

Testin g the Visual Basic .NET Applicati<strong>on</strong><br />

The Visual Basic .NET applicati<strong>on</strong> is a newly written applicati<strong>on</strong> instead of a migrated<br />

applicati<strong>on</strong>. Even though <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms and Visual Basic are architecturally and<br />

functi<strong>on</strong>ally similar, n<strong>on</strong>e of the code is reusable. Hence the applicati<strong>on</strong> should undergo<br />

unit testing using a procedure that would be followed <str<strong>on</strong>g>for</str<strong>on</strong>g> new development. However, this<br />

newly developed Visual Basic .NET applicati<strong>on</strong> does differ from other new development<br />

projects. Remember that the Visual Basic .NET applicati<strong>on</strong> was designed <strong>to</strong> mimic the<br />

<str<strong>on</strong>g>for</str<strong>on</strong>g>m and functi<strong>on</strong> of the <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms applicati<strong>on</strong>, while most applicati<strong>on</strong>s are develop ed<br />

based <strong>on</strong> documented requirements.<br />

The objective of unit testing is <strong>to</strong> verify that the user interface closely resembles the<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g><br />

Forms applicati<strong>on</strong> and every comp<strong>on</strong>ent functi<strong>on</strong>s correctly. Start by visually<br />

comparing every frame in th e <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms applicati<strong>on</strong> <strong>to</strong> the corresp<strong>on</strong>ding window in<br />

Visual Basic .NET. Ensure that all panels are present. E nsure that all the c<strong>on</strong>trols (items)<br />

are accurately presented <strong>on</strong> the panel. Crosscheck all the visual comp<strong>on</strong>ents against the<br />

Visual Model.<br />

The event models differ from <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms <strong>to</strong> Visual Basic .NET. <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms c<strong>on</strong>tains<br />

a nested hierarchy, with events being fired when moving through the window and its<br />

objects. These have <strong>to</strong> be duplicated in Visual Basic . NET. Verify the behavior by<br />

per<str<strong>on</strong>g>for</str<strong>on</strong>g>ming a walk-through of the entire applicati<strong>on</strong> with tracing and debugging enabled.<br />

The logs can later be reviewed <str<strong>on</strong>g>for</str<strong>on</strong>g> errors and executi<strong>on</strong> sequences. Visual Basic .NET<br />

p rovides a set of methods and properties that help you trace and debug the executi<strong>on</strong>.<br />

Interactive debuggers are also available in the Visual Studio .NET SDK.<br />

The applicati<strong>on</strong> should then be tested <str<strong>on</strong>g>for</str<strong>on</strong>g> functi<strong>on</strong>ality. Start with testing the menus and<br />

then drilling down window-by-window. Test the functi<strong>on</strong>ality<br />

of every c<strong>on</strong>trol. Use the


296 Developing: Applicati<strong>on</strong>s — <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Forms<br />

same set of test cases in both applicati<strong>on</strong>s. Populate the test data in the <str<strong>on</strong>g>for</str<strong>on</strong>g>m and click all<br />

the c<strong>on</strong>trols. Verify that all the functi<strong>on</strong>al areas and navigati<strong>on</strong> match the old applicati<strong>on</strong>.<br />

Validate that the presentati<strong>on</strong> domain screens are all called by the applicati<strong>on</strong>.<br />

For detailed guidance about all aspects of testing your Visual Basic .NET applicati<strong>on</strong> and<br />

the available <strong>to</strong>ols, refer <strong>to</strong><br />

http://msdn.microsoft.com/library/default.asp?url=/library/enus/vsent7/html/vxoriTestingOptimizing.asp.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 297<br />

18<br />

Stabilizing Phase<br />

Introducti<strong>on</strong> and Goals<br />

During this phase, the test team verifies that the soluti<strong>on</strong> meets the defined quality levels<br />

and that the risk of bugs is eliminated or minimized. Any existing bugs should not affect<br />

critical functi<strong>on</strong>ality or per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance. After the soluti<strong>on</strong> has been stabilized, it will be ready<br />

<str<strong>on</strong>g>for</str<strong>on</strong>g> deployment in<strong>to</strong> the producti<strong>on</strong> envir<strong>on</strong>ment. This chapter highlights the processes of<br />

stabilizati<strong>on</strong> as they relate <strong>to</strong> an <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> Microsoft® <strong>SQL</strong> <strong>Server</strong> <strong>on</strong><br />

Windows® migrati<strong>on</strong> project.<br />

The main goals <str<strong>on</strong>g>for</str<strong>on</strong>g> the Stabilizing Phase include:<br />

● Improve the overall quality of the migrated soluti<strong>on</strong> and stabilize <str<strong>on</strong>g>for</str<strong>on</strong>g> release.<br />

● Ensure that the soluti<strong>on</strong> meets the requirements of the project outlined in the<br />

Envisi<strong>on</strong>ing and Planning Phases.<br />

● Assemble all of the comp<strong>on</strong>ents of the soluti<strong>on</strong> and test the entire system be<str<strong>on</strong>g>for</str<strong>on</strong>g>e<br />

deployment.<br />

● Complete and validate documentati<strong>on</strong> that is required <str<strong>on</strong>g>for</str<strong>on</strong>g> deployment, operati<strong>on</strong>s,<br />

and end users.<br />

● Evaluate and mitigate the risks involved in releasing the soluti<strong>on</strong> <str<strong>on</strong>g>for</str<strong>on</strong>g> deployment.<br />

The deliverables produced during the Stabilizing Phase are listed in Table 18.1.<br />

Table 18.1: Deliverables <str<strong>on</strong>g>for</str<strong>on</strong>g> the Stabilizing Phase<br />

Task Deliverables Owner<br />

Testing the soluti<strong>on</strong> Release versi<strong>on</strong>s of source Test Role<br />

code, executables, release<br />

versi<strong>on</strong> of scripts, and<br />

installati<strong>on</strong> documentati<strong>on</strong><br />

Testing the soluti<strong>on</strong> Release versi<strong>on</strong>s of enduser<br />

User Experience Role<br />

training materials and<br />

operati<strong>on</strong>s documentati<strong>on</strong><br />

Testing the soluti<strong>on</strong> Release notes Release Management<br />

Bug tracking and reporting Testing and bug reports Test Role<br />

Piloting the soluti<strong>on</strong> Pilot Review Release Management<br />

Piloting the soluti<strong>on</strong> Project documents Program Management<br />

Piloting the soluti<strong>on</strong> Sign off document Project team


298 Stabilizing Phase<br />

Testing<br />

The Stabilizing Phase c<strong>on</strong>sists of two major activities: testing the soluti<strong>on</strong> and piloting the<br />

soluti<strong>on</strong>. During testing, the entire ecosystem is evaluated, including the hardware,<br />

software, database, c<strong>on</strong>nectivity layer, and the applicati<strong>on</strong>. As a result of the testing,<br />

bugs and issues will be tracked and resolved.<br />

The sec<strong>on</strong>d major activity of the Stabilizing Phase pertains <strong>to</strong> piloting the soluti<strong>on</strong> <strong>to</strong> a<br />

select group c<strong>on</strong>sisting of end users, deployment, and operati<strong>on</strong>s pers<strong>on</strong>nel in the<br />

producti<strong>on</strong> envir<strong>on</strong>ment. Pilot testing also helps anticipate and resolve any issues that<br />

may occur during deployment. While piloting the soluti<strong>on</strong> is opti<strong>on</strong>al, this activity is highly<br />

recommended because comp<strong>on</strong>ents are deployed in<strong>to</strong> the Windows envir<strong>on</strong>ment that<br />

were originally developed <str<strong>on</strong>g>for</str<strong>on</strong>g> another plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m.<br />

Testing is an iterative refinement process and is initiated every time there is a change <strong>to</strong><br />

the soluti<strong>on</strong> (including bug fixes). The occurrence of sec<strong>on</strong>d and third iterati<strong>on</strong>s is<br />

comm<strong>on</strong> in data migrati<strong>on</strong>s involving complex data integrity rules. Applicati<strong>on</strong> testing will<br />

vary based <strong>on</strong> the amount of modificati<strong>on</strong>s needed <strong>to</strong> migrate the soluti<strong>on</strong> applicati<strong>on</strong>.<br />

Fo r example, when an applicati<strong>on</strong> is ported, the code coverage tests may be given<br />

limited importance because the code base has not changed from the existing applicati<strong>on</strong>.<br />

The test team should accumulate complete knowledge of the software's functi<strong>on</strong>ality and<br />

the tests that should be per<str<strong>on</strong>g>for</str<strong>on</strong>g>med <strong>to</strong> verify them. Often, the original design<br />

c<strong>on</strong>siderati<strong>on</strong>s and approach used <strong>to</strong> create the existing soluti<strong>on</strong> are not available <strong>to</strong> the<br />

migrati<strong>on</strong> team. This limits the effective knowledge of the test team. Testing should not<br />

be limited <strong>on</strong>ly <strong>to</strong> the parts that the developers have identified as affected by the<br />

migrati<strong>on</strong>. Changes in the backend database and the envir<strong>on</strong>ment can manifest itself in<br />

unpredictable places.<br />

The project team should reuse test cases from the existing soluti<strong>on</strong>. If n<strong>on</strong>e exist, new<br />

test cases can be created from the business requirements of the existing soluti<strong>on</strong>. Tests<br />

can then be run against both the source and target systems in the migrati<strong>on</strong> project and<br />

the results compared <strong>to</strong> identify deviati<strong>on</strong>s and bugs in the new soluti<strong>on</strong>.<br />

Logs and audit reports that document any defects associated with the applicati<strong>on</strong>s need<br />

<strong>to</strong> be created and published <strong>to</strong> the entire team in c<strong>on</strong>juncti<strong>on</strong> with the tests per<str<strong>on</strong>g>for</str<strong>on</strong>g>med.<br />

This is because the source of the bug and the place where it manifests itself may be<br />

different. For example, even though a problem may be detected in the applicati<strong>on</strong>, the<br />

source may be a database c<strong>on</strong>figurati<strong>on</strong> or a hardware setting.<br />

Each iterati<strong>on</strong> of testing helps make the subsequent iterati<strong>on</strong> more robust and complete<br />

than the previous <strong>on</strong>e. This process must c<strong>on</strong>tinue until an iterati<strong>on</strong> has no excepti<strong>on</strong>s.<br />

The number of tests completed and the defect rate are used <strong>to</strong> measure progress and<br />

schedule c<strong>on</strong><str<strong>on</strong>g>for</str<strong>on</strong>g>mance.<br />

A c omprehensive series of tests is key <strong>to</strong> meeting the goals of the Stabilizing Phase.<br />

The se tests provide assurances of the quality and stability of the soluti<strong>on</strong>. The following<br />

secti<strong>on</strong>s provide in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> about:<br />

● Best practices<br />

● Preparing <str<strong>on</strong>g>for</str<strong>on</strong>g> testing<br />

●<br />

●<br />

●<br />

the <str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g><br />

Types of testing<br />

Bug tracking and reporting<br />

User Acceptance Testing (UAT) and signoff


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 299<br />

This in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> will help you assure the quality and stability of the soluti<strong>on</strong> you have<br />

developed.<br />

Best Practices<br />

When testing a soluti<strong>on</strong>, two important best practices are clearly defining the success<br />

criteria and approaching testing with a zero-defect mindset.<br />

Success Criteria<br />

Judging whether a project has been successful is almost impossible without something <strong>to</strong><br />

measure the project's results against. Success criteria, also called key per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance<br />

indica<strong>to</strong>rs (KPIs), can be created by defining c<strong>on</strong>diti<strong>on</strong>s under which the proposed<br />

soluti<strong>on</strong> will achieve its goals. In a migrati<strong>on</strong> project, the success criteria can be gauged<br />

by the effectiveness of the new soluti<strong>on</strong>. Does it effectively replace the existing soluti<strong>on</strong> in<br />

terms of features, per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance, and functi<strong>on</strong> based <strong>on</strong> results from the test cases?<br />

Note Though measured in the Stabilizing Phase, success criteria <str<strong>on</strong>g>for</str<strong>on</strong>g> a project is<br />

established during the Envisi<strong>on</strong>ing and Planning Phases.<br />

Zero-defect Mindset<br />

The c<strong>on</strong>cept of a zero-defect mindset should encompass the project team's commitment<br />

<strong>to</strong> p roducing the highest quality product possible. Each member is individually<br />

resp<strong>on</strong>sible <str<strong>on</strong>g>for</str<strong>on</strong>g> helping achieve the desired level of quality.<br />

The zero-defect mindset does not mean that the deployed soluti<strong>on</strong> must be flawless;<br />

rather, it specifies a predetermined quality bar <str<strong>on</strong>g>for</str<strong>on</strong>g> the deliverables. Oftentimes, the<br />

project schedule will play a determining fac<strong>to</strong>r in achieving a zero-defect soluti<strong>on</strong>. In<br />

situati<strong>on</strong>s where schedule does not allow <str<strong>on</strong>g>for</str<strong>on</strong>g> complete testing, tests should be prioritized<br />

<strong>to</strong> ensure that all critical functi<strong>on</strong>ality is evaluated.<br />

In additi<strong>on</strong>, the zero-defect mindset c<strong>on</strong>cept should be carried throughout the dynamic<br />

life cycle of the soluti<strong>on</strong>. For example, as the database scales over time, additi<strong>on</strong>al tuning<br />

will be required <strong>to</strong> ensure optimum per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance.<br />

Preparing <str<strong>on</strong>g>for</str<strong>on</strong>g> Testing<br />

Preparati<strong>on</strong> <str<strong>on</strong>g>for</str<strong>on</strong>g> testing involves creating two key items:<br />

● Test envir<strong>on</strong>ment<br />

● Bug tracking system<br />

Each of these items is discussed under the following headings.<br />

The Test Envir<strong>on</strong>ment<br />

The development and test plans provide a list of requirements that must be met by the<br />

test envir<strong>on</strong>ment, and the test envir<strong>on</strong>ment should be set up according <strong>to</strong> them. The test<br />

envir<strong>on</strong>ment should be completely separate from the producti<strong>on</strong> envir<strong>on</strong>ment. Although it<br />

may not mirror the producti<strong>on</strong> envir<strong>on</strong>ment, it is best if it does.<br />

If the development phase is completed, the same hardware and software may be used <strong>to</strong><br />

test the soluti<strong>on</strong>. If the needs <str<strong>on</strong>g>for</str<strong>on</strong>g> the testing envir<strong>on</strong>ment are more demanding, then<br />

additi<strong>on</strong>al resources may be required. In some situati<strong>on</strong>s, it may be necessary <strong>to</strong> scale<br />

the testing based <strong>on</strong> the available hardware.<br />

In MSF, setting up the test envir<strong>on</strong>ment starts <strong>to</strong>ward the end of the Planning Phase. This<br />

is <strong>to</strong> make sure that a test envir<strong>on</strong>ment is available <strong>to</strong> the development team while


300 Stabilizing Phase<br />

individual comp<strong>on</strong>ents are being developed. However, a full-scale test envir<strong>on</strong>ment <strong>to</strong><br />

verify all aspects of an integrated soluti<strong>on</strong> will <strong>on</strong>ly be required in the Stabilizing Phase.<br />

Another c<strong>on</strong>siderati<strong>on</strong> of the testing envir<strong>on</strong>ment is ensuring that it is properly tuned<br />

be<str<strong>on</strong>g>for</str<strong>on</strong>g>e testing commences. Some recommended best practices <str<strong>on</strong>g>for</str<strong>on</strong>g> optimal tuning of<br />

<strong>SQL</strong> <strong>Server</strong> running under Windows 2003 include:<br />

● Format disk partiti<strong>on</strong>s using NTFS 5.0. This file system provides per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance<br />

enhancements in Windows 2003.<br />

● C<strong>on</strong>figure <strong>SQL</strong> <strong>Server</strong> as a stand-al<strong>on</strong>e server. If c<strong>on</strong>figured as a domainc<strong>on</strong>troller,<br />

additi<strong>on</strong>al resources are utilized, and per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance is reduced.<br />

● Set the Applicati<strong>on</strong> Resp<strong>on</strong>se setting <strong>to</strong> optimize <str<strong>on</strong>g>for</str<strong>on</strong>g> background services. This<br />

setting allows background services <strong>to</strong> run at a higher priority than <str<strong>on</strong>g>for</str<strong>on</strong>g>eground<br />

applicati<strong>on</strong>s and is accessed through the System ic<strong>on</strong> in the C<strong>on</strong>trol Panel. This<br />

setting will improve the per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance of <strong>SQL</strong> <strong>Server</strong>.<br />

● Turn off additi<strong>on</strong>al security auditing. This will reduce I/O activities.<br />

● Set the size of PAGEFILE.SYS. M<strong>on</strong>i<strong>to</strong>r the usage of this swap file used by<br />

<strong>SQL</strong> <strong>Server</strong> and resize the resources slightly larger than your needs.<br />

● Turn off unnecessary services. Review all services and determine which can be<br />

turned off.<br />

● Turn off unnecessary network pro<strong>to</strong>cols.<br />

For more in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <strong>on</strong> tuning the test envir<strong>on</strong>ment, refer <strong>to</strong><br />

http://www.microsoft.com/windowsserver2003/evaluati<strong>on</strong>/per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance/tuning.mspx.<br />

Bug Tracking <str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g><br />

An effective bug tracking system is needed <strong>to</strong> make sure that bugs are identified and<br />

issues are not dropped until they have been completely resolved. Projects typically have<br />

several hundreds or thousands of bugs. It is imperative <strong>to</strong> have a robust bug tracking<br />

system in place <strong>to</strong> address these issues.<br />

The bug tracking software <str<strong>on</strong>g>for</str<strong>on</strong>g> the project was selected during the Planning Phase. Using<br />

this software from the beginning of testing allows all bugs identified through the life cycle<br />

of the soluti<strong>on</strong> <strong>to</strong> be tracked in <strong>on</strong>e locati<strong>on</strong>. This testing his<strong>to</strong>ry can also be a useful<br />

reference <str<strong>on</strong>g>for</str<strong>on</strong>g> future releases after the soluti<strong>on</strong> has been deployed.<br />

Bug categorizati<strong>on</strong> is an important c<strong>on</strong>siderati<strong>on</strong> during the c<strong>on</strong>figurati<strong>on</strong> process of the<br />

bug tracking soluti<strong>on</strong>. Variables required by the categorizati<strong>on</strong> may affect the<br />

c<strong>on</strong>figurati<strong>on</strong> of new and existing bug tracking soluti<strong>on</strong>s. These variables include:<br />

● Repeatability. This is a variable that measures how repeatable the issue or bug is.<br />

Repeatability is the percentage of the time the issue or bug manifests itself.<br />

● Visibility. This is a variable that measures the situati<strong>on</strong> or envir<strong>on</strong>ment that must<br />

be established be<str<strong>on</strong>g>for</str<strong>on</strong>g>e the issue or bug manifests itself. For example, if the issue or<br />

bug occurs <strong>on</strong>ly when the user holds down the Shift key while right-clicking the<br />

mouse and viewing the File menu, the percentage of obscurity is likely <strong>to</strong> be high.<br />

● Severity. This is a variable that measures how much impact the issue or bug will<br />

produce in the soluti<strong>on</strong>, in the code, or <strong>to</strong> the users. For example, a bug that<br />

causes the applicati<strong>on</strong> <strong>to</strong> crash would rank higher than situati<strong>on</strong>s that allow the<br />

applicati<strong>on</strong> <strong>to</strong> recover.<br />

These three variables are estimated and assigned <strong>to</strong> each issue or bug by the project<br />

team and are used <strong>to</strong> derive the issue or bug priority.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 301<br />

Note The priority of a bug can be calculated by using the following <str<strong>on</strong>g>for</str<strong>on</strong>g>mula:<br />

(repeatability + visibility) * severity = priority<br />

Types of Testing<br />

Often, the test envir<strong>on</strong>ment is the first place that all of the separate comp<strong>on</strong>ents (that<br />

have been unit tested in the Development Phase) are combined in<strong>to</strong> a fully functi<strong>on</strong>al<br />

versi<strong>on</strong> of the soluti<strong>on</strong>. The first task is <strong>to</strong> ensure that the disparate comp<strong>on</strong>ents of the<br />

soluti<strong>on</strong> integrate properly. Next, ensure that the soluti<strong>on</strong> per<str<strong>on</strong>g>for</str<strong>on</strong>g>ms as expected. The next<br />

series of tests check <strong>to</strong> ensure that the soluti<strong>on</strong> will work properly under heavy<br />

workloads. The final set of tests check the soluti<strong>on</strong> <str<strong>on</strong>g>for</str<strong>on</strong>g> operati<strong>on</strong>al aspects.<br />

The following types of testing are useful in an <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> migrati<strong>on</strong>:<br />

● Integrati<strong>on</strong> testing. Does the soluti<strong>on</strong> work as a cohesive unit?<br />

● Per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance testing. Does the soluti<strong>on</strong> meet the baseline requirements?<br />

● Stress testing. How does the soluti<strong>on</strong> react <strong>to</strong> stresses and workloads?<br />

● Scalability testing. How far will the soluti<strong>on</strong> scale? Can the system handle<br />

increased load by adding new hardware as required?<br />

● Operati<strong>on</strong>al testing. Do the operati<strong>on</strong>al aspects of the system per<str<strong>on</strong>g>for</str<strong>on</strong>g>m as<br />

expected?<br />

Each of these testing types is described under the following headings.<br />

Integrati<strong>on</strong> Testing<br />

The first level of testing in the Stabilizing Phase is integrati<strong>on</strong> testing, an iterative process<br />

in which separate comp<strong>on</strong>ents are combined in<strong>to</strong> larger soluti<strong>on</strong>s until the system is<br />

complete. In integrati<strong>on</strong> testing, the focus is <strong>on</strong> the interfaces between comp<strong>on</strong>ents.<br />

Integrati<strong>on</strong> testing proves that all areas of the system interface with each other correctly<br />

and that there are no gaps in communicati<strong>on</strong>. The final integrati<strong>on</strong> test proves that the<br />

enti re system works as an integrated unit.<br />

Integrati<strong>on</strong> testing will also reveal any issues with shared resources. For instance, if<br />

Pretty Good Privacy (PGP) encrypti<strong>on</strong> is used by more than <strong>on</strong>e applicati<strong>on</strong>, instead of<br />

having a separate key <str<strong>on</strong>g>for</str<strong>on</strong>g> each applicati<strong>on</strong>, multiple applicati<strong>on</strong>s could potentially share a<br />

single key.<br />

If server c<strong>on</strong>solidati<strong>on</strong> is a business goal <str<strong>on</strong>g>for</str<strong>on</strong>g> this soluti<strong>on</strong>, then it has <strong>to</strong> be per<str<strong>on</strong>g>for</str<strong>on</strong>g>med at<br />

this stage. For more in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <strong>on</strong> server c<strong>on</strong>solidati<strong>on</strong>, refer <strong>to</strong><br />

ht tp://www.microsoft.com/downloads/details.aspx?FamilyId=0F70695E-5D0B-4781-<br />

8966-84BE43216F9E&displaylang=en.<br />

Resolving Integrati<strong>on</strong> Issues<br />

The major reas<strong>on</strong>s issues arise during integrati<strong>on</strong> testing are incompatibilities or<br />

inc<strong>on</strong>sistencies in the design or implementati<strong>on</strong> of the interfaces between comp<strong>on</strong>ents. In<br />

a migrati<strong>on</strong> project, such issues are bound <strong>to</strong> occur because of interoperati<strong>on</strong> between<br />

applicati<strong>on</strong>s, changes in command usage, and differences in pro<strong>to</strong>cols between the two<br />

plat<str<strong>on</strong>g>for</str<strong>on</strong>g>ms. Such issues should be logged and <str<strong>on</strong>g>for</str<strong>on</strong>g>warded <strong>to</strong> the development team <str<strong>on</strong>g>for</str<strong>on</strong>g><br />

resoluti<strong>on</strong>. Another comm<strong>on</strong>ly encountered issue is resource shortage because several<br />

comp<strong>on</strong>ents are being assembled <str<strong>on</strong>g>for</str<strong>on</strong>g> the first time. Additi<strong>on</strong>al resources, such as<br />

processor, memory, and s<strong>to</strong>rage, should be made available <strong>to</strong> complete the testing.


302 Stabilizing Phase<br />

Per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance Testing<br />

Per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance testing involves evaluating how well the soluti<strong>on</strong> meets the expected<br />

criteria. Testing <str<strong>on</strong>g>for</str<strong>on</strong>g> per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance can be further defined by two sub-types:<br />

● Applicati<strong>on</strong> per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance testing<br />

● Hardware utilizati<strong>on</strong> per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance testing<br />

Applicati<strong>on</strong> per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance testing in a migrati<strong>on</strong> focuses <strong>on</strong> comparing various speed and<br />

efficiency fac<strong>to</strong>rs between the existing soluti<strong>on</strong> and the migrated soluti<strong>on</strong>. This ensures<br />

that the migrated soluti<strong>on</strong> complies with the expected level of per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance.<br />

These key speed and efficiency fac<strong>to</strong>rs include:<br />

● Throughput. Database throughput measures the <strong>to</strong>tal number of transacti<strong>on</strong>s that<br />

the server can handle in a given time frame. Baseline figures from the existing<br />

soluti<strong>on</strong> are needed <str<strong>on</strong>g>for</str<strong>on</strong>g> comparis<strong>on</strong>. Per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance testing must be executed using<br />

a workload that represents the type of operati<strong>on</strong>s that are most frequently<br />

per<str<strong>on</strong>g>for</str<strong>on</strong>g>med in the producti<strong>on</strong> envir<strong>on</strong>ment.<br />

Note For a detailed discussi<strong>on</strong> of baselines, see Appendix C, "Baselining."<br />

●<br />

Resp<strong>on</strong>se time. Resp<strong>on</strong>se time measures the length of time required <strong>to</strong> return the<br />

first row of the result set.<br />

The following resources can be used <strong>to</strong> c<strong>on</strong>duct per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance testing:<br />

● Checklist: <strong>SQL</strong> <strong>Server</strong> Per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance<br />

http://msdn.microsoft.com/library/default.asp?url=/library/en-<br />

us/dnpag/html/scalenetcheck08.asp.<br />

● Windows 2003 Per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance and Scalability<br />

http://www.microsoft.com/windowsserver2003/evaluati<strong>on</strong>/per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance/perfscaling.<br />

mspx<br />

● Testing <strong>to</strong>ols<br />

http://msdn.microsoft.com/library/default.asp?url=/library/enus/adminsql/ad_perfm<strong>on</strong>_1qgj.asp.<br />

● CPU M<strong>on</strong>i<strong>to</strong>r<br />

http://www.sysinternals.com/ntw2k/freeware/cpum<strong>on</strong>.shtml<br />

● Disk M<strong>on</strong>i<strong>to</strong>r<br />

http://www.sysinternals.com/ntw2k/freeware/diskm<strong>on</strong>.shtml<br />

Testing hardware per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance in a cross-plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m migrati<strong>on</strong> is recommended because<br />

additi<strong>on</strong>al adjustments may need <strong>to</strong> be made <strong>to</strong> the proposed soluti<strong>on</strong>. There are no<br />

reliable benchmarks that can provide equivalency per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance statistics between the<br />

<strong>UNIX</strong> and Windows plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m. The results of benchmarks of the popular Transacti<strong>on</strong><br />

Processing Per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance Council (http://www.tpc.org/) can be used as a guideline. You<br />

should ask the assistance of the vendors in per<str<strong>on</strong>g>for</str<strong>on</strong>g>ming lab testing of your soluti<strong>on</strong> <strong>to</strong> get<br />

more accurate numbers <strong>on</strong> the proposed hardware. This testing validates the hardware<br />

requirements <str<strong>on</strong>g>for</str<strong>on</strong>g> the soluti<strong>on</strong>.<br />

While c<strong>on</strong>ducting per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance tests, capture data regarding the utilizati<strong>on</strong> of resources<br />

such as CPU, memory, disk I/O, and network bandwidth. This is important because if<br />

your testing envir<strong>on</strong>ment is not the same scale as the producti<strong>on</strong> load, then bottlenecks<br />

in these resources may not be discovered until deployment. Resource utilizati<strong>on</strong> data,<br />

captured at various load levels, can be used <strong>to</strong> draw c<strong>on</strong>clusi<strong>on</strong>s about resource<br />

requirements at producti<strong>on</strong> loads.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 303<br />

●<br />

●<br />

<strong>Net</strong>work M<strong>on</strong>i<strong>to</strong>r<br />

http://msdn.microsoft.com/library/default.asp?url=/library/enus/netm<strong>on</strong>/netm<strong>on</strong>/about_network_m<strong>on</strong>i<strong>to</strong>r_2_0.asp<br />

File M<strong>on</strong>i<strong>to</strong>r<br />

http://www.sysinternals.com/ntw2K/source/filem<strong>on</strong>.shtml<br />

Resolving Per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance Issues<br />

Per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance problems can occur because of several reas<strong>on</strong>s: applicati<strong>on</strong> code,<br />

database implementati<strong>on</strong>, hardware c<strong>on</strong>figurati<strong>on</strong>, software c<strong>on</strong>figurati<strong>on</strong>, or resource<br />

availability. The testing team should be able <strong>to</strong> solve c<strong>on</strong>figurati<strong>on</strong> and resource<br />

problems themselves, while issues with the applicati<strong>on</strong> and database should be logged<br />

and <str<strong>on</strong>g>for</str<strong>on</strong>g>warded <strong>to</strong> the development team, al<strong>on</strong>g with any analysis and supporting<br />

evidence <str<strong>on</strong>g>for</str<strong>on</strong>g> resoluti<strong>on</strong>. Additi<strong>on</strong>al resources may have <strong>to</strong> be procured <strong>to</strong> solve resource-<br />

related hardware issues.<br />

Per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance tuning can be an <strong>on</strong>going series of refinements and improvements. A large<br />

amount of in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> regarding per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance tuning is available. For more in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong>,<br />

refer <strong>to</strong> the following resources:<br />

● The Data Tier: An Approach <strong>to</strong> Database Optimizati<strong>on</strong><br />

http://www.microsoft.com/resources/documentati<strong>on</strong>/sql/2000/all/reskit/enus/part10/c3361.mspx<br />

● Improving <strong>SQL</strong> <strong>Server</strong> Per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance includes schemas, queries, indexes,<br />

transacti<strong>on</strong>s, s<strong>to</strong>red procedures, executi<strong>on</strong> plans and tuning <strong>to</strong>pics.<br />

http://msdn.microsoft.com/sql/default.aspx?pull=/library/en-<br />

us/dnpag/html/scalenetchapt14.asp<br />

● How To: Optimize <strong>SQL</strong> Queries<br />

http://msdn.microsoft.com/sql/default.aspx?pull=/library/enus/dnpag/html/scalenethow<strong>to</strong>04.asp<br />

● How To: Optimize <strong>SQL</strong> Indexes<br />

http://msdn.microsoft.com/sql/default.aspx?pull=/library/enus/dnpag/html/scalenethow<strong>to</strong>03.asp<br />

● Microsoft <strong>SQL</strong> <strong>Server</strong> 2000 Index Defragmentati<strong>on</strong> Best Practices<br />

http://www.microsoft. com/technet/prodtechnol/sql/2000/maintain/ss2kidbp.mspx<br />

● Using Views with a View <strong>on</strong> Per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance<br />

http://www.microsoft.com/resources/documentati<strong>on</strong>/sql/2000/all/reskit/en-<br />

us/part10/c3661.mspx<br />

● Microsoft S<strong>to</strong>rage <str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g>s — The Right S<strong>to</strong>rage and Productivity <str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g><br />

http://www.microsoft.com/windowsserversystem/s<strong>to</strong>rage/soluti<strong>on</strong>s/rightsoluti<strong>on</strong>/righ<br />

tsoluti<strong>on</strong>.mspx<br />

Stress Testing<br />

Stress testing is per<str<strong>on</strong>g>for</str<strong>on</strong>g>med <strong>to</strong> determine the load at which the per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance is<br />

unacceptable or the system fails. This involves loading the system bey<strong>on</strong>d the use it was<br />

designed <str<strong>on</strong>g>for</str<strong>on</strong>g> and checking <str<strong>on</strong>g>for</str<strong>on</strong>g> issues. When<br />

per<str<strong>on</strong>g>for</str<strong>on</strong>g>ming stress tests, new bugs or issues<br />

often may surface because of the high stress and load levels. At a minimum, stress<br />

testing should load the system as defined in the business goals.<br />

If the test envir<strong>on</strong>ment is scaled down in relati<strong>on</strong> <strong>to</strong> the producti<strong>on</strong> envir<strong>on</strong>ment, the<br />

limitati<strong>on</strong>s of the testing envir<strong>on</strong>ment in relati<strong>on</strong> <strong>to</strong> the producti<strong>on</strong> envir<strong>on</strong>ment should be<br />

c<strong>on</strong>sidered in the results.


304 Stabilizing Phase<br />

For example, with respect <strong>to</strong> applicati<strong>on</strong>s, there may be a failure when the number of<br />

simultaneous c<strong>on</strong>necti<strong>on</strong>s hit 100. This could be because of the limitati<strong>on</strong> of some<br />

variable associated with the code segment related <strong>to</strong> c<strong>on</strong>necti<strong>on</strong> handling. Similar<br />

problems may be encountered <strong>on</strong>ly during stress testing because there will be<br />

differences in resource c<strong>on</strong>sumpti<strong>on</strong> and low-level implementati<strong>on</strong> of the same functi<strong>on</strong>s<br />

between the <strong>UNIX</strong> and Windows plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m.<br />

Resolving Stress Issues<br />

Stress testing should be per<str<strong>on</strong>g>for</str<strong>on</strong>g>med <strong>on</strong>ly after all issues encountered during per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance<br />

testing have been fixed. Bugs encountered during stress testing can be because of the<br />

applicati<strong>on</strong>, the hardware c<strong>on</strong>figurati<strong>on</strong>, or resource availability. Issues or bugs found with<br />

the applicati<strong>on</strong> have <strong>to</strong> be sent <strong>to</strong> the development team with any pertinent in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong>. If<br />

the issues relate directly <strong>to</strong> hardware or hardware resources, they can be solved by<br />

c<strong>on</strong>figurati<strong>on</strong> or adding additi<strong>on</strong>al resources.<br />

For example, <strong>SQL</strong> <strong>Server</strong> is not c<strong>on</strong>figured <strong>to</strong> take advantage of memory more than 2 GB<br />

by default. If your hardware c<strong>on</strong>tains additi<strong>on</strong>al memory, this issue can be resolved by<br />

correctly c<strong>on</strong>figuring <strong>SQL</strong> <strong>Server</strong> <strong>to</strong> take advantage of the server's available memory.<br />

Microsoft offers two utilities, Read80Trace and OSTRESS, <strong>to</strong> assist in stress testing<br />

<strong>SQL</strong> <strong>Server</strong>. To learn more or download these utilities, refer <strong>to</strong><br />

http://support.microsoft.com/?kbid=887057.<br />

For detailed in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <strong>on</strong> scalability, refer <strong>to</strong> the following resources:<br />

● Scaling out <strong>on</strong> <strong>SQL</strong> <strong>Server</strong><br />

http://www.microsoft.com/resources/documentati<strong>on</strong>/sql/2000/all/reskit/en-<br />

us/part10/c3861.mspx.<br />

● <strong>SQL</strong> <strong>Server</strong> Scalability FAQ<br />

http://www.microsoft.com/sql/techinfo/administrati<strong>on</strong>/2000/scalabilityfaq.asp.<br />

● Microsoft <strong>SQL</strong> <strong>Server</strong> 2000 Scalability Project — <strong>Server</strong> C<strong>on</strong>solidati<strong>on</strong><br />

http://msdn.microsoft.com/library/default.asp?url=/library/enus/dnsql2k/html/sql_asphosting.asp.<br />

● Windows 2003 Per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance and Scalability<br />

http://www.microsoft.com/windowsserver2003/evaluati<strong>on</strong>/per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance/perfscaling.<br />

mspx.<br />

Scalability Testing<br />

Scalability testing is per<str<strong>on</strong>g>for</str<strong>on</strong>g>med <strong>to</strong> determine if the soluti<strong>on</strong> scales <strong>to</strong> handle an increasing<br />

workload. The workload may be increased size, as in Very Large Databases (VLDB), or<br />

more activity, such as transacti<strong>on</strong>s. Activity scalability is measured in number of user<br />

c<strong>on</strong>necti<strong>on</strong>s, requests, reports, <str<strong>on</strong>g>for</str<strong>on</strong>g> example. The overall scalability is also dependent <strong>on</strong><br />

the hardware and the applicati<strong>on</strong>. The applicati<strong>on</strong>'s throughput change as the load is<br />

increased is a measure of its scalability. Also, the throughput may be measured with<br />

increased resources al<strong>on</strong>g with the increased load.<br />

Scalability testing, while similar <strong>to</strong> stress testing, provides additi<strong>on</strong>al in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <strong>to</strong> assist<br />

in future soluti<strong>on</strong> expansi<strong>on</strong> plans. Scalability testing is c<strong>on</strong>ducted <strong>to</strong> record how well the<br />

migrated soluti<strong>on</strong> will scale or increase throughput as the user workload increases. It<br />

differs from stress testing because scalability testing will generally load the soluti<strong>on</strong> far<br />

past the minimum load levels defined in the Planning Phase.<br />

If additi<strong>on</strong>al hardware is available, it is worthwhile <strong>to</strong> determine whether exceeding the<br />

limits of the current soluti<strong>on</strong> requires a simple additi<strong>on</strong> of hardware or a complete<br />

redesign of the system.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 305<br />

Resolving Scalability Issues<br />

Issues of scaling should be documented as c<strong>on</strong>straints of the system. If it is imperative<br />

that the entire system scale <strong>to</strong> a certain point based <strong>on</strong> business goals, but the soluti<strong>on</strong><br />

does not meet these goals, then the resources (mostly hardware) have <strong>to</strong> be reevaluated<br />

by experts. In most cases, vendors can provide support and in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> in this<br />

area.<br />

Operati<strong>on</strong>al Testing<br />

Operati<strong>on</strong>al testing is required <strong>to</strong> ensure that day-<strong>to</strong>-day functi<strong>on</strong>ality and maintainability<br />

is developed and tested. This type of testing includes items such as:<br />

● Backup routines<br />

● Database maintenance tasks and schedules<br />

● Documentati<strong>on</strong> and processes developed <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>on</strong>going support<br />

● Alert and m<strong>on</strong>i<strong>to</strong>ring processes<br />

● Disaster recovery plans<br />

If the soluti<strong>on</strong> is not going <strong>to</strong> be piloted, operati<strong>on</strong>al testing can be expanded <strong>to</strong> ensure<br />

that the operati<strong>on</strong>s team is com<str<strong>on</strong>g>for</str<strong>on</strong>g>table with the processes and procedures needed <strong>to</strong><br />

maintain the system.<br />

Resolving Operati<strong>on</strong>al Issues<br />

Issues during operati<strong>on</strong>al testing are normally because of incomplete documentati<strong>on</strong> of<br />

the system requirements and c<strong>on</strong>figurati<strong>on</strong> with respect <strong>to</strong> comp<strong>on</strong>ents that are found<br />

<strong>on</strong>ly in the producti<strong>on</strong> envir<strong>on</strong>ment. In most cases, the issues will have <strong>to</strong> be handled by<br />

the operati<strong>on</strong>s staff who may seek in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> and expertise from the project team.<br />

Bug Tracking and Reporting<br />

There are several important interim milest<strong>on</strong>es in the iterative process of testing and<br />

refining the soluti<strong>on</strong> be<str<strong>on</strong>g>for</str<strong>on</strong>g>e release. The interim milest<strong>on</strong>es guide the tracking and testing<br />

process. These milest<strong>on</strong>es include:<br />

● Bug c<strong>on</strong>vergence<br />

● Zero bug bounce<br />

● Release candidates<br />

● Golden release<br />

These milest<strong>on</strong>es are discussed under the following headings.<br />

Bug C<strong>on</strong>vergence<br />

Bug c<strong>on</strong>vergence is the point at which the team makes visible progress against the active<br />

bug count. It is the point at which the rate of bugs that are resolved exceeds the rate of<br />

bugs that are found.<br />

Figure 18.1 illustrates bug c<strong>on</strong>vergence.


306 Stabilizing Phase<br />

Figure 18.1<br />

Bug c<strong>on</strong>vergence graph<br />

Because the bug rate will still vary — even after it starts its overall decline — bug<br />

c<strong>on</strong>vergence usually manifests itself as a trend instead of a fixed point in time. After bug<br />

c<strong>on</strong>vergence, the number of bugs should c<strong>on</strong>tinue <strong>to</strong> decrease until the zero bug bounce.<br />

Zero Bug Bounce<br />

Zero bug bounce (ZBB) is the point in the project when development resolves all the<br />

bugs raised by the Test role and there are no active bugs — <str<strong>on</strong>g>for</str<strong>on</strong>g> the moment. Figure 18. 2<br />

illustrates ZBB.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 307<br />

Figure 18.2<br />

Zero bug bounce<br />

After ZBB, the bug peaks should become noticeably smaller and should c<strong>on</strong>tinue <strong>to</strong><br />

decrease until the product is stable enough <strong>to</strong> release.<br />

Careful bug prioritizati<strong>on</strong> is vital because every bug that is fixed creates the risk of<br />

creating a new bug or regressi<strong>on</strong> issue. Achieving ZBB is a clear sign that the team is in<br />

the final stage as it progresses <strong>to</strong>ward a stable product.<br />

Note New bugs will certainly be found after this milest<strong>on</strong>e is reached. But it does mark<br />

the first time that the team can h<strong>on</strong>estly report that there are no active bugs — even if it<br />

is <strong>on</strong>ly temporary. This can help the team maintain focus <strong>on</strong> a zero-defect mindset.<br />

Release Candidates<br />

After the first achievement of zero bug bounce, a series of release candidates are<br />

prepared <str<strong>on</strong>g>for</str<strong>on</strong>g> release <strong>to</strong> the pilot group. Each of these releases is marked as an interim<br />

milest<strong>on</strong>e. The release candidates are made available <strong>to</strong> the pilot group so they can test<br />

it. The users provide feedback <strong>to</strong> the project team, and the project team in turn c<strong>on</strong>tinues<br />

<strong>to</strong> improve the product and resolve bugs that appear during the pilot. As each new<br />

release candidate is built, there should be fewer bugs <strong>to</strong> report, prioritize, and resolve.<br />

The pilot group is discussed in m ore detail in the "Piloting the <str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g>" secti<strong>on</strong> later in<br />

this chapter<br />

Golden Release<br />

Golden release is the release of the product <strong>to</strong> producti<strong>on</strong>. Golden release is a milest<strong>on</strong>e<br />

in the Stabilizing Phase that is identified by the combinati<strong>on</strong> of zero-defect and success<br />

criteria metrics. At golden release, the team must select the release candidate that they<br />

will release <strong>to</strong> producti<strong>on</strong>. The team uses the testing data that is measured against the<br />

zero-defect and success criteria metrics <strong>to</strong> make this selecti<strong>on</strong>.


308 Stabilizing Phase<br />

User Acceptance Testing and Signoff<br />

User acceptance testing (UAT) is an additi<strong>on</strong>al testing process <strong>to</strong> determine if the<br />

soluti<strong>on</strong> meets the cus<strong>to</strong>mer acceptance criteria. Because this is a migrati<strong>on</strong> project, the<br />

database and the existing soluti<strong>on</strong> have already passed these criteria. In most cases,<br />

<strong>on</strong>ly the soluti<strong>on</strong>'s operating envir<strong>on</strong>ment has changed.<br />

In migrati<strong>on</strong> projects, UAT should test whether the new soluti<strong>on</strong> produces the same<br />

results from use cases as the existing soluti<strong>on</strong>. Whenever possible, use acceptance tests<br />

from the existing soluti<strong>on</strong> as a base.<br />

UAT can also affect the database. Part of testing should ensure that the <strong>SQL</strong> <strong>Server</strong><br />

database can be accessed by the client applicati<strong>on</strong>s.<br />

User signoff is obtained when the users agree that the soluti<strong>on</strong> meets the needs of the<br />

end user. The user signoff is proof that the soluti<strong>on</strong> meets the user acceptance criteria in<br />

relati<strong>on</strong> <strong>to</strong> their business requirements. The user signoff indicates that the soluti<strong>on</strong><br />

c<strong>on</strong><str<strong>on</strong>g>for</str<strong>on</strong>g>ms <strong>to</strong> the requirements of the end-user (functi<strong>on</strong>ality) and the enterprise<br />

(per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance), and that the soluti<strong>on</strong> is ready <strong>to</strong> be deployed in<strong>to</strong> producti<strong>on</strong>.<br />

Piloting the <str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g><br />

A pilot program is a test of the soluti<strong>on</strong> in the producti<strong>on</strong> envir<strong>on</strong>ment, and a trial of the<br />

soluti<strong>on</strong> by installers, systems support staff, and end users. The primary purposes of a<br />

pilot are <strong>to</strong> dem<strong>on</strong>strate that the design works in the producti<strong>on</strong> envir<strong>on</strong>ment as expected<br />

and that it meets the organizati<strong>on</strong>'s business requirements. Pilot deployments are often<br />

characterized by a reduced but key feature set of the system or a smaller end-user<br />

group.<br />

The pilot is the last major step be<str<strong>on</strong>g>for</str<strong>on</strong>g>e a full-scale deployment. Be<str<strong>on</strong>g>for</str<strong>on</strong>g>e the pilot, all testing<br />

must be completed. This provides the opportunity <strong>to</strong> integrate and test other pieces of the<br />

producti<strong>on</strong> envir<strong>on</strong>ment that do not have any equivalent in the test envir<strong>on</strong>ment.<br />

The pilot also provides an opportunity <str<strong>on</strong>g>for</str<strong>on</strong>g> users <strong>to</strong> provide feedback about how the<br />

soluti<strong>on</strong> works. This feedback must be used <strong>to</strong> resolve any issues or <strong>to</strong> create a<br />

c<strong>on</strong>tingency plan. The feedback can help the team determine the level of support that<br />

they are likely <strong>to</strong> need after full deployment. Some of the feedback can also c<strong>on</strong>tribute <strong>to</strong><br />

the next versi<strong>on</strong> of the applicati<strong>on</strong>.<br />

Note The success of the pilot c<strong>on</strong>tributes heavily <strong>to</strong> the deployment schedule. Issues<br />

discovered during the pilot can delay deployment until the problems are resolved.<br />

Every migrati<strong>on</strong> situati<strong>on</strong> is unique, and some scenarios may not require a pilot program.<br />

The pilot helps minimize the risks involved with the Deployment Phase. For instance, if<br />

the migrati<strong>on</strong> involves a Perl applicati<strong>on</strong> that is ported <strong>to</strong> run natively <strong>on</strong> the Windows<br />

plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m, the differences within the applicati<strong>on</strong> could be minimal and, depending <strong>on</strong> other<br />

mitigating fac<strong>to</strong>rs, a decisi<strong>on</strong> may be made not <strong>to</strong> pilot the soluti<strong>on</strong>.<br />

A pilot program is highly recommended in situati<strong>on</strong>s where any of the following instances<br />

apply:<br />

● The deployment plan is highly complex and the deployment team requires the<br />

experience of the pilot deployment.<br />

● The soluti<strong>on</strong> is prominent or critical <strong>to</strong> the organizati<strong>on</strong>. If the rollout must go<br />

exactly as planned, a pilot will provide additi<strong>on</strong>al assurance.<br />

● There is a large difference between the producti<strong>on</strong> and test envir<strong>on</strong>ments.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 309<br />

●<br />

There are elements in the producti<strong>on</strong> envir<strong>on</strong>ment that cannot be adequately<br />

verified in the test envir<strong>on</strong>ment.<br />

Preparing <str<strong>on</strong>g>for</str<strong>on</strong>g> the Pilot<br />

A pilot deployment needs <strong>to</strong> be rehearsed <strong>to</strong> minimize the risk of disrupti<strong>on</strong> <str<strong>on</strong>g>for</str<strong>on</strong>g> the pilot<br />

group. At this stage, the development team is per<str<strong>on</strong>g>for</str<strong>on</strong>g>ming last-minute checks and<br />

ensuring that nothing has changed since pre-producti<strong>on</strong> testing. The following tasks need<br />

<strong>to</strong> be completed be<str<strong>on</strong>g>for</str<strong>on</strong>g>e starting the pilot:<br />

● The development team and the pilot participants must clearly agree <strong>on</strong> the success<br />

criteria <str<strong>on</strong>g>for</str<strong>on</strong>g> the pilot. In a migrati<strong>on</strong> project, the main success criteri<strong>on</strong> is that the<br />

new soluti<strong>on</strong> effectively replaces the existing soluti<strong>on</strong>.<br />

● A support structure and issue resoluti<strong>on</strong> process must be in place. This process<br />

may require that the support staff be trained. The procedures used <str<strong>on</strong>g>for</str<strong>on</strong>g> resoluti<strong>on</strong><br />

during a pilot can vary significantly from those used during the deployment and<br />

when in full producti<strong>on</strong>.<br />

● To identify any issues and c<strong>on</strong>firm that the deployment process will work, it is<br />

necessary <strong>to</strong> implement a trial run or a rehearsal of all the elements of the<br />

deployment.<br />

● It is necessary <strong>to</strong> obtain cus<strong>to</strong>mer approval of the pilot plan. Work <strong>on</strong> the pilot plan<br />

starts early during the Planning Phase so that the communicati<strong>on</strong> channels are in<br />

place and the participants are prepared by the time the test team is ready <strong>to</strong> deploy<br />

the pilot.<br />

● Ensure that the plan effectively mirrors the deployment process. For instance, if the<br />

migrati<strong>on</strong> soluti<strong>on</strong> is scheduled <strong>to</strong> be deployed in phases, the entire process<br />

should be replicated <str<strong>on</strong>g>for</str<strong>on</strong>g> the pilot.<br />

Note It is important <strong>to</strong> remember that a pilot program tests and validates the<br />

deployment process as well as the soluti<strong>on</strong>.<br />

A pilot plan should include the following:<br />

● Scope and objectives<br />

● Participating users, locati<strong>on</strong>s, and c<strong>on</strong>tact in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong><br />

● Training plan <str<strong>on</strong>g>for</str<strong>on</strong>g> pilot users<br />

● Support plan <str<strong>on</strong>g>for</str<strong>on</strong>g> the pilot<br />

● Known risks and c<strong>on</strong>tingency plans<br />

● Rollback plan<br />

● Schedule <str<strong>on</strong>g>for</str<strong>on</strong>g> deploying and c<strong>on</strong>ducting the pilot<br />

C<strong>on</strong>ducting the Pilot<br />

C<strong>on</strong>ducting the pilot involves deploying the applicati<strong>on</strong>s and databases that have been<br />

chosen <strong>to</strong> be part of the pilot. The golden release of the soluti<strong>on</strong> is used <str<strong>on</strong>g>for</str<strong>on</strong>g> pilot testing<br />

against an audience c<strong>on</strong>sisting of actual users using real-world scenarios. When the pilot<br />

is c<strong>on</strong>ducted in a producti<strong>on</strong> envir<strong>on</strong>ment, care has <strong>to</strong> be taken <strong>to</strong> ensure that the existing<br />

applicati<strong>on</strong> and databases are not jeopardized. Hence, adequate support has <strong>to</strong> be<br />

provided while c<strong>on</strong>ducting the pilot <strong>to</strong> m<strong>on</strong>i<strong>to</strong>r and fix any issues that arise.<br />

C<strong>on</strong>ducting a pilot also includes testing the accuracy of supporting documentati<strong>on</strong>,<br />

training and other n<strong>on</strong>-code elements, such as cu<strong>to</strong>ver and fallback procedures. Any


310 Stabilizing Phase<br />

changes made <strong>to</strong> these documents during the pilot have <strong>to</strong> be noted and the<br />

documentati<strong>on</strong> updated accordingly.<br />

Note Ultimately, the pilot leads <strong>to</strong> a decisi<strong>on</strong> <strong>to</strong> either proceed with a full deployment<br />

or <strong>to</strong> delay deployment so that issues can be resolved.<br />

Evaluating the Pilot<br />

At the end of the pilot, its success is evaluated <strong>to</strong> determine whether deployment should<br />

begin. The project team then needs <strong>to</strong> decide whether <strong>to</strong> c<strong>on</strong>tinue the project bey<strong>on</strong>d the<br />

pilot.<br />

It is important <strong>to</strong> obtain in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> about both the design process and the deployment<br />

process. Review what worked and what did not work so that it is possible <strong>to</strong> revise and<br />

refine the plan be<str<strong>on</strong>g>for</str<strong>on</strong>g>e deployment. Examples of in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <strong>to</strong> be gathered include:<br />

● Training required <str<strong>on</strong>g>for</str<strong>on</strong>g> using the soluti<strong>on</strong><br />

● Rollout process<br />

● Support required <str<strong>on</strong>g>for</str<strong>on</strong>g> the soluti<strong>on</strong><br />

● Communicati<strong>on</strong>s<br />

● Problems encountered<br />

● Suggesti<strong>on</strong>s <str<strong>on</strong>g>for</str<strong>on</strong>g> improvements<br />

The feedback is used <strong>to</strong> validate that the delivered design meets the design specificati<strong>on</strong>,<br />

and the business requirements. After the data is evaluated, the team must make a<br />

decisi<strong>on</strong>. The team can select <strong>on</strong>e of following strategies:<br />

● Stagger <str<strong>on</strong>g>for</str<strong>on</strong>g>ward. Prepare another release candidate and release it <strong>to</strong> the original<br />

pilot group, then <strong>to</strong> additi<strong>on</strong>al groups. The release <strong>to</strong> more than <strong>on</strong>e group might<br />

have been part of the original plan or might have been a c<strong>on</strong>tingency triggered by<br />

an unacceptable first pilot.<br />

● Roll back. Return the pilot group <strong>to</strong> their pre-pilot state.<br />

● Suspend the pilot. Put the soluti<strong>on</strong> <strong>on</strong> hold or cancel it.<br />

● Patch and c<strong>on</strong>tinue. Fix the build that the pilot is running and c<strong>on</strong>tinue.<br />

● Proceed <strong>to</strong> the Deploying Phase. Move <str<strong>on</strong>g>for</str<strong>on</strong>g>ward <strong>to</strong> deploy the pilot build <strong>to</strong> the full<br />

live producti<strong>on</strong> envir<strong>on</strong>ment.<br />

Finalizing the Release<br />

The Stabilizing Phase culminates in the Release Readiness Approved Milest<strong>on</strong>e. This<br />

milest<strong>on</strong>e occurs when the team has addressed all outstanding issues and has released<br />

the soluti<strong>on</strong> and made it available <str<strong>on</strong>g>for</str<strong>on</strong>g> full deployment. This milest<strong>on</strong>e is the opportunity<br />

<str<strong>on</strong>g>for</str<strong>on</strong>g> cus<strong>to</strong>mers and users, operati<strong>on</strong>s and support pers<strong>on</strong>nel, and key project stakeholders<br />

<strong>to</strong> evaluate the soluti<strong>on</strong> and identify any remaining issues they need <strong>to</strong> address be<str<strong>on</strong>g>for</str<strong>on</strong>g>e<br />

beginning the transiti<strong>on</strong> <strong>to</strong> deployment and, ultimately, release.<br />

After all of the stabilizati<strong>on</strong> tasks are complete, the team must <str<strong>on</strong>g>for</str<strong>on</strong>g>mally agree that the<br />

project has reached the milest<strong>on</strong>e of release readiness. As the team progresses from the<br />

release milest<strong>on</strong>e <strong>to</strong> the next phase of deploying, resp<strong>on</strong>sibility <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>on</strong>-going management<br />

and support of the soluti<strong>on</strong> officially transfers from the project team <strong>to</strong> the operati<strong>on</strong>s and<br />

support teams. By agreeing, team members signify that they are satisfied with the work<br />

that is per<str<strong>on</strong>g>for</str<strong>on</strong>g>med in their areas of resp<strong>on</strong>sibility.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 311<br />

Project teams usually mark the completi<strong>on</strong> of a milest<strong>on</strong>e with a <str<strong>on</strong>g>for</str<strong>on</strong>g>mal sign-off. Key<br />

stakeholders, typically representatives of each team role and any important cus<strong>to</strong>mer<br />

representatives who are not <strong>on</strong> the project team, signal their approval of the milest<strong>on</strong>e by<br />

signing or initialing a document stating that the milest<strong>on</strong>e is complete. The sign-off<br />

document becomes<br />

a project deliverable and is archived <str<strong>on</strong>g>for</str<strong>on</strong>g> future reference.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 313<br />

19<br />

Deploying Phase<br />

Introducti<strong>on</strong> and Goals<br />

After envisi<strong>on</strong>ing, planning, developing, and stabilizing, the soluti<strong>on</strong> is ready <strong>to</strong> be<br />

deployed. The Deploying Phase implements the tested soluti<strong>on</strong> in the producti<strong>on</strong><br />

env ir<strong>on</strong>ment. The migrati<strong>on</strong> project Release Management team deploying the soluti<strong>on</strong><br />

works with the operati<strong>on</strong>s team <strong>to</strong> successfully deploy and stabilize the soluti<strong>on</strong>. At the<br />

close of the Deploying Phase, cus<strong>to</strong>mer approval <str<strong>on</strong>g>for</str<strong>on</strong>g> the migrati<strong>on</strong> is obtained, and the<br />

soluti<strong>on</strong> is transferred <strong>to</strong> the operati<strong>on</strong>s team. It is also possible that the operati<strong>on</strong>s team<br />

handles the deployment with the aid of the project team. Irrespective of which team does<br />

the deployment, the key goal of the Deploying Phase is <strong>to</strong> successfully migrate the new<br />

solu ti<strong>on</strong> in<strong>to</strong> the producti<strong>on</strong> envir<strong>on</strong>ment as smoothly as possible, and with the least<br />

amount of disrupti<strong>on</strong> <strong>to</strong> the business envir<strong>on</strong>ment or the end users.<br />

The deployment rollout should be c<strong>on</strong>ducted as a series of activities. Though you can<br />

abbreviate or combine some of these activities, you cannot skip any of them completely<br />

with out increasing risk <strong>to</strong> the project's success.<br />

Nearly all of these activities are per<str<strong>on</strong>g>for</str<strong>on</strong>g>med in c<strong>on</strong>juncti<strong>on</strong> between the project team and<br />

the operati<strong>on</strong>s team. Coordinati<strong>on</strong> between the two teams is now a critical success<br />

fact or. All decisi<strong>on</strong>s should be agreed up<strong>on</strong> by both of the teams <strong>to</strong> minimize risk. Both<br />

team s are involved with completing the tasks and producing the deliverables shown in<br />

Table 19.1.<br />

Table 19.1: Major Tasks and Deliverables <str<strong>on</strong>g>for</str<strong>on</strong>g> the Deploying Phase<br />

Tasks Deliverables Resp<strong>on</strong>sible Roles<br />

Deploy the soluti<strong>on</strong> Deployment Checklist Release Management<br />

Stabilize the deployment Deployment Checklist Release Management<br />

Obtain the soluti<strong>on</strong> signoff Cus<strong>to</strong>mer Sign Off Product Management<br />

Transfer ownership Project Documents Program Management<br />

Deploying the <str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g><br />

At the close of the Stabilizing Phase, the database and applicati<strong>on</strong>s (server side and<br />

client side) are fully tested and are ready <str<strong>on</strong>g>for</str<strong>on</strong>g> deployment. The release versi<strong>on</strong>s of the<br />

source code, executables, scripts, and other installati<strong>on</strong> in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> are complete and<br />

delivered <strong>to</strong> the deployment team.


314 Deploying Phase<br />

While deployment is often discussed and planned singularly, there are actually three<br />

separate comp<strong>on</strong>ents and technologies that must be deployed in<strong>to</strong> the producti<strong>on</strong><br />

envir<strong>on</strong>ment. These soluti<strong>on</strong> comp<strong>on</strong>ents are:<br />

● Database server<br />

● <strong>Server</strong> side applicati<strong>on</strong>(s)<br />

● Client side applicati<strong>on</strong>(s)<br />

Each of these comp<strong>on</strong>ents is discussed in this secti<strong>on</strong>. Each of these <strong>to</strong>pics is divided<br />

in<strong>to</strong> two sub<strong>to</strong>pics: process and technology. The process sub<strong>to</strong>pics provide an overview<br />

of the intricacies involved with the deployment of each of the soluti<strong>on</strong> comp<strong>on</strong>ents. The<br />

technology sub<strong>to</strong>pics include in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <strong>on</strong> software <strong>to</strong>ols that can assist with the<br />

deployments of the soluti<strong>on</strong> comp<strong>on</strong>ents.<br />

Deploying the Database <strong>Server</strong><br />

The database should be deployed first because the server side and client side<br />

applicati<strong>on</strong>s are dependent <strong>on</strong> it. The process and technology required <str<strong>on</strong>g>for</str<strong>on</strong>g> setting up<br />

database server and implementing databases are discussed under the following<br />

headings.<br />

Process<br />

During the Planning Phase of the migrati<strong>on</strong>, all hardware needs are evaluated and any<br />

required new equipment is acquired. During the Deploying Phase, the server must be set<br />

up and c<strong>on</strong>figured <str<strong>on</strong>g>for</str<strong>on</strong>g> the Windows <strong>Server</strong> 2003 envir<strong>on</strong>ment. The following procedure<br />

describes the steps <str<strong>on</strong>g>for</str<strong>on</strong>g> deploying the database and its server:<br />

1. The server should be built and delivered by your hardware vendor based <strong>on</strong><br />

specificati<strong>on</strong>s defined during the Planning Phase. If the server will be built from<br />

existing equipment, ensure that the server is available and has the required<br />

capacity <strong>to</strong> host the soluti<strong>on</strong>.<br />

2. Install any necessary hardware. Comm<strong>on</strong>ly, items such as additi<strong>on</strong>al memory,<br />

interface cards, additi<strong>on</strong>al s<strong>to</strong>rage, tape drives, or FDDA gigabit switches will need<br />

<strong>to</strong> be installed <strong>to</strong> meet operati<strong>on</strong>al specificati<strong>on</strong>s.<br />

3. Install the operating system, including any necessary service packs and patches.<br />

This step can be per<str<strong>on</strong>g>for</str<strong>on</strong>g>med manually or by using imaging software. This <strong>to</strong>pic is<br />

discussed in greater detail in the technology porti<strong>on</strong> of this secti<strong>on</strong>.<br />

4. C<strong>on</strong>figure any additi<strong>on</strong>al hardware that was installed. For instance, if NIC cards are<br />

installed, they must be c<strong>on</strong>figured <strong>to</strong> match the settings of the network switch they<br />

will c<strong>on</strong>nect <strong>to</strong>.<br />

5. Install any additi<strong>on</strong>al applicati<strong>on</strong>s needed <str<strong>on</strong>g>for</str<strong>on</strong>g> the server, such as m<strong>on</strong>i<strong>to</strong>ring<br />

applicati<strong>on</strong>s, backup software, asset management software, and software delivery<br />

applicati<strong>on</strong>s.<br />

6. Select the deployment mechanism <str<strong>on</strong>g>for</str<strong>on</strong>g> the database. Some possible opti<strong>on</strong>s<br />

include:<br />

● Use au<strong>to</strong>mated processes, such as installati<strong>on</strong> and c<strong>on</strong>figurati<strong>on</strong> scripts,<br />

where possible.<br />

● Use manual processes <str<strong>on</strong>g>for</str<strong>on</strong>g> some installati<strong>on</strong> and c<strong>on</strong>figurati<strong>on</strong>. These must<br />

have detailed, step-by-step instructi<strong>on</strong>s.<br />

7. Create the database deployment package by putting <strong>to</strong>gether the following:<br />

● Microsoft® <strong>SQL</strong> <strong>Server</strong> installati<strong>on</strong> and c<strong>on</strong>figurati<strong>on</strong> scripts.<br />

● Database<br />

administrati<strong>on</strong> <strong>to</strong>ols and utilities.<br />

a


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 315<br />

●<br />

●<br />

●<br />

●<br />

●<br />

●<br />

Database administrati<strong>on</strong> scripts and a scripting language such as Perl.<br />

User database migrati<strong>on</strong> scripts.<br />

Database administrati<strong>on</strong> tasks and packages, such as a maintenance plan,<br />

jobs, and backup and res<strong>to</strong>re procedures.<br />

Windows® domain user accounts c<strong>on</strong>figurati<strong>on</strong> scripts.<br />

Scripts <str<strong>on</strong>g>for</str<strong>on</strong>g> c<strong>on</strong>figuring ODBC data sources, ADO, and OLE DB c<strong>on</strong>necti<strong>on</strong><br />

strings.<br />

Scripts <str<strong>on</strong>g>for</str<strong>on</strong>g> c<strong>on</strong>figuring COM+ comp<strong>on</strong>ents <str<strong>on</strong>g>for</str<strong>on</strong>g> database c<strong>on</strong>necti<strong>on</strong>.<br />

8. Create rollback scripts <strong>to</strong> undo or remove changes introduced by the deployment.<br />

If a parallel cu<strong>to</strong>ver strategy is being employed, the scripts should disable the<br />

replicati<strong>on</strong>. Not every aspect of the fallback can be scripted. A checklist of tasks<br />

with detailed instructi<strong>on</strong>s should be prepared.<br />

9. Add the deployment package <strong>to</strong> the c<strong>on</strong>figurati<strong>on</strong> management database (CMDB).<br />

Maintain change c<strong>on</strong>trol of the release. Where a CMDB does not exist, a simplified<br />

<strong>on</strong>e should be created <str<strong>on</strong>g>for</str<strong>on</strong>g> release-tracking. The purpose of updating the CMDB is<br />

<strong>to</strong> ensure that accurate knowledge is s<strong>to</strong>red regarding all of the comp<strong>on</strong>ents or<br />

c<strong>on</strong>figurati<strong>on</strong> items that make up the releases.<br />

10. Execute deployment package <str<strong>on</strong>g>for</str<strong>on</strong>g> the databases being migrated as per the phase-<br />

12. If a straight cu<strong>to</strong>ver strategy is used, shut down the <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> databases. If a parallel<br />

out strategy.<br />

11. Execute the scripts <strong>to</strong> create the database and its objects. The serial cu<strong>to</strong>ver<br />

strategy will dictate the order in which the databases are migrated.<br />

cu<strong>to</strong>ver is used, the databases may not be shut down. However, a quiet period is<br />

required <strong>to</strong> enable the replicati<strong>on</strong> and ensure that the replicati<strong>on</strong> mechanism is<br />

working properly. Start migrating the data.<br />

13. M<strong>on</strong>i<strong>to</strong>r the data migrati<strong>on</strong> <str<strong>on</strong>g>for</str<strong>on</strong>g> errors. If the migrati<strong>on</strong> has <strong>to</strong> be aborted, the<br />

rollback scripts and other fallback steps should be per<str<strong>on</strong>g>for</str<strong>on</strong>g>med <str<strong>on</strong>g>for</str<strong>on</strong>g> each of the<br />

databases affected by the failure (if the databases are related and have <strong>to</strong> be<br />

migrated <strong>to</strong>gether).<br />

Note If you must deviate from these scripts in the producti<strong>on</strong> envir<strong>on</strong>ment, make<br />

sure <strong>to</strong> alter the scripts <strong>to</strong> reflect the change and enter a note in the script or<br />

documentati<strong>on</strong> regarding what was altered, why, and whether you noticed any<br />

issues afterward.<br />

Technology<br />

Setting up and c<strong>on</strong>figuring servers can be time-c<strong>on</strong>suming, especially if additi<strong>on</strong>al<br />

applicati<strong>on</strong>s are needed <str<strong>on</strong>g>for</str<strong>on</strong>g> operati<strong>on</strong>s, m<strong>on</strong>i<strong>to</strong>ring, reporting, or other purposes. Based<br />

<strong>on</strong> the needs of the deployment, there are two ways <strong>to</strong> deploy the server: manual<br />

deployment and au<strong>to</strong>mated deployment using imaging <strong>to</strong>ols. Imaging <strong>to</strong>ols allow <str<strong>on</strong>g>for</str<strong>on</strong>g><br />

applicati<strong>on</strong>s, operating systems, c<strong>on</strong>figurati<strong>on</strong>s, or drivers <strong>to</strong> be installed in <strong>on</strong>e package,<br />

instead of as individual installati<strong>on</strong>s. However, imaging can <strong>on</strong>ly be useful when setting<br />

up identical servers using<br />

identical hardware, as in a clustered set.<br />

Manual Deployment<br />

If a manual deployment is a c<strong>on</strong>siderati<strong>on</strong>, a few guidelines should be noted. Often,<br />

hardware vendors will provide cus<strong>to</strong>mized installati<strong>on</strong> CDs that c<strong>on</strong>tain specific drivers<br />

and software needed <str<strong>on</strong>g>for</str<strong>on</strong>g> the c<strong>on</strong>figurati<strong>on</strong>. Using these installati<strong>on</strong> discs can reduce the<br />

time needed <str<strong>on</strong>g>for</str<strong>on</strong>g> installati<strong>on</strong>.


316 Deploying Phase<br />

For the detailed manual installati<strong>on</strong> procedure and c<strong>on</strong>figurati<strong>on</strong> of<br />

Windows® 2000 Professi<strong>on</strong>al, Windows® XP, Windows <strong>Server</strong> 2000 Advanced<br />

<strong>Server</strong>, and Windows 2003 <strong>Server</strong> Enterprise Editi<strong>on</strong>, refer <strong>to</strong> the help documentati<strong>on</strong><br />

provided with the Windows operating system CD.<br />

Note Manual installati<strong>on</strong>s of the operating system can be partially au<strong>to</strong>mated using an<br />

answer file. This file provides the input that the setup needs <strong>to</strong> per<str<strong>on</strong>g>for</str<strong>on</strong>g>m the installati<strong>on</strong><br />

and reduces the amount of user interacti<strong>on</strong> needed during the installati<strong>on</strong> process. For<br />

details about creating an answer file and the opti<strong>on</strong>s available in an answer file, refer <strong>to</strong><br />

http://www.microsoft.com/resources/documentati<strong>on</strong>/windows/2000/server/reskit/enus/deploy/dghn_ans_wten.asp.<br />

Another <strong>to</strong>ol that can be utilized <strong>to</strong> assist in manual deployments is Microsoft Remote<br />

Installati<strong>on</strong> Services (RIS). RIS enables you <strong>to</strong> per<str<strong>on</strong>g>for</str<strong>on</strong>g>m system installati<strong>on</strong>s across a<br />

network using an Active Direc<strong>to</strong>ry service. For more in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <strong>on</strong> RIS, refer <strong>to</strong><br />

http://www.microsoft.com/windows2000/techinfo/planning/management/remote steps.asp.<br />

The RDBMS should be installed manually using the Microsoft <strong>SQL</strong> <strong>Server</strong> Software<br />

Distributi<strong>on</strong> CD or a network installati<strong>on</strong> <strong>to</strong>ol such as RIS. For more in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <strong>on</strong> the<br />

installati<strong>on</strong> process <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>SQL</strong> <strong>Server</strong> 2000, refer <strong>to</strong><br />

http://msdn.microsoft.com/library/default.asp?url=/library/enus/instsql/in_overview_0v3l.asp.<br />

Creati<strong>on</strong> of the databases and database objects can be per<str<strong>on</strong>g>for</str<strong>on</strong>g>med using Data Definiti<strong>on</strong><br />

Language (DDL) scripts that have been generated from the test envir<strong>on</strong>ment. This<br />

in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> can also be recreated manually using the Enterprise Manager GUI, but in<br />

most instances the large number of objects that need <strong>to</strong> be created would make this<br />

ef<str<strong>on</strong>g>for</str<strong>on</strong>g>t <strong>to</strong>o time-c<strong>on</strong>suming.<br />

To create a database using the CREATE DATABASE command, refer <strong>to</strong><br />

http://msdn.microsoft.com/library/default.asp?url=/library/enus/tsqlref/ts_create_1up1.asp.<br />

To create a database using the Create Database Wizard in Enterprise Manager, refer <strong>to</strong><br />

http://msdn.microsoft.com/library/default.asp?url=/library/enus/how<strong>to</strong>sql/ht_7_design_4g8p.asp.<br />

DDL scripts can be run using Query Analyzer, a utility installed as part of <strong>SQL</strong> <strong>Server</strong>.<br />

Third-party <strong>SQL</strong> <strong>Server</strong> <strong>to</strong>ols can also be used. For more in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <strong>on</strong> Query Analyzer,<br />

refe r <strong>to</strong> Appendix B.<br />

Au<strong>to</strong>mated Deployment<br />

Imagin g is an alternate method of deploying the operating system and all applicati<strong>on</strong>s<br />

and c<strong>on</strong>figurati<strong>on</strong>s simultaneously. Imaging captures a snapshot of the entire system,<br />

including the operating system, applicati<strong>on</strong>s, desk<strong>to</strong>p settings, and user preferences.<br />

Imagin g <strong>to</strong>ols should be a serious c<strong>on</strong>siderati<strong>on</strong> <str<strong>on</strong>g>for</str<strong>on</strong>g> deployments that c<strong>on</strong>sist of multiple<br />

serv ers that require the same c<strong>on</strong>figurati<strong>on</strong>. Creating images can greatly reduce the time<br />

needed <strong>to</strong> prepare servers <str<strong>on</strong>g>for</str<strong>on</strong>g> deployment and also ensure c<strong>on</strong>sistent c<strong>on</strong>figurati<strong>on</strong>.<br />

To create an image, a master system must be manually c<strong>on</strong>figured with all necessary<br />

software. After the server has been properly c<strong>on</strong>figured, the image is created using<br />

imaging software. Finally, the image can be deployed <strong>to</strong> as many servers as required.<br />

Each will be a cl<strong>on</strong>e of the master system.<br />

The major benefits of using the imaging <strong>to</strong>ols include:<br />

● Deployments can be per<str<strong>on</strong>g>for</str<strong>on</strong>g>med simultaneously. All systems can be running in a<br />

short time.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 317<br />

●<br />

All applicati<strong>on</strong>s are bundled in<strong>to</strong> the image.<br />

The major drawback of imaging is that each type of hardware c<strong>on</strong>figurati<strong>on</strong> requires a<br />

separate image. You can <strong>on</strong>ly install images <strong>on</strong> target computers that have a compatible<br />

hardware abstracti<strong>on</strong> layer (HAL) <strong>to</strong> the reference computer. For instance, if a server<br />

c<strong>on</strong>tains a different graphics card, it would require a separate image.<br />

There are many different <strong>to</strong>ols and utilities available that provide the capability <strong>to</strong> record<br />

and deploy images. Here is a listing of some of these <strong>to</strong>ols:<br />

● Symantec Ghost (also called Nort<strong>on</strong> Ghost) captures a complete system image <str<strong>on</strong>g>for</str<strong>on</strong>g><br />

redistributi<strong>on</strong>. For detailed in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <strong>on</strong> using Symantec Ghost, refer <strong>to</strong><br />

http://service1.symantec.com/SUPPORT/ghost.nsf/pfdocs/.<br />

● Au<strong>to</strong>mated Deployment Services (ADS) is designed <strong>to</strong> deploy Microsoft Windows<br />

2000 <strong>Server</strong>, Advanced <strong>Server</strong> and Datacenter <strong>Server</strong>, and<br />

Windows <strong>Server</strong> 2003 (all 32-bit editi<strong>on</strong>s). Other operating systems are not<br />

currently supported. For detailed in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <strong>on</strong> how <strong>to</strong> use ADS, refer <strong>to</strong><br />

http://www.microsoft.com/windowsserver2003/technologies/management/ads/defa<br />

ult.mspx.<br />

Deploying the <strong>Server</strong> Side Applicati<strong>on</strong>s<br />

The steps <str<strong>on</strong>g>for</str<strong>on</strong>g> building the servers described in the previous secti<strong>on</strong> can also be used <strong>to</strong><br />

prepare the servers <str<strong>on</strong>g>for</str<strong>on</strong>g> the server-side applicati<strong>on</strong>s. Detailed guidance <str<strong>on</strong>g>for</str<strong>on</strong>g> setting up the<br />

server-side applicati<strong>on</strong>s is discussed under the following headings.<br />

Process<br />

Though the server will be set up <strong>to</strong> meet the needs of your specific applicati<strong>on</strong>s,<br />

additi<strong>on</strong>al steps may be needed <strong>to</strong> prepare the hardware <str<strong>on</strong>g>for</str<strong>on</strong>g> deployment.<br />

To deploy server-side applicati<strong>on</strong>s, follow these steps:<br />

1. Install the operating system and third-party comp<strong>on</strong>ents <strong>on</strong> the server as required<br />

by the applicati<strong>on</strong>.<br />

2. C<strong>on</strong>figure the server-side applicati<strong>on</strong> comp<strong>on</strong>ents.<br />

3. Install the server-side comp<strong>on</strong>ents <strong>on</strong> the server.<br />

4. Add all c<strong>on</strong>figurati<strong>on</strong> in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> in<strong>to</strong> the c<strong>on</strong>figurati<strong>on</strong> management database<br />

(CMDB) and maintain change c<strong>on</strong>trol of the release. If a CMDB does not exist, a<br />

simplified <strong>on</strong>e should be created <str<strong>on</strong>g>for</str<strong>on</strong>g> release-tracking. Updating the CMDB ensures<br />

that accurate knowledge is s<strong>to</strong>red regarding all of the comp<strong>on</strong>ents or c<strong>on</strong>figurati<strong>on</strong><br />

items that make up the releases.<br />

5. Deploy the applicati<strong>on</strong>s in c<strong>on</strong>juncti<strong>on</strong> with the deployment strategy being<br />

employed <str<strong>on</strong>g>for</str<strong>on</strong>g> the databases.<br />

6. After the database migrati<strong>on</strong> has been c<strong>on</strong>firmed, per<str<strong>on</strong>g>for</str<strong>on</strong>g>m c<strong>on</strong>figurati<strong>on</strong> changes <strong>to</strong><br />

the envir<strong>on</strong>ment <strong>to</strong> activate the applicati<strong>on</strong>.<br />

7. If a fallback is required, then the applicati<strong>on</strong> should be shut down and the original<br />

c<strong>on</strong>figurati<strong>on</strong> that points all users back <strong>to</strong> the original applicati<strong>on</strong> should be<br />

res<strong>to</strong>red.


318 Deploying Phase<br />

Technology<br />

The server side applicati<strong>on</strong> comp<strong>on</strong>ents can be either deployed manually or by using<br />

imaging as discussed in the "Au<strong>to</strong>mated Deployment" secti<strong>on</strong>.<br />

Manual Deployment<br />

If manual deployment is chosen, each of the comp<strong>on</strong>ents of the server-side applicati<strong>on</strong><br />

should be individually installed. First, install the language envir<strong>on</strong>ments (such as Perl and<br />

PHP) and any third-party utilities using the vendor's software distributi<strong>on</strong>. Then install the<br />

server-side applicati<strong>on</strong> using the golden versi<strong>on</strong> of the source code from the project<br />

team.<br />

Au<strong>to</strong>mated Deployment<br />

The deployment of the server-side applicati<strong>on</strong>s can be au<strong>to</strong>mated by bundling it in<strong>to</strong> the<br />

image. The technology is the same as discussed <str<strong>on</strong>g>for</str<strong>on</strong>g> deploying the database.<br />

Deploying the Client Applicati<strong>on</strong><br />

After the server-side applicati<strong>on</strong>s and databases have been deployed <strong>to</strong> producti<strong>on</strong> and<br />

tested, the client applicati<strong>on</strong> should be released. Often, this stage of the deployment can<br />

be complex because of the number of users and comp<strong>on</strong>ents involved.<br />

This is usually the point in the deployment process where the end users are affected. In<br />

many cases, this is the first time that they are involved in the migrati<strong>on</strong> process. While<br />

this guidance focuses <strong>on</strong> the applicati<strong>on</strong> and database aspects of the migrati<strong>on</strong>, keep in<br />

mind that there are many other items <strong>to</strong> c<strong>on</strong>sider. For instance, documentati<strong>on</strong>, training,<br />

and help desk support also need <strong>to</strong> be in place at the time of this deployment.<br />

It is quite likely that the client computers are already in use. If not, build the hardware <str<strong>on</strong>g>for</str<strong>on</strong>g><br />

the client computers and deploy the required software.<br />

Process<br />

As with the other stages of deployment, the client applicati<strong>on</strong> can be deployed manually<br />

or through the use of au<strong>to</strong>mated <strong>to</strong>ols. C<strong>on</strong>sider the following steps when deploying the<br />

client applicati<strong>on</strong>.<br />

1. Create the deployment package, which can include the following:<br />

● The complete applicati<strong>on</strong>, including the binary installati<strong>on</strong> files and any<br />

au<strong>to</strong>mati<strong>on</strong> files.<br />

● Client c<strong>on</strong>figurati<strong>on</strong> and support files.<br />

● Windows domain user accounts c<strong>on</strong>figurati<strong>on</strong> scripts.<br />

● Scripts <str<strong>on</strong>g>for</str<strong>on</strong>g> c<strong>on</strong>figuring ODBC data sources, ADO, or OLE DB c<strong>on</strong>necti<strong>on</strong><br />

strings.<br />

● Scripts <str<strong>on</strong>g>for</str<strong>on</strong>g> c<strong>on</strong>figuring COM+ comp<strong>on</strong>ents <str<strong>on</strong>g>for</str<strong>on</strong>g> database c<strong>on</strong>necti<strong>on</strong>.<br />

● Acceptance test scripts and packages.<br />

2. Create rollback scripts <strong>to</strong> remove changes introduced by the deployment. Rollback<br />

scripts provide an alternate opti<strong>on</strong> if an uncorrectable issue arises during the<br />

server, database, or applicati<strong>on</strong> deployments.<br />

3. Add the deployment package <strong>to</strong> the c<strong>on</strong>figurati<strong>on</strong> management database (CMDB).<br />

Maintain change c<strong>on</strong>trol of the release. Where a CMDB does not exist, a simplified<br />

<strong>on</strong>e should be<br />

created <str<strong>on</strong>g>for</str<strong>on</strong>g> release-tracking.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 319<br />

4. When the database and applicati<strong>on</strong> migrati<strong>on</strong> are completed successfully, deploy<br />

the client applicati<strong>on</strong>. In additi<strong>on</strong> <strong>to</strong> the database and applicati<strong>on</strong> deployment<br />

strategy, a horiz<strong>on</strong>tal phase-out strategy may be employed <str<strong>on</strong>g>for</str<strong>on</strong>g> client applicati<strong>on</strong>s.<br />

5. If a fallback is required, then the applicati<strong>on</strong> should be rolled back <strong>to</strong> the previous<br />

<strong>on</strong>e and the original c<strong>on</strong>figurati<strong>on</strong> that points all clients back <strong>to</strong> the original<br />

applicati<strong>on</strong> should be res<strong>to</strong>red. If the fallback is due <strong>to</strong> an applicati<strong>on</strong> issue, then a<br />

horiz<strong>on</strong>tal phase-out strategy reduces the rollback ef<str<strong>on</strong>g>for</str<strong>on</strong>g>t.<br />

Technology<br />

When deploying the client applicati<strong>on</strong>, additi<strong>on</strong>al <strong>to</strong>ols may be required <strong>to</strong> efficiently<br />

manage the deployment. Some comm<strong>on</strong> <strong>to</strong>ols used <str<strong>on</strong>g>for</str<strong>on</strong>g> packaging applicati<strong>on</strong>s and<br />

utilizing distributi<strong>on</strong> channels include:<br />

● MSI (or Windows Installer) is a Microsoft soluti<strong>on</strong> <str<strong>on</strong>g>for</str<strong>on</strong>g> applicati<strong>on</strong> packages. This<br />

installer provides additi<strong>on</strong>al functi<strong>on</strong>ality and integrati<strong>on</strong> with the Windows<br />

envir<strong>on</strong>ment, including elevated privileges <str<strong>on</strong>g>for</str<strong>on</strong>g> installati<strong>on</strong> and deployment across<br />

an Active Direc<strong>to</strong>ry. To download Windows Installer or learn more about it, refer <strong>to</strong><br />

http://www.microsoft.com/downloads/details.aspx?FamilyID=5fbc5470-b259-4733-<br />

a914-a956122e08e8&DisplayLang=en.<br />

● Visual Studio Installer creates setups based <strong>on</strong> the Microsoft Windows Installer<br />

technology in the Visual Studio IDE. For detailed step-by-step instructi<strong>on</strong>s <str<strong>on</strong>g>for</str<strong>on</strong>g><br />

Visual Studio Installer, refer <strong>to</strong><br />

http://msdn.microsoft.com/library/default.asp?url=/library/en-<br />

us/vsinstal/html/vehowvisualstudioinstallerquickstart.asp.<br />

● WinINSTALL LE creates packages by recording a snapshot of a systems<br />

envir<strong>on</strong>ment be<str<strong>on</strong>g>for</str<strong>on</strong>g>e and after an applicati<strong>on</strong> is installed, then records all of the<br />

changes between snapshots <strong>to</strong> generate the installati<strong>on</strong> package. For more<br />

in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> about WinINSTALL LE, refer <strong>to</strong><br />

http://www.<strong>on</strong>demandsoftware.com/FREELE2003 /.<br />

● Wise Package Studio is a <strong>to</strong>ol used <str<strong>on</strong>g>for</str<strong>on</strong>g> packaging/repackaging applicati<strong>on</strong>s using<br />

Wise script or an MSI file. Scripts, checks, and c<strong>on</strong>diti<strong>on</strong>s can be embedded in<strong>to</strong><br />

the package, which also helps in deploying or distributing the package. For more<br />

in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <strong>on</strong> Wise Package Studio, refer <strong>to</strong><br />

http://www.wise.com/wps.asp?bhcp=1.<br />

● InstallShield AdminStudio can also create a scripted package file or an MSI<br />

package. The repackaging methodology is same as that of Wise Package Studio.<br />

For more in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> about InstallShield, refer <strong>to</strong><br />

http://www.installshield.com/downloads/isas/evalguide/AdminStudio5_Evalua<strong>to</strong>r_<str<strong>on</strong>g>Guide</str<strong>on</strong>g>.pdf.<br />

● IntelliMirror uses a Windows Installer server <strong>to</strong> provide distributi<strong>on</strong>s <strong>to</strong> client<br />

computers. When an applicati<strong>on</strong> is launched, IntelliMirror checks <strong>to</strong> ensure that the<br />

applicati<strong>on</strong> is loaded and up <strong>to</strong> date. If not, the needed files are downloaded and<br />

installed <strong>on</strong> the system. Because IntelliMirror checks <str<strong>on</strong>g>for</str<strong>on</strong>g> updated versi<strong>on</strong>ing every<br />

time the applicati<strong>on</strong> is launched, this software can be used <strong>to</strong> manage all future<br />

releases of the client applicati<strong>on</strong>. For more details <strong>on</strong> IntelliMirror, refer <strong>to</strong><br />

http://www.microsoft.com/resources/documentati<strong>on</strong>/WindowsServ/2003/standard/p<br />

roddocs/enus/Default.asp?url=/resources/documentati<strong>on</strong>/windowsserv/2003/standard/proddoc<br />

s/en-us/sag_imirror_<strong>to</strong>p_node.asp.<br />

● Windows Installer au<strong>to</strong>matically reads an MSI file and deploys the applicati<strong>on</strong><br />

packaged as an MSI file. The MSI file can be cus<strong>to</strong>mized <str<strong>on</strong>g>for</str<strong>on</strong>g> the features,<br />

installati<strong>on</strong> locati<strong>on</strong>, and so <str<strong>on</strong>g>for</str<strong>on</strong>g>th. Windows Installer can also per<str<strong>on</strong>g>for</str<strong>on</strong>g>m a silent install<br />

of the MSI file when provided with that opti<strong>on</strong>. For an overview of Windows


320 Deploying Phase<br />

●<br />

●<br />

Installer, refer <strong>to</strong><br />

http://www.microsoft.com/windows2000/en/advanced/help/default.asp?url=/window<br />

s2000/en/advanced/help/sag_WinInstall_Technology.htm?id=3991.<br />

Active Direc<strong>to</strong>ry is a core feature in the Windows server operating system which<br />

not <strong>on</strong>ly handles security and privileges of the domain, but also has the capability<br />

<strong>to</strong> distribute MSI files. Group Policy policy settings can be set in Active Direc<strong>to</strong>ry <strong>to</strong><br />

distribute the required MSI file. Active Direc<strong>to</strong>ry can be used efficiently <strong>to</strong> distribute<br />

the files at off hours or weekends <strong>to</strong> avoid blocking network c<strong>on</strong>gesti<strong>on</strong>. For further<br />

in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> about Active Direc<strong>to</strong>ry, refer <strong>to</strong><br />

http://www.microsoft.com/windowsserver2003/technologies/direc<strong>to</strong>ry/activedirec<strong>to</strong>r<br />

y/default.mspx.<br />

Systems Management <strong>Server</strong> (SMS) is a <strong>to</strong>ol from Microsoft <str<strong>on</strong>g>for</str<strong>on</strong>g> distributing<br />

software packages. SMS has various features, such as packaging, distributing,<br />

deploying applicati<strong>on</strong>s, and m<strong>on</strong>i<strong>to</strong>ring. For step-by-step procedures <str<strong>on</strong>g>for</str<strong>on</strong>g> distributing<br />

a package using SMS, refer <strong>to</strong><br />

http://www.microsoft.com/downloads/details.aspx?FamilyID=32f2bb4c-42f8-4b8d-<br />

844f-2553fd78049f&DisplayLang=en<br />

Not<br />

e The <strong>to</strong>ols listed previously have not been tested in a lab envir<strong>on</strong>ment as part of<br />

this soluti<strong>on</strong>.<br />

Change Management<br />

Change management is the process <str<strong>on</strong>g>for</str<strong>on</strong>g> c<strong>on</strong>trolling changes <strong>to</strong> a protected envir<strong>on</strong>ment.<br />

In the Stabilizing Phase, changes are made <strong>to</strong> the test envir<strong>on</strong>ment related <strong>to</strong> bug fixes<br />

and promoting the builds. Changes made <strong>to</strong> the soluti<strong>on</strong> in the producti<strong>on</strong> envir<strong>on</strong>ment<br />

are handled more strictly because they can affect the end users of the applicati<strong>on</strong> as well<br />

as other users of the producti<strong>on</strong> envir<strong>on</strong>ment. Any proposed changes must go through<br />

the change approval process <strong>to</strong> ensure that the changes will not adversely affect the<br />

producti<strong>on</strong> envir<strong>on</strong>ment.<br />

For detailed in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <strong>on</strong> Change Management, refer <strong>to</strong><br />

http://www.microsoft.com/technet/itsoluti<strong>on</strong>s/cits/mo/smf/smfchgmg.mspx.<br />

Stabilizing the Deployment<br />

After the server-side applicati<strong>on</strong> comp<strong>on</strong>ents, database, and client-side applicati<strong>on</strong><br />

comp<strong>on</strong>ents are deployed, every aspect of the deployment must be validated <strong>to</strong> ensure<br />

that the migrati<strong>on</strong> has been per<str<strong>on</strong>g>for</str<strong>on</strong>g>med successfully. Comm<strong>on</strong> items <strong>to</strong> check are<br />

included in the deployment checklist discussed in the following secti<strong>on</strong>s.<br />

Deployment Checklist<br />

The product manager and the operati<strong>on</strong>s team should ensure that the soluti<strong>on</strong> meets the<br />

business requirements and standards determined during the Envisi<strong>on</strong>ing Phase. The<br />

checklist developed during the Planning Phase should c<strong>on</strong>tain the acceptance criteria<br />

that evaluate the per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance of the soluti<strong>on</strong>. It should also provide a baseline <str<strong>on</strong>g>for</str<strong>on</strong>g> the<br />

cus<strong>to</strong>mer <strong>to</strong> approve the soluti<strong>on</strong>. The following categories should be included in the<br />

checklist <strong>to</strong> test the soluti<strong>on</strong> be<str<strong>on</strong>g>for</str<strong>on</strong>g>e signoff:<br />

● <strong>Server</strong><br />

● Database<br />

● Applicati<strong>on</strong> (client and server side)


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 321<br />

●<br />

Additi<strong>on</strong>al c<strong>on</strong>siderati<strong>on</strong>s<br />

These categories are discussed under the following headings.<br />

<strong>Server</strong><br />

The following are some server-related items that should be c<strong>on</strong>sidered <str<strong>on</strong>g>for</str<strong>on</strong>g> the checklist:<br />

●<br />

●<br />

●<br />

●<br />

●<br />

●<br />

●<br />

●<br />

●<br />

●<br />

●<br />

●<br />

●<br />

●<br />

●<br />

●<br />

●<br />

●<br />

●<br />

Have all relevant service packs been loaded <strong>to</strong> the producti<strong>on</strong> servers? Are the OS<br />

and installed service pack level well known and documented? You will need this<br />

in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> if the systems fail and manufacturer support is required.<br />

Have the settings from the per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance tuning in the test envir<strong>on</strong>ment during the<br />

Stabilizing Phase been transferred correctly? At the same time, ensure that any<br />

c<strong>on</strong>figurati<strong>on</strong>s unique <strong>to</strong> the testing envir<strong>on</strong>ment have not been transferred <strong>to</strong> the<br />

producti<strong>on</strong> envir<strong>on</strong>ment.<br />

Have backup power systems been fully tested <strong>to</strong> ensure proper operati<strong>on</strong>?<br />

Are an appropriate number of replacement hard disks <strong>on</strong> hand in case of failure in<br />

an array?<br />

Are the default client c<strong>on</strong>necti<strong>on</strong> network library settings established <strong>on</strong> the server?<br />

Are all database and applicati<strong>on</strong> server installati<strong>on</strong> settings documented (such as<br />

sort orders and default language)?<br />

Has communicati<strong>on</strong> between servers been checked <strong>to</strong> assure that proper DNS<br />

resoluti<strong>on</strong> and routing is functi<strong>on</strong>ing as expected?<br />

Are alerts defined <str<strong>on</strong>g>for</str<strong>on</strong>g> key problems and c<strong>on</strong>diti<strong>on</strong>s? Who m<strong>on</strong>i<strong>to</strong>rs the e-mail<br />

address <strong>to</strong> which these are sent? Are pagers used? Has the alert system been<br />

tested?<br />

Has the team removed guest accounts from the system and checked <strong>to</strong> ensure<br />

that this does not affect the applicati<strong>on</strong>?<br />

Is the appropriate level of direc<strong>to</strong>ry security set?<br />

Has security logging been implemented?<br />

Have all n<strong>on</strong>-essential services and open ports <strong>on</strong> the server been identified and<br />

closed?<br />

Has the team tested producti<strong>on</strong> integrati<strong>on</strong> with third-party systems?<br />

Have any and all event log messages been identified and investigated?<br />

Does the OS have sufficient client access licenses <str<strong>on</strong>g>for</str<strong>on</strong>g> the expected peak traffic<br />

loads?<br />

Are sufficient client access licenses and c<strong>on</strong>necti<strong>on</strong>s installed <str<strong>on</strong>g>for</str<strong>on</strong>g> the OS? Is this<br />

being m<strong>on</strong>i<strong>to</strong>red <strong>to</strong> assure that it does not reach its limit?<br />

Are system c<strong>on</strong>figurati<strong>on</strong>s <str<strong>on</strong>g>for</str<strong>on</strong>g> all tiers backed up? Were scripts created <strong>to</strong> reset<br />

c<strong>on</strong>figurati<strong>on</strong>s in an emergency or <strong>to</strong> bring up a new server? Are they in a wellknown<br />

locati<strong>on</strong>?<br />

Have server backups been tested? Are procedures in place <str<strong>on</strong>g>for</str<strong>on</strong>g> proper s<strong>to</strong>rage and<br />

retrieval?<br />

Have clustering software c<strong>on</strong>figurati<strong>on</strong> and failover operati<strong>on</strong>s been tested?


322 Deploying Phase<br />

Database<br />

The following are some database-related items that should be c<strong>on</strong>sidered <str<strong>on</strong>g>for</str<strong>on</strong>g> the<br />

checklist:<br />

● Have all database creati<strong>on</strong> scripts been executed properly and without errors?<br />

● Were the database statistics updated be<str<strong>on</strong>g>for</str<strong>on</strong>g>e launch?<br />

● Have the database backups been tested <strong>to</strong> ensure that backup mechanisms are<br />

operating properly? Have res<strong>to</strong>rati<strong>on</strong> procedures been tested <strong>on</strong> the soluti<strong>on</strong><br />

server and <strong>on</strong> different hardware <strong>to</strong> test failover procedures? Are off-site backup<br />

procedures in place?<br />

● Has database security been addressed and appropriate log<strong>on</strong> accounts created?<br />

Is the system administra<strong>to</strong>r's (SA) account password blank? Are applicati<strong>on</strong>s using<br />

the SA account or other account(s)?<br />

● Did the team define, test, schedule, and sign-off <strong>on</strong> maintenance plans?<br />

● Has a schedule been established <str<strong>on</strong>g>for</str<strong>on</strong>g> the transacti<strong>on</strong> log dumping that will be<br />

sufficient <strong>to</strong> recover activity <strong>to</strong> the satisfacti<strong>on</strong> of the business? Has it been tested?<br />

● Are sufficient client access licenses installed <str<strong>on</strong>g>for</str<strong>on</strong>g> the database server? Are these<br />

being m<strong>on</strong>i<strong>to</strong>red <strong>to</strong> assure that they do not reach their limit?<br />

● Has the latest build of the database from the development envir<strong>on</strong>ment been<br />

migrated, installed, tested, and verified within the producti<strong>on</strong> envir<strong>on</strong>ment?<br />

● The user databases should be checked <strong>to</strong> ensure that all the data from the<br />

database is transferred from the source soluti<strong>on</strong> <strong>to</strong> the target soluti<strong>on</strong> during<br />

deployment.<br />

● Has the database been loaded in the producti<strong>on</strong> envir<strong>on</strong>ment with clean data, and<br />

have initial inven<strong>to</strong>ry levels been set? Have feeds from other systems been verified<br />

under load <strong>to</strong> ensure that system availability is unaffected at the time they run?<br />

● Is the database running <strong>on</strong> the default port of 1433? If so, can this be changed <strong>to</strong><br />

another port or ports <strong>to</strong> enhance security of the applicati<strong>on</strong> without affecting proper<br />

operati<strong>on</strong>?<br />

● Are n<strong>on</strong>-essential <strong>SQL</strong> <strong>Server</strong> services running (MS Search, OLAP)? S<strong>to</strong>p them if<br />

they are not required.<br />

● Are n<strong>on</strong>-essential databases installed <strong>on</strong> the server? Remove databases such as<br />

pubs or Northwind, but be careful not <strong>to</strong> remove needed system databases such<br />

as model, tempdb, or master.<br />

● Is the database correctly tuned, and does it have the proper memory usage<br />

settings applied?<br />

● Is disk space sufficient <str<strong>on</strong>g>for</str<strong>on</strong>g> the expected size of the data 6-12 m<strong>on</strong>ths ahead?<br />

● Have clustering software c<strong>on</strong>figurati<strong>on</strong> and failover operati<strong>on</strong>s been tested with the<br />

databases?<br />

Applicati<strong>on</strong> (Client Side or <strong>Server</strong> Side)<br />

The following list offers some client-side or server-side applicati<strong>on</strong>-related items that<br />

should be c<strong>on</strong>sidered <str<strong>on</strong>g>for</str<strong>on</strong>g> the checklist:<br />

● Are the proper security settings <str<strong>on</strong>g>for</str<strong>on</strong>g> the applicati<strong>on</strong>s set and documented?<br />

● Has applicati<strong>on</strong> logging been enabled or disabled, as required?<br />

● Has the golden release of the applicati<strong>on</strong>s and other comp<strong>on</strong>ents been given a<br />

release number, archived, then deployed? C<strong>on</strong>firm that the golden release of the<br />

source code matches the versi<strong>on</strong> of the applicati<strong>on</strong> that was released.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 323<br />

●<br />

●<br />

●<br />

●<br />

●<br />

●<br />

●<br />

Are all required envir<strong>on</strong>mental settings <str<strong>on</strong>g>for</str<strong>on</strong>g> the applicati<strong>on</strong>s set and documented?<br />

Are all third-party software or comp<strong>on</strong>ents that are required by the system installed<br />

and documented (such as versi<strong>on</strong> numbers and vendor c<strong>on</strong>tact in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong>)?<br />

Ensure that the client applicati<strong>on</strong> properly c<strong>on</strong>nects <strong>to</strong> the database. Per<str<strong>on</strong>g>for</str<strong>on</strong>g>m<br />

cursory testing of the applicati<strong>on</strong> that is not intrusive and does not change the<br />

producti<strong>on</strong> database. For example, running producti<strong>on</strong> reports is a good way <strong>to</strong><br />

test database functi<strong>on</strong>ality without changing the live data.<br />

Has c<strong>on</strong>nectivity between the middle-tier system and any back-end systems been<br />

tested under load? Has c<strong>on</strong>necti<strong>on</strong> pooling been m<strong>on</strong>i<strong>to</strong>red <strong>to</strong> assure proper<br />

operati<strong>on</strong>?<br />

Are the activati<strong>on</strong> types <str<strong>on</strong>g>for</str<strong>on</strong>g> any COM+ applicati<strong>on</strong>s set properly? Has the<br />

applicati<strong>on</strong> been tested with the c<strong>on</strong>soles logged <strong>on</strong> and logged off <strong>to</strong> assure the<br />

proper identity is used?<br />

Has the applicati<strong>on</strong> integrati<strong>on</strong> been tested with third-party systems?<br />

Have clustering software c<strong>on</strong>figurati<strong>on</strong> and failover operati<strong>on</strong>s been tested with the<br />

applicati<strong>on</strong>s?<br />

Additi<strong>on</strong>al C<strong>on</strong>siderati<strong>on</strong>s<br />

Here are some additi<strong>on</strong>al c<strong>on</strong>siderati<strong>on</strong>s that could apply <strong>to</strong> your envir<strong>on</strong>ment. Some of<br />

the tasks per<str<strong>on</strong>g>for</str<strong>on</strong>g>med here are related <strong>to</strong> operati<strong>on</strong>s. Validating these tasks during<br />

deployment ensures operati<strong>on</strong>s is prepared <strong>to</strong> manage the soluti<strong>on</strong> and SLAs can be<br />

met.<br />

● Are scheduler jobs defined <str<strong>on</strong>g>for</str<strong>on</strong>g> comm<strong>on</strong> tasks? Jobs such as backups and health<br />

reporting are normally scheduled through a scheduler such as cr<strong>on</strong> in <strong>UNIX</strong>.<br />

These may have been migrated over.<br />

● Has a disaster recovery plan (DRP) been established that includes database<br />

procedures?<br />

Who is the DRP team leader? Is the leader's c<strong>on</strong>tact in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> well<br />

known, and is a c<strong>on</strong>tingency leader appointed?<br />

● Has the team enabled change-c<strong>on</strong>trol procedures <str<strong>on</strong>g>for</str<strong>on</strong>g> the operati<strong>on</strong>s envir<strong>on</strong>ment?<br />

● Has the team finalized the operati<strong>on</strong>al processes and guidelines?<br />

● Has the team developed, tested, and simulated disaster recovery procedures?<br />

● Was an external c<strong>on</strong>necti<strong>on</strong> used when testing the applicati<strong>on</strong> against the<br />

operati<strong>on</strong>s system? The external c<strong>on</strong>necti<strong>on</strong> should be similar <strong>to</strong> what a cus<strong>to</strong>mer<br />

will use.<br />

● Was soluti<strong>on</strong> training delivered?<br />

● Is the processing speed acceptable?<br />

● Have the business objectives and requirements been met?<br />

● Have operati<strong>on</strong> tests been per<str<strong>on</strong>g>for</str<strong>on</strong>g>med? Steps should be taken <strong>to</strong> make sure that<br />

the operati<strong>on</strong>s team can properly track the servers and services with their<br />

m<strong>on</strong>i<strong>to</strong>ring <strong>to</strong>ols.<br />

Quiet Period<br />

The quiet period <str<strong>on</strong>g>for</str<strong>on</strong>g> the target envir<strong>on</strong>ment begins after stabilizing the deployed soluti<strong>on</strong><br />

and c<strong>on</strong>tinues until the deployment is complete. It usually exists <str<strong>on</strong>g>for</str<strong>on</strong>g> a period of 15 <strong>to</strong> 30<br />

days. During this period, the operati<strong>on</strong>s team manages the deployed soluti<strong>on</strong>.<br />

No significant changes should be made <strong>to</strong> the soluti<strong>on</strong>. However, a member from the<br />

project team may aid the operati<strong>on</strong>s team <strong>to</strong> manage and resolve problems that can<br />

affect the working of the deployed soluti<strong>on</strong>. This enables the organizati<strong>on</strong> <strong>to</strong> estimate the


324 Deploying Phase<br />

maintenance costs of the soluti<strong>on</strong> and prepare a budget. Changes made <strong>to</strong> the soluti<strong>on</strong><br />

will be through the process of Change Management.<br />

During the quiet period, the efficiency of the soluti<strong>on</strong> can be ascertained by evaluating the<br />

following:<br />

● <str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g>'s stability<br />

● <str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g>'s downtime<br />

● Maintenance required by the soluti<strong>on</strong><br />

Transferring Ownership <strong>to</strong> Operati<strong>on</strong>s<br />

The final transiti<strong>on</strong> occurs when the project team completes its tasks and transfers the<br />

infrastructure, documentati<strong>on</strong>, and operati<strong>on</strong>s <strong>to</strong> the Operati<strong>on</strong>s team. The ownership of<br />

the soluti<strong>on</strong> is also transferred <strong>to</strong> the Operati<strong>on</strong>s team.<br />

The Operati<strong>on</strong>s team has <strong>to</strong> understand the functi<strong>on</strong>ing of the soluti<strong>on</strong> and manage it.<br />

The soluti<strong>on</strong>'s documentati<strong>on</strong> should supply in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> required <strong>to</strong> manage the soluti<strong>on</strong>.<br />

The Operati<strong>on</strong>s team will require the following documents <strong>to</strong> handle the soluti<strong>on</strong> after<br />

migrati<strong>on</strong>:<br />

● User manual. The user manual details the procedures <str<strong>on</strong>g>for</str<strong>on</strong>g> working with the<br />

soluti<strong>on</strong>. It also details the procedures <str<strong>on</strong>g>for</str<strong>on</strong>g> installati<strong>on</strong> and soluti<strong>on</strong> maintenance.<br />

● Hardware specificati<strong>on</strong>s. This document describes the hardware used in the<br />

producti<strong>on</strong> envir<strong>on</strong>ment.<br />

● Software specificati<strong>on</strong>s. This document covers the different applicati<strong>on</strong>s, such as<br />

third-party software used by the soluti<strong>on</strong> itself or used <strong>to</strong> stabilize the deployment.<br />

The software specificati<strong>on</strong>s also detail the different c<strong>on</strong>figurati<strong>on</strong>s and settings<br />

applied <strong>to</strong> the soluti<strong>on</strong> during or after the installati<strong>on</strong> and deployment of the<br />

soluti<strong>on</strong>.<br />

● Support policies and procedures. This document details the updated business<br />

policies and procedures that need <strong>to</strong> be followed after the migrati<strong>on</strong> is complete.<br />

Project Team Tasks<br />

The project team will examine the deployment <strong>to</strong> ensure that all areas of the deployment<br />

are successfully completed and functi<strong>on</strong>ing as required. A final run of the tests that<br />

caused discrepancies can be used <strong>to</strong> check that they have been fixed. The project team<br />

ensures that:<br />

● All the procedures of the migrati<strong>on</strong> have been followed.<br />

● Backups are per<str<strong>on</strong>g>for</str<strong>on</strong>g>med as required.<br />

● All security measures (hardware and software) are in place and operate without<br />

issues.<br />

● All errors and bugs are fixed.<br />

● Adequate training is provided <strong>to</strong> operati<strong>on</strong>s <strong>to</strong> manage the soluti<strong>on</strong>.<br />

● Different user accounts have been created and checked <str<strong>on</strong>g>for</str<strong>on</strong>g> their functi<strong>on</strong>ality.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 325<br />

Operati<strong>on</strong>s Team Tasks<br />

The operati<strong>on</strong>s team will check the soluti<strong>on</strong> <strong>to</strong> ensure that it c<strong>on</strong><str<strong>on</strong>g>for</str<strong>on</strong>g>ms <strong>to</strong> the business<br />

objectives. The operati<strong>on</strong>s team will:<br />

●<br />

●<br />

●<br />

●<br />

●<br />

C<strong>on</strong>duct a final run through of the soluti<strong>on</strong> <strong>to</strong> check its per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance and stability.<br />

Ensure that the project team has completed all the tasks needed <strong>to</strong> complete the<br />

deployment.<br />

Check that the <strong>to</strong>ols <strong>to</strong> per<str<strong>on</strong>g>for</str<strong>on</strong>g>m routine tasks are set up.<br />

Review the documentati<strong>on</strong>.<br />

Decide the frequency <str<strong>on</strong>g>for</str<strong>on</strong>g> per<str<strong>on</strong>g>for</str<strong>on</strong>g>ming routine tasks.<br />

C<strong>on</strong>ducting Project Review and Closure<br />

After the deployment of the soluti<strong>on</strong> is complete, the team c<strong>on</strong>ducts a review meeting <strong>to</strong><br />

assess the migrati<strong>on</strong> project. This review covers all the phases of the migrati<strong>on</strong> project,<br />

including the Envisi<strong>on</strong>ing, Planning, Developing, Stabilizing and Deploying Phases. By<br />

taking the time <strong>to</strong> discuss the entire migrati<strong>on</strong> project, important less<strong>on</strong>s can be learned<br />

and applied <strong>to</strong> future endeavors. This will also highlight the positive acti<strong>on</strong>s taken <strong>to</strong><br />

successfully migrate the soluti<strong>on</strong>, and the less positive decisi<strong>on</strong>s or acti<strong>on</strong>s that delayed<br />

or hindered the migrati<strong>on</strong>. The project review can also compare the estimated outcome of<br />

the migrati<strong>on</strong> project with the actual targets achieved.<br />

The cus<strong>to</strong>mer sign-off signifies the end of the Deploying Phase. The soluti<strong>on</strong>'s key<br />

stakeholders review the migrated soluti<strong>on</strong> and documentati<strong>on</strong> and c<strong>on</strong>firm that the needs<br />

of the project have been met. After this sign-off has been received, the project team can<br />

be disengaged. The exact terms of this sign off will depend <strong>on</strong> the migrati<strong>on</strong> requirements<br />

<str<strong>on</strong>g>for</str<strong>on</strong>g> the project.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 327<br />

20<br />

Operati<strong>on</strong>s<br />

Introducti<strong>on</strong> and Goals<br />

After the soluti<strong>on</strong> has been deployed, the operati<strong>on</strong>s staff inherits ownership of the<br />

soluti<strong>on</strong> and is required <strong>to</strong> manage and maintain it. The operati<strong>on</strong>s team has been<br />

prepared <str<strong>on</strong>g>for</str<strong>on</strong>g> this task by its involvement in the Deploying and Stabilizing Phases and by<br />

reviewing the documentati<strong>on</strong> prepared by the project team. Even if the Windows®<br />

envir<strong>on</strong>ment existed be<str<strong>on</strong>g>for</str<strong>on</strong>g>e the migrati<strong>on</strong>, this project will have a great impact <strong>on</strong><br />

operati<strong>on</strong>al tasks and resp<strong>on</strong>sibilities. This chapter provides additi<strong>on</strong>al links <strong>to</strong> guidance<br />

<strong>on</strong> how <strong>to</strong> operate the producti<strong>on</strong> infrastructure c<strong>on</strong>taining Microsoft® <strong>SQL</strong> <strong>Server</strong> and<br />

Windows technologies.<br />

Operati<strong>on</strong>al Framework<br />

With the penetrati<strong>on</strong> of technology in<strong>to</strong> every aspect of modern day business, success is<br />

based not <strong>on</strong>ly <strong>on</strong> the technology but also <strong>on</strong> the people and processes that c<strong>on</strong>trol the<br />

technology. The migrati<strong>on</strong> project has <strong>on</strong>ly c<strong>on</strong>tributed the technology and not the<br />

operati<strong>on</strong>al aspects of the deployed soluti<strong>on</strong>. Microsoft Operati<strong>on</strong>s Framework (MOF) is a<br />

collecti<strong>on</strong> of best practices, principles, and models. It provides comprehensive technical<br />

guidance <str<strong>on</strong>g>for</str<strong>on</strong>g> achieving missi<strong>on</strong>-critical producti<strong>on</strong> system reliability, availability,<br />

supportability, and manageability <str<strong>on</strong>g>for</str<strong>on</strong>g> soluti<strong>on</strong>s and services built <strong>on</strong> Microsoft products<br />

and technologies.<br />

The following links provide in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> about the operati<strong>on</strong>al framework:<br />

● Microsoft <str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g>s <str<strong>on</strong>g>for</str<strong>on</strong>g> Infrastructure and Management (MSIM) provides in-depth<br />

technical procedural guidance <strong>on</strong> the management and operati<strong>on</strong> of Windowsbased<br />

servers and computer data centers. More in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> is available at<br />

http://www.microsoft.com/tech net/itsoluti<strong>on</strong>s/cits/mo/default.mspx.<br />

● A brief overview of the MOF process model and c<strong>on</strong>cepts is provided in "Appendix<br />

A" of the <strong>UNIX</strong> Migrati<strong>on</strong> Project <str<strong>on</strong>g>Guide</str<strong>on</strong>g> (UMPG):<br />

http://go.microsoft.com/fwlink/?LinkId=19832.<br />

● An entire discussi<strong>on</strong> of MOF, its Service Management Functi<strong>on</strong>s (SMFs), and all<br />

the resources that support the framework, is available at<br />

http://www.microsoft.com/technet/itsoluti<strong>on</strong>s/techguide/mof/m ofpm.mspx.


328 Operati<strong>on</strong>s<br />

Windows Envir<strong>on</strong>ment Operati<strong>on</strong>s<br />

This secti<strong>on</strong> provides in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> about various aspects of a Windows <strong>Server</strong> 2003<br />

deployment in an enterprise envir<strong>on</strong>ment.<br />

System Administrati<strong>on</strong><br />

●<br />

●<br />

For comm<strong>on</strong> administrative tasks, refer <strong>to</strong><br />

http://www.microsoft.com/technet/treeview/default.asp?url=/technet/prodtechnol/wi<br />

ndowsserver2003/proddocs/entserver/ctasks_<strong>to</strong>pnode.asp.<br />

For <strong>to</strong>ols, refer <strong>to</strong><br />

http://www.microsoft.com/windows server2003/downloads/<strong>to</strong>ols/default.mspx.<br />

● The Active Direc<strong>to</strong>ry Operati<strong>on</strong>s <str<strong>on</strong>g>Guide</str<strong>on</strong>g> is available at<br />

http://www.microsoft.com/downloads/details.aspx?familyid=84dfe61e-fb7b-4673-<br />

89b8-55bcc801b431&displaylang=en.<br />

●<br />

●<br />

A technical overview of network load balancing is available at<br />

http://www.microsoft.com/technet/prodtechnol/acs/reskit/acrkappb.mspx.<br />

Security Administrati<strong>on</strong><br />

●<br />

●<br />

●<br />

●<br />

●<br />

●<br />

The Windows <strong>Server</strong> 2003 <str<strong>on</strong>g>Guide</str<strong>on</strong>g> is available at<br />

http://www.microsoft.com/technet/security/prodtech/win2003/w2003hg/sgch00.msp<br />

x.<br />

A source c<strong>on</strong>taining a wide range of security <strong>to</strong>pics and technologies is available at<br />

http://www.microsoft.com/security/guidance/default.mspx.<br />

For best practices <str<strong>on</strong>g>for</str<strong>on</strong>g> implementing a Microsoft Windows <strong>Server</strong> 2003 Public Key<br />

Infrastructure, refer <strong>to</strong><br />

http://www.microsoft.com/technet/prodtechnol/windowsserver2003/technologies/se<br />

curity/ws3pkibp.mspx.<br />

In<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <strong>on</strong> account passwords and policies is available at<br />

http://www.microsoft.com/technet/prodtechnol/windowsserver2003/technologies/se<br />

curity/bpactlck.mspx.<br />

In<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <strong>on</strong> certificate templates is available at<br />

http://www.microsoft.com/technet/prodtechnol/windowsserver2003/technologies/se<br />

curity/ws03crtm.mspx.<br />

The Security Services FAQ is available at<br />

http://www.microsoft.com/resources/documentati<strong>on</strong>/WindowsServ/2003/standard/p<br />

roddocs/enus/Default.asp?url=/resources/documentati<strong>on</strong>/windowsserv/2003/standard/proddoc<br />

s/en-us/safer_how<strong>to</strong>.asp.<br />

Security checklists <str<strong>on</strong>g>for</str<strong>on</strong>g> securing Windows 2003 <strong>Server</strong> are available at<br />

http://www.microsoft.com/security/guidance/checklists/default.mspx.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 329<br />

M<strong>on</strong>i<strong>to</strong>ring<br />

●<br />

●<br />

●<br />

In<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <strong>on</strong> the <strong>to</strong>ols available <str<strong>on</strong>g>for</str<strong>on</strong>g> m<strong>on</strong>i<strong>to</strong>ring is available at<br />

http://www.microsoft.com/resources/documentati<strong>on</strong>/WindowsServ/2003/enterprise/<br />

proddocs/enus/Default.asp?url=/resources/documentati<strong>on</strong>/WindowsServ/2003/enterprise/prodd<br />

ocs/en-us/<strong>to</strong>ols_m<strong>on</strong>i<strong>to</strong>ring_status.asp.<br />

For m<strong>on</strong>i<strong>to</strong>ring of server per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance, refer <strong>to</strong><br />

http://www.microsoft.com/technet/treeview/default.asp?url=/technet/prodtechnol/wi<br />

ndowsserver2003/proddocs/entserver/ctasks019.asp.<br />

For m<strong>on</strong>i<strong>to</strong>ring of security-related events, refer <strong>to</strong><br />

http://www.microsoft.com/technet/treeview/default.asp?url=/technet/prodtechnol/wi<br />

ndowsserver2003/proddocs/entserver/ctasks018.asp.<br />

Additi<strong>on</strong>al Links<br />

●<br />

●<br />

●<br />

In<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <strong>on</strong> Windows <strong>Server</strong> 2003 per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance and scalability is available at<br />

http://www.microsoft.com/windowsserver2003/evaluati<strong>on</strong>/per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance/perfscaling.<br />

mspx.<br />

In<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <strong>on</strong> account management <str<strong>on</strong>g>for</str<strong>on</strong>g> Windows <strong>Server</strong> 2003 is available at<br />

http://www.microsoft.com/business/reducecosts/efficiency/manageability/account.<br />

mspx.<br />

Best practices <str<strong>on</strong>g>for</str<strong>on</strong>g> managing Windows <strong>Server</strong> 2003 are available at<br />

http://www.microsoft.com/technet/community/events/windows2003srv/tnt1-<br />

106.mspx.<br />

<strong>SQL</strong> <strong>Server</strong> Envir<strong>on</strong>ment Operati<strong>on</strong>s<br />

This secti<strong>on</strong> provides in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <strong>on</strong> various aspects of a <strong>SQL</strong> <strong>Server</strong> 2000 deployment<br />

that can be used <strong>to</strong> ensure optimal per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance in an enterprise envir<strong>on</strong>ment.<br />

Per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance is also critical <strong>to</strong> scalability.<br />

Administrati<strong>on</strong><br />

● For detailed in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <strong>on</strong> <strong>SQL</strong> <strong>Server</strong> administrati<strong>on</strong>, refer <strong>to</strong><br />

http://msdn.microsoft.com/library/default.asp?url=/library/enus/adminsql/ad_adminovw_7f3m.asp.<br />

● In<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> about administrati<strong>on</strong> subjects is available at<br />

http://www.microsoft.com/sql/techinfo/administrati<strong>on</strong>/2000/default.asp.<br />

● For detailed discussi<strong>on</strong>s <strong>on</strong> <strong>to</strong>pics such as indexes, statistics, au<strong>to</strong>mati<strong>on</strong>, and<br />

memory management, refer <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> 2000 Operati<strong>on</strong>s <str<strong>on</strong>g>Guide</str<strong>on</strong>g>: System<br />

Administrati<strong>on</strong> at<br />

http://www.microsoft.com/technet/prodtechnol/sql/2000/maintain/sqlops4.mspx.<br />

● In<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> about backup and recovery is available at<br />

http://msdn.microsoft.com/library/default.asp?url=/library/enus/adminsql/ad_bkprst_9zcj.asp.<br />

● A discussi<strong>on</strong> <strong>on</strong> recovery models is available at<br />

http://msdn.microsoft.com/library/default.asp?url=/library/enus/dnsqlmag2k/html/dbRecovery.asp.


330 Operati<strong>on</strong>s<br />

Security<br />

For detailed discussi<strong>on</strong> <strong>on</strong> managing security, refer <strong>to</strong><br />

http://msdn.microsoft.com/library/default.asp?url=/library/enus/adminsql/ad_security_05bt.asp.<br />

M<strong>on</strong>i<strong>to</strong>ring<br />

For m<strong>on</strong>i<strong>to</strong>ring of system per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance and activity, refer <strong>to</strong><br />

http://msdn.microsoft.com/library/default.asp?url=/library/enus/adminsql/ad_m<strong>on</strong>_perf_00mr.asp.<br />

Additi<strong>on</strong>al Links<br />

The following links provide in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <strong>on</strong> <strong>SQL</strong> <strong>Server</strong> 2000 envir<strong>on</strong>ment operati<strong>on</strong>s:<br />

●<br />

●<br />

In<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> about security patch management <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>SQL</strong> <strong>Server</strong> is available at<br />

http://www.microsoft.com/business/reducecosts/efficiency/manageability/patch.ms<br />

px.<br />

The <strong>SQL</strong> <strong>Server</strong> 2000 Operati<strong>on</strong>s <str<strong>on</strong>g>Guide</str<strong>on</strong>g> is available at<br />

http://www.microsoft.com/technet/prodtechnol/sql/2000/maintain/sqlops0.mspx.<br />

Also refer <strong>to</strong> Appendix B, "Getting the Best out of <strong>SQL</strong> <strong>Server</strong> 2000 and Windows," <str<strong>on</strong>g>for</str<strong>on</strong>g><br />

links <strong>to</strong> additi<strong>on</strong>al in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> about per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance,<br />

scalability, and high availability.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 331<br />

APPENDICES<br />

Appendix A: <strong>SQL</strong> <strong>Server</strong> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Professi<strong>on</strong>als<br />

One of the assumpti<strong>on</strong>s of this guide has been that both <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and<br />

Microsoft® <strong>SQL</strong> <strong>Server</strong> database administrati<strong>on</strong> experience is available in the project<br />

team. The success of the migrati<strong>on</strong> depends <strong>on</strong> how well the requirements of the current<br />

envir<strong>on</strong>ment are translated in<strong>to</strong> the <strong>SQL</strong> <strong>Server</strong> envir<strong>on</strong>ment. The knowledge and<br />

involvement of the cus<strong>to</strong>dians of the current envir<strong>on</strong>ment, the <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> DBAs, is very<br />

important. A separate set of <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong> DBAs working <strong>on</strong> the migrati<strong>on</strong> has<br />

the disadvantage of possible communicati<strong>on</strong> problems and cost. Hence training the<br />

Ora<br />

cle DBAs in <strong>SQL</strong> <strong>Server</strong> will serve the purpose of per<str<strong>on</strong>g>for</str<strong>on</strong>g>ming the migrati<strong>on</strong>, retaining<br />

DBAs with valuable knowledge of the business and the databases, and preparing them <strong>to</strong><br />

manage the new <strong>SQL</strong> <strong>Server</strong> envir<strong>on</strong>ment.<br />

The purpose of this appendix is <strong>to</strong> provide a primer <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> DBAs in the workings of<br />

<strong>SQL</strong> <strong>Server</strong> and its administrati<strong>on</strong>. The transiti<strong>on</strong> from <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> is eased by<br />

the<br />

several similarities that exist between the two RDBMSs. Some of the key<br />

comm<strong>on</strong>alities include:<br />

● Relati<strong>on</strong>al engine. Both <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong> use an optimizer <strong>to</strong> generate an<br />

optimal executi<strong>on</strong> plan from alternative soluti<strong>on</strong>s using statistics and access paths.<br />

The executi<strong>on</strong> plan can be influenced by optimizer hints.<br />

● Process architecture. Both <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong> have specialized processes<br />

<str<strong>on</strong>g>for</str<strong>on</strong>g> user c<strong>on</strong>necti<strong>on</strong>s (shared) and dedicated database functi<strong>on</strong>s. <strong>SQL</strong> <strong>Server</strong> uses<br />

threads and provides CPU affinity, features that are found in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> Microsoft<br />

Windows®.<br />

● Memory architecture. In both <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong>, memory is broken up in<strong>to</strong><br />

buffers or caches with separate memory areas <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>SQL</strong>, procedural <strong>SQL</strong>, data<br />

dicti<strong>on</strong>ary, and sessi<strong>on</strong>. Database buffers or caches are manipulated in terms of<br />

pages/blocks. Both have similar buffer replacement policies (Least Recently Used<br />

policy).<br />

● S<strong>to</strong>rage architecture. In both <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong>, the physical database is<br />

structured as data files, system files, transacti<strong>on</strong> logs, and c<strong>on</strong>trol files. Logical<br />

structures <strong>to</strong> complement the physical structures are hierarchical in nature.<br />

● Backup opti<strong>on</strong>s. <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong> provide various opti<strong>on</strong>s <str<strong>on</strong>g>for</str<strong>on</strong>g> backing up<br />

databases, such as <strong>on</strong>line backups, full and partial backups, and transacti<strong>on</strong> log<br />

backups.<br />

● Recovery model. Both <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong> use transacti<strong>on</strong> logs (redo) and<br />

rollback. Recovery is possible using single file backups, transacti<strong>on</strong> logs, and so<br />

<strong>on</strong>.<br />

● Tools. Both <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong> employ Enterprise Manager, <strong>SQL</strong> client<br />

Architecture<br />

An understanding of <strong>SQL</strong> <strong>Server</strong> architecture and how it compares and c<strong>on</strong>trasts with<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> is fundamental in shaping the migrati<strong>on</strong> as well as extracting the optimal<br />

per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance out of the <strong>SQL</strong> <strong>Server</strong> plat<str<strong>on</strong>g>for</str<strong>on</strong>g>m.


332 Appendices<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong> are very similar in their architecture and internal workings.<br />

However, the same terms have different meanings in the two envir<strong>on</strong>ments. For example,<br />

in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> the term instance is used <str<strong>on</strong>g>for</str<strong>on</strong>g> the memory and processes that support an <str<strong>on</strong>g>Oracle</str<strong>on</strong>g><br />

database. However, in <strong>SQL</strong> <strong>Server</strong>, the term instance c<strong>on</strong>tains the memory, processes,<br />

and also the user databases. Irrespective of the terminologies used, <strong>SQL</strong> <strong>Server</strong> also<br />

uses memory and process comp<strong>on</strong>ents in a manner similar <strong>to</strong> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>. In this discussi<strong>on</strong>,<br />

<strong>SQL</strong> <strong>Server</strong> is presented <strong>to</strong> the <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> DBA using an <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>-like view.<br />

Database and Instance<br />

A database, by definiti<strong>on</strong>, is the reposi<strong>to</strong>ry <str<strong>on</strong>g>for</str<strong>on</strong>g> data and metadata (data dicti<strong>on</strong>ary). This<br />

definiti<strong>on</strong> is universal in nature. In <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>, the term database is used <strong>to</strong> specifically refer<br />

<strong>to</strong> the files that are used <strong>to</strong> s<strong>to</strong>re the database's data and metadata. The term instance is<br />

used <str<strong>on</strong>g>for</str<strong>on</strong>g> the memory structures (System Global Area is the main comp<strong>on</strong>ent) and<br />

processes that are required <strong>to</strong> access and per<str<strong>on</strong>g>for</str<strong>on</strong>g>m work against the database. In <strong>SQL</strong><br />

<strong>Server</strong>, the instance is used collectively <str<strong>on</strong>g>for</str<strong>on</strong>g> the data files, memory, and processes. Figure<br />

A.1 illustrates the similarities between instances of <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong> with respect<br />

<strong>to</strong> memory and processes. Only the important comp<strong>on</strong>ents of an instance—the SGA and<br />

the processes — are covered in the figure. Details of the <strong>SQL</strong> <strong>Server</strong> architecture can be<br />

found at http://msdn.microsoft.com/<strong>SQL</strong>/sqlarchitecture/default.aspx.<br />

Figure A.1<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong> 2000 – High level comparis<strong>on</strong> of Instance and Database in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong><br />

<strong>Server</strong> <strong>to</strong> show architectural similarities<br />

Apart from the defined meaning of the terms instance and database in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong><br />

<strong>Server</strong>, the terms are used very loosely <strong>to</strong> mean an occurrence of the database. The<br />

phrase “multiple instances or multiple databases running <strong>on</strong> a single database server” is<br />

a typical usage of this terminology. Database administra<strong>to</strong>rs should be able <strong>to</strong> infer the<br />

meaning from the c<strong>on</strong>text.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 333<br />

What can be c<strong>on</strong>fusing with <strong>SQL</strong> <strong>Server</strong> is the presence of several system and usercreated<br />

“databases” inside a <strong>SQL</strong> <strong>Server</strong> database. Hence the term database system<br />

has been coined here <strong>to</strong> mean an occurrence of <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> or <strong>SQL</strong> <strong>Server</strong>. Multiple<br />

Database Systems (Instances)<br />

In <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>, multiple database systems can be created <strong>on</strong> a single server and the creati<strong>on</strong><br />

is independent of the software installati<strong>on</strong> (using the CREATE DATABASE <strong>SQL</strong><br />

command). The same is not true with <strong>SQL</strong> <strong>Server</strong>. The initial database system (default or<br />

named) is created as part of the software installati<strong>on</strong>. The software distributi<strong>on</strong> is also<br />

needed <strong>to</strong> create additi<strong>on</strong>al database systems. For in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <strong>on</strong> working with named<br />

and multiple instances of <strong>SQL</strong> <strong>Server</strong> 2000, refer <strong>to</strong><br />

http://msdn.microsoft.com/library/default.asp?url=/library/en-<br />

us/instsql/in_runsetup_2xmb.asp.<br />

The following comp<strong>on</strong>ents are shared between all of the instances running <strong>on</strong> the same<br />

computer:<br />

● There is <strong>on</strong>ly <strong>on</strong>e <strong>SQL</strong> <strong>Server</strong> 2000 program group (Microsoft <strong>SQL</strong> <strong>Server</strong>) <strong>on</strong> the<br />

computer, and <strong>on</strong>ly <strong>on</strong>e copy of the utility represented by each ic<strong>on</strong> in the program<br />

group. There is <strong>on</strong>ly <strong>on</strong>e copy of <strong>SQL</strong> <strong>Server</strong> Books Online.<br />

● The versi<strong>on</strong>s of the utilities in the program group are from the first versi<strong>on</strong> of <strong>SQL</strong><br />

<strong>Server</strong> installed <strong>on</strong> the computer.<br />

● There is <strong>on</strong>ly <strong>on</strong>e copy of the MSSearchService that manages full-text searches<br />

against all of the instances of <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> the computer.<br />

● There is <strong>on</strong>ly <strong>on</strong>e copy each of the English Query and Microsoft <strong>SQL</strong> <strong>Server</strong> 2000<br />

Analysis Services servers.<br />

● The registry keys associated with the client software are not duplicated between<br />

instances.<br />

● There is <strong>on</strong>ly <strong>on</strong>e copy of the <strong>SQL</strong> <strong>Server</strong> development libraries (include and .lib<br />

files) and sample applicati<strong>on</strong>s.<br />

Extending out <strong>to</strong> the client tier, the <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> clients and <strong>SQL</strong> <strong>Server</strong> clients c<strong>on</strong>nect <strong>to</strong><br />

databases in similar, albeit proprietary, pro<strong>to</strong>cols: Transparent <strong>Net</strong>work Substrate (TNS)<br />

<str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and Tabular Data Stream (TDS) <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>SQL</strong> <strong>Server</strong>. Figure A.2 compares the<br />

user-instance-database interacti<strong>on</strong> paths.


334 Appendices<br />

Figure A.2<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong> 2000 — User-instance database interacti<strong>on</strong> compared<br />

Unlike <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>, <strong>SQL</strong> <strong>Server</strong> does not s<strong>to</strong>re client c<strong>on</strong>figurati<strong>on</strong> in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> in an operating<br />

system file. <strong>SQL</strong> <strong>Server</strong> uses registry keys <strong>to</strong> s<strong>to</strong>re such in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong>. By default, <strong>SQL</strong><br />

<strong>Server</strong> is c<strong>on</strong>figured <strong>to</strong> listen <strong>on</strong> TCP/IP network pro<strong>to</strong>col, which should suffice <str<strong>on</strong>g>for</str<strong>on</strong>g> most<br />

installati<strong>on</strong>s migrating from <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>. The server network utility (part of the server<br />

installati<strong>on</strong>) can be used <strong>to</strong> c<strong>on</strong>figure <strong>SQL</strong> <strong>Server</strong> <strong>to</strong> listen <strong>on</strong> named pipes, multipro<strong>to</strong>col,<br />

NWLink, IPX/SPX, Banyan VINES, and Appletalk pro<strong>to</strong>cols.<br />

On the client side, the client network utility (part of the client installati<strong>on</strong>) can be used <strong>to</strong><br />

set up alias names <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>SQL</strong> <strong>Server</strong>s. The alias names can be mapped <strong>to</strong> an IP address or<br />

a named pipe address. The naming varies based <strong>on</strong> the type of installati<strong>on</strong>. Clients can<br />

c<strong>on</strong>nect <strong>to</strong>:<br />

● A default instance by specifying the servername.<br />

● A named instance by specifying the servername\instancename.<br />

The proper instance naming will have <strong>to</strong> be used while defining Data Source Names<br />

(DSN) in the c<strong>on</strong>necti<strong>on</strong> string of ODBC, ADO, DBI::DBD, Enterprise Manager, Query<br />

Analyzer, and isql utility.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 335<br />

Database Architecture<br />

A database has <strong>on</strong>e or more physical data files that c<strong>on</strong>tain all the database data. This<br />

fact has not changed from the early days of data reposi<strong>to</strong>ries, such as Sequential Access<br />

Methods (SAM), Indexed Sequential Access Method (ISAM), and Virtual S<strong>to</strong>rage Access<br />

Method (VSAM), <strong>to</strong> the modern day relati<strong>on</strong>al database management systems (RDBMS).<br />

Though hardware throughput has improved in the past several years, the improvement in<br />

data access rates is not purely hardware-related, but also in part <strong>to</strong> the evoluti<strong>on</strong> of the<br />

database s<strong>to</strong>rage architectures.<br />

Physical S<strong>to</strong>rage Architecture<br />

The physical architecture is made up of files that c<strong>on</strong>tain the system (or catalog) and<br />

applicati<strong>on</strong> data. As with <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>, <strong>SQL</strong> <strong>Server</strong> also has support <str<strong>on</strong>g>for</str<strong>on</strong>g> raw devices. The<br />

physical architecture is used <strong>to</strong> provide separati<strong>on</strong> of data based <strong>on</strong> its type, such as<br />

metadata from user data; heap data from index data; user data from DBMS data<br />

(including transacti<strong>on</strong> logs), and permanent data from temporary data.<br />

The <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> physical architecture is made up of data files, redo log files, and c<strong>on</strong>trol files.<br />

<strong>SQL</strong> <strong>Server</strong> database systems have four system databases (master, model, tempdb,<br />

and msdb) and <strong>on</strong>e or more user databases. Each of these databases has <strong>on</strong>e or more<br />

files. Each database has its own transacti<strong>on</strong> log files, which are separate from the data<br />

files.<br />

Logical S<strong>to</strong>rage Architecture<br />

For the c<strong>on</strong>venience of administrati<strong>on</strong> and efficiency of use, the physical s<strong>to</strong>rage is<br />

broken down in<strong>to</strong> smaller logical structures. By dividing each physical data file in<strong>to</strong><br />

several logical structures, and allocating space <strong>to</strong> each database object in increments of<br />

these smaller logical structures, access <strong>to</strong> the database objects can be insulated from the<br />

physical file s<strong>to</strong>rage <strong>on</strong> the operating system. <strong>SQL</strong> <strong>Server</strong> has a s<strong>to</strong>rage hierarchy which<br />

is similar <strong>to</strong> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>’s block-extent-segment-tablespace implementati<strong>on</strong>.<br />

This enables you <strong>to</strong> load smaller chunks of data in<strong>to</strong> memory <str<strong>on</strong>g>for</str<strong>on</strong>g> faster data access and<br />

also enables you <strong>to</strong> move the physical locati<strong>on</strong> of a data file in the file system,<br />

transparent <strong>to</strong> the database objects or the applicati<strong>on</strong>s that access them. Figure A.3<br />

shows the hierarchy of s<strong>to</strong>rage structures available in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong>.<br />

Figure A.3<br />

Physical and Logical s<strong>to</strong>rage structure hierarchies in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong>


336 Appendices<br />

In <strong>SQL</strong> <strong>Server</strong>, the term page is used instead of blocks. The data files are <str<strong>on</strong>g>for</str<strong>on</strong>g>matted in<strong>to</strong><br />

blocks (pages) of the same size (8 KB). The unit of transfer <str<strong>on</strong>g>for</str<strong>on</strong>g> data between s<strong>to</strong>rage and<br />

database memory is a block or page. The compositi<strong>on</strong> of the <strong>SQL</strong> <strong>Server</strong> page is similar<br />

<strong>to</strong> the <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> block and is made up of page header, data rows and row offset array (row<br />

direc<strong>to</strong>ry). Free and used space is also tracked and managed similarly. <strong>SQL</strong> <strong>Server</strong> does<br />

not allow rows larger than 8060 bytes. This restricti<strong>on</strong>, however, does not apply <strong>to</strong> rows<br />

c<strong>on</strong>taining large data types such as text, image, and so <strong>on</strong>, which can be s<strong>to</strong>red<br />

separately.<br />

Although the data is s<strong>to</strong>red in blocks, the block is <strong>to</strong>o small a unit <str<strong>on</strong>g>for</str<strong>on</strong>g> allocati<strong>on</strong> <strong>to</strong> the<br />

database objects. A bigger unit called extent, which corresp<strong>on</strong>ds <strong>to</strong> a specific number of<br />

c<strong>on</strong>tiguous data blocks, is used <str<strong>on</strong>g>for</str<strong>on</strong>g> this purpose. <strong>SQL</strong> <strong>Server</strong> <strong>on</strong>ly supports fixed size<br />

extents of 64 KB (8 pages).<br />

For more details <strong>on</strong> the two types of extents and how they are used, refer <strong>to</strong> the “Pages<br />

and Extents” article at http://msdn.microsoft.com/librar y/default.asp?url= /library/en-<br />

us/architec/8_ar_da2_4iu r.asp.<br />

Also refer <strong>to</strong> the “Managing Extent Alloc ati<strong>on</strong>s and Free Space” article at<br />

http://msdn.mic rosoft.com/library/d efault.asp? url=/library/en-<br />

us/architec/8_ar_<br />

da2_4lgl. asp.<br />

The <strong>SQL</strong> <strong>Server</strong> equivalen t of the <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> tables pace is called the filegroup. Each <strong>SQL</strong><br />

<strong>Server</strong> database is created with a primary file bel<strong>on</strong>ging <strong>to</strong> the default primary filegroup.<br />

Opti<strong>on</strong>ally, sec<strong>on</strong>dary datafiles can be added <strong>to</strong> the primary filegroup or additi<strong>on</strong>al<br />

filegroups can be created. Files and filegroups in <strong>SQL</strong> <strong>Server</strong> are implemented al<strong>on</strong>g the<br />

same lines as datafiles and table spaces in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>.<br />

Instance Architecture<br />

This secti<strong>on</strong> covers the two comp<strong>on</strong>ents that make up an <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> instance: memory and<br />

processes and its <strong>SQL</strong> <strong>Server</strong> equivalents.<br />

Memory Architecture<br />

The design of database m emory architecture in both <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> Ser ver are based<br />

<strong>on</strong> the same objective. This objective is <strong>to</strong> acquire memory from the syste m and make it<br />

available <strong>to</strong> the RDBMS <strong>to</strong> per<str<strong>on</strong>g>for</str<strong>on</strong>g>m its work. Because the available memory is a very<br />

small percentage of the database size, the c<strong>on</strong>figurati<strong>on</strong> of memory is very important <strong>to</strong><br />

the per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance of the database system. The memory per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance has <strong>to</strong> be optimized<br />

not <strong>on</strong>ly <str<strong>on</strong>g>for</str<strong>on</strong>g> applicati<strong>on</strong> data, but also the data dicti<strong>on</strong>ary and the needs of the relati<strong>on</strong>al<br />

engine. For <strong>SQL</strong> this includes procedures, executi<strong>on</strong> plan, cursors, temporary objects,<br />

and sorting.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 337<br />

The <strong>SQL</strong> <strong>Server</strong> memory address space is illustrated in Figure A.4:<br />

Figure A.4<br />

<strong>SQL</strong> <strong>Server</strong> Address Space<br />

A 32-bit process is normally limited <strong>to</strong> addressing 2 GB of memory, or 3 GB if the system<br />

was booted using the /3G boot switch in boot.ini, even if there is more physical memory<br />

available. However, both <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong> can use the MS Windows 2000<br />

Address Windowing Extensi<strong>on</strong>s (AWE) API <strong>to</strong> support up <strong>to</strong> a maximum of 64 GB of<br />

physical memory. The specific amount of memory is dependent <strong>on</strong> the hardware and<br />

operating system versi<strong>on</strong>s. The AWE-enabled server c<strong>on</strong>figurati<strong>on</strong> parameter is available<br />

in <strong>SQL</strong> <strong>Server</strong> <str<strong>on</strong>g>for</str<strong>on</strong>g> the purpose. The Microsoft Knowledge Base Article 274750, "How <strong>to</strong><br />

c<strong>on</strong>figure memory <str<strong>on</strong>g>for</str<strong>on</strong>g> more than 2 GB in <strong>SQL</strong> <strong>Server</strong>," is available at<br />

http://support.microsoft.com/default.aspx?scid=kb;en-us;274750. It provides in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong><br />

<strong>on</strong> the maximum amount of memory that various Microsoft Windows Operating System<br />

versi<strong>on</strong>s can support and how <strong>to</strong> c<strong>on</strong>figure memory opti<strong>on</strong>s.<br />

An overview of the internals of memory management facilities of <strong>SQL</strong> <strong>Server</strong> 2000 is<br />

available at http://msdn.microsoft.com/sql/default.aspx?pull=/library/enus/dnsqldev/html/sqldev_01262004.asp.<br />

The <strong>SQL</strong> <strong>Server</strong> 2000 memory manager uses different algorithms <strong>to</strong> manage memory <strong>on</strong><br />

different versi<strong>on</strong>s of Windows. While memory allocati<strong>on</strong> <strong>to</strong> the RDBMS has been rigidly<br />

c<strong>on</strong>trolled in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> by the c<strong>on</strong>figurati<strong>on</strong> (initializati<strong>on</strong>) parameters, the sizes of the<br />

comp<strong>on</strong>ents in <strong>SQL</strong> <strong>Server</strong> 2000 address space are au<strong>to</strong>-tuned dynamically in<br />

cooperati<strong>on</strong> between the RDBMS and the operating system. All memory areas within the<br />

memory pool are also dynamically adjusted by the <strong>SQL</strong> <strong>Server</strong> code <strong>to</strong> optimize<br />

per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance and do not need any administra<strong>to</strong>r input.<br />

The Memory Pool is the <strong>SQL</strong> <strong>Server</strong> equivalent of the SGA. The compositi<strong>on</strong> of the<br />

memory pool can be found at<br />

http://msdn.microsoft.com/library/default.asp?url=/library/enus/architec/8_ar_sa_1zu4.asp.


338 Appendices<br />

Process/Thread Architecture<br />

The process architecture identifies the various database related processes and their<br />

functi<strong>on</strong>ality. As is true with <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> Windows, <strong>SQL</strong> <strong>Server</strong> also uses a thread-based<br />

architecture. <strong>SQL</strong> <strong>Server</strong> does not differ significantly from <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> in its use of pools of<br />

processes (threads) <str<strong>on</strong>g>for</str<strong>on</strong>g> system functi<strong>on</strong>s and user requests. Table A.1 compares <strong>SQL</strong><br />

<strong>Server</strong> functi<strong>on</strong>ality with respect <strong>to</strong> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> background processes.<br />

Table A.1: Mapping of <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong> Background Processes<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Process<br />

(Required Status)*<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g><br />

Identifier<br />

Min / Max<br />

<strong>SQL</strong> <strong>Server</strong> Process<br />

(Required Status)*<br />

Min / Max<br />

Process M<strong>on</strong>i<strong>to</strong>r (M) PMON 1 / 1 Open Data Services (M) 1 / 1<br />

System M<strong>on</strong>i<strong>to</strong>r (M) SMON 1 / 1 Database cleanup / 1 / 1<br />

shrinking (M)<br />

Database Writers (M) DBWn 1 / 20 Lazywriter (M) 1 / 1<br />

Checkpoint Process (M) CKPT 1 / 1 Database checkpoint (M) 1 / 1<br />

Recoverer (O) RECO 0 / 1 MS DTC (O) 0 / 1<br />

Log Writer (M) LGWR 1 / 1 Logwriter (M) 1 / 1<br />

Archive Processes (O) ARCn 0 / 10 N/A<br />

Job Queue Processes Jnnn 0 / 1000 <strong>SQL</strong> Agent (O) 0 / 1<br />

(O)<br />

Job Queue Coordina<strong>to</strong>rs CJQn 0 / 1 <strong>SQL</strong> Agent (O)<br />

0 / 1<br />

(O)<br />

Queue M<strong>on</strong>i<strong>to</strong>r<br />

QMNn 0 / 10 <strong>SQL</strong> Agent (O) 0 / 1<br />

Processes (O)<br />

Parallel Query Slave Pnnn 0 / 3600 Worker threads (M) 32 / 32767<br />

Processes (O)<br />

Dispatcher (O) Dnnn 0 / 5 <strong>Net</strong>work thread (M) 1 / 1<br />

Shared <strong>Server</strong>s (O) Snnn 0 / OS Worker threads (M) 32 / 32767<br />

<strong>SQL</strong> <strong>Server</strong> employs sophisticated shared server architecture. On startup, <strong>SQL</strong> <strong>Server</strong><br />

creates a User Mode Scheduler (UMS) o bject <str<strong>on</strong>g>for</str<strong>on</strong>g> each processor using the affinity mask<br />

setting. A pool of worker threads is created by Open Data Services (ODS) <strong>to</strong> handle user<br />

commands, and their c<strong>on</strong>trol is distributed am<strong>on</strong>g the UMS schedulers. This architecture<br />

mimics the shared server-dispatcher c<strong>on</strong>cept in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>. While in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> the shared server<br />

processes are schedule d by the operating system, <strong>SQL</strong> <strong>Server</strong> uses the UMS <strong>to</strong><br />

schedule worker threads.<br />

The internal workings of the User Mode Scheduler are available at:<br />

http://msdn.microsoft.com/<strong>SQL</strong>/sqlarchitectu re /default.aspx?pull=/library/en-<br />

us/dnsqldev/html/sqldev_02252004.asp?frame=true.<br />

Additi<strong>on</strong>al references <strong>on</strong> <strong>to</strong>pics related <strong>to</strong> process architecture include:<br />

● <strong>Server</strong> Memory Opti<strong>on</strong>s (Administrating <strong>SQL</strong> <strong>Server</strong>):<br />

http://msdn.microsoft.com/library/default.asp?url=/library/en-<br />

us/adminsql/ad_c<strong>on</strong>fig_9zfy.asp.<br />

● <strong>SQL</strong> <strong>Server</strong> Memory Usage: http://support.microsoft.com/default.aspx?scid=kb;enus;321363.<br />

● 64-bit Overview: http://www.microsoft.com/sql/64bit/productinfo/overview.asp.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 339<br />

●<br />

IO Affinity: http://support.microsoft.com/default.aspx?scid=kb;[LN];298402.<br />

● Allocating threads <strong>to</strong> a CPU:<br />

http://msdn.microsoft.com/library/default.asp?url=/library/enus/architec/8_ar_sa_8agl.asp.<br />

Relati<strong>on</strong>al Engine Architecture<br />

The Relati<strong>on</strong>al Engine is the part of the RDBMS that is resp<strong>on</strong>sible <str<strong>on</strong>g>for</str<strong>on</strong>g> parsing,<br />

optimizing, and executing the <strong>SQL</strong> statements received from end users and returning<br />

results (also known as fetching) <strong>to</strong> the end users.<br />

Figure A.5 illustrates the comp<strong>on</strong>ents of <strong>SQL</strong> <strong>Server</strong> relati<strong>on</strong>al engine.<br />

Figure A.5<br />

Comp<strong>on</strong>ents of <strong>SQL</strong> <strong>Server</strong> Relati<strong>on</strong>al Engine<br />

Figue A.5 illustrates the main comp<strong>on</strong>ents of the relati<strong>on</strong>al engine porti<strong>on</strong> of <strong>SQL</strong> <strong>Server</strong>.<br />

The illustrated comp<strong>on</strong>ents can be organized in<strong>to</strong> three groupings of subsystems:<br />

Compilati<strong>on</strong>, Executi<strong>on</strong>, and <strong>SQL</strong> Manager. The comp<strong>on</strong>ents parser, T-<strong>SQL</strong> compiler,<br />

normalizer, and query optimizer bel<strong>on</strong>g <strong>to</strong> the compilati<strong>on</strong> subsystem, which processes<br />

the <strong>SQL</strong> statements. These statements typically come in as TDS messages. The <strong>SQL</strong><br />

Manager, in the middle of the figure, <str<strong>on</strong>g>for</str<strong>on</strong>g>ms the sec<strong>on</strong>d subsystem, which c<strong>on</strong>trols the<br />

flow of everything inside the <strong>SQL</strong> <strong>Server</strong>. Remote Procedure Call (RPC) messages are<br />

handled directly by the <strong>SQL</strong> Manager. T-<strong>SQL</strong> executi<strong>on</strong>, query executi<strong>on</strong>, and expressi<strong>on</strong><br />

service <str<strong>on</strong>g>for</str<strong>on</strong>g>m the executi<strong>on</strong> subsystem. The query results come out of the expressi<strong>on</strong><br />

service and are sent back out by ODS, after <str<strong>on</strong>g>for</str<strong>on</strong>g>matting the results in<strong>to</strong> TDS messages.<br />

The expressi<strong>on</strong> services library per<str<strong>on</strong>g>for</str<strong>on</strong>g>ms data c<strong>on</strong>versi<strong>on</strong>, predicate evaluati<strong>on</strong> or<br />

filtering, and arithmetic calculati<strong>on</strong>s.<br />

The catalog services comp<strong>on</strong>ent handles data definiti<strong>on</strong> statements (DDL). The UMS is a<br />

scheduler internal <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> that handles the threads and fibers. The system-s<strong>to</strong>red<br />

procedures are self evident.<br />

For a more detailed discussi<strong>on</strong> of the relati<strong>on</strong>al engine, refer <strong>to</strong><br />

http://msdn.microsoft.com/library/default.asp?url=/library/enus/dnsql7/html/sqlquerproc.asp.<br />

The c<strong>on</strong>cepts of executi<strong>on</strong> plan, cost based optimizati<strong>on</strong>, and hints are comm<strong>on</strong> <strong>to</strong><br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong>.<br />

A white paper <strong>on</strong> query optimizer and statistics is available at<br />

http://msdn.microsoft.com/library/default.asp?url=/library/enus/dnsql2k/html/statquery.asp.


340 Appendices<br />

Transacti<strong>on</strong> Architecture<br />

Users and applicati<strong>on</strong>s interact with the database using transacti<strong>on</strong>s. Both <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and<br />

<strong>SQL</strong> <strong>Server</strong> offer both optimistic and pessimistic c<strong>on</strong>currency c<strong>on</strong>trol. Pessimistic locking<br />

is the default <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>SQL</strong> <strong>Server</strong>. Microsoft <strong>SQL</strong> <strong>Server</strong> supports all four levels of isolati<strong>on</strong>:<br />

read uncommitted, read committed, repeatable read, and serializati<strong>on</strong>. Read committed<br />

is the default level of isolati<strong>on</strong> <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>SQL</strong> <strong>Server</strong>.<br />

Like most RDBMSs, <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong> achieve isolati<strong>on</strong> by c<strong>on</strong>trolling c<strong>on</strong>current<br />

access <strong>to</strong> shared resources (such as schema objects) and their subcomp<strong>on</strong>ents (such as<br />

data rows), and internal database structures using locks. Transacti<strong>on</strong>s acquire locks at<br />

different levels of granularity. In <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>, the granularities are row and table, while in <strong>SQL</strong><br />

<strong>Server</strong> the granularities are row (RID and rowid), key (row lock within an index), page,<br />

exte nt, table, and database. A major difference between <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong> in their<br />

use of locks is that <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> does not escalate locks, while <strong>SQL</strong> <strong>Server</strong> escalates locks <strong>to</strong><br />

reduce the system overhead of maintaining a large number of finer-grained locks. <strong>SQL</strong><br />

<strong>Server</strong> au<strong>to</strong>matically escalates row locks and page locks in<strong>to</strong> table locks when a<br />

transacti<strong>on</strong> exceeds its escalati<strong>on</strong> threshold.<br />

Table A.2 compares the types of locking available in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong>.<br />

Table A.2: Comparis<strong>on</strong> of the Modes of Locking in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong><br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>SQL</strong> <strong>Server</strong> Purpose<br />

Share (S) Shared (S) Used <str<strong>on</strong>g>for</str<strong>on</strong>g> operati<strong>on</strong>s that do not change<br />

data, such as SELECT statements<br />

Row Share (RS) Update (U) Used <strong>on</strong> resources that can be updated,<br />

such as SELECT … FOR UPDATE in<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and SELECT statements with<br />

the UPDLOCK lock hint in <strong>SQL</strong> <strong>Server</strong><br />

Row Exclusive (RX) Exclusive (X) Used <str<strong>on</strong>g>for</str<strong>on</strong>g> data modificati<strong>on</strong> operati<strong>on</strong>s,<br />

such as INSERT, UPDATE, DELETE<br />

Share Row Exclusive N/A Only allows n<strong>on</strong>-update S and RS locks<br />

(SRX)<br />

Exclusive (X) Exclusive (X) Disables all other updates<br />

N/A Intent Shared (IS) Indicates intenti<strong>on</strong> <strong>to</strong> read some<br />

resources lower in the hierarchy<br />

N/A Intent Exclusive (IX) Indicates intenti<strong>on</strong> <strong>to</strong> modify some<br />

resources lower in the hierarchy<br />

N/A Shared with Intent<br />

Exclusive (SIX)<br />

Indicates intenti<strong>on</strong> <strong>to</strong> read all resources<br />

at a lower level and modify some of<br />

them using IX locks<br />

Exclusive DDL Schema Modificati<strong>on</strong> For per<str<strong>on</strong>g>for</str<strong>on</strong>g>ming DDL<br />

(Sch-M)<br />

Breakable Parse Schema Stability For compiling queries<br />

(Sch-S)<br />

N/A<br />

Bulk Update (BU) For bulk copying data in<strong>to</strong> a table<br />

<strong>SQL</strong> <strong>Server</strong> Books Online has very useful in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <strong>on</strong> lock modes, lock hints, lock<br />

compatibility, and deadlocks. More in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> is available at<br />

http://msdn.microsoft.com/library/default.asp?url=/library/enus/architec/8_ar_sa2_2sit.asp.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 341<br />

Security Architecture<br />

The database has security mechanisms such as logins, privileges, and roles <strong>to</strong> provide<br />

c<strong>on</strong>trol over privileges <strong>to</strong> c<strong>on</strong>nect <strong>to</strong> the database, access schema objects, and<br />

manipulate their structure and data. Both <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong> utilize a layered<br />

app roach <strong>to</strong> security, from logins <strong>to</strong> roles <strong>to</strong> system (statement) and object privileges.<br />

Logins<br />

Both <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong> provide logins <str<strong>on</strong>g>for</str<strong>on</strong>g> authorized users <strong>to</strong> c<strong>on</strong>nect <strong>to</strong> the<br />

database. In <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>, the login is called user or username, and in <strong>SQL</strong> <strong>Server</strong>, it is called<br />

login identifier or simply login. Any operati<strong>on</strong> the user can per<str<strong>on</strong>g>for</str<strong>on</strong>g>m is c<strong>on</strong>trolled by the<br />

privileges granted <strong>to</strong> the login.<br />

Authenticati<strong>on</strong><br />

Both <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong> allow authenticati<strong>on</strong> by the operating system or by the<br />

database (server). In <strong>SQL</strong> <strong>Server</strong>, the operating system mode is called Windows<br />

Authenticati<strong>on</strong> Mode and the database mode is called <strong>SQL</strong> <strong>Server</strong> Authenticati<strong>on</strong> Mode.<br />

<strong>SQL</strong> <strong>Server</strong> can operate in either Windows authenticati<strong>on</strong> mode or Windows and <strong>SQL</strong><br />

<strong>Server</strong> authenticati<strong>on</strong> mode.<br />

Passwords<br />

The features and functi<strong>on</strong>ality related <strong>to</strong> passwords, such as complexity, aging, or lock<br />

out, that exist with <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> logins, can <strong>on</strong>ly be found in Windows logins and not <strong>SQL</strong><br />

<strong>Server</strong> authenticated logins.<br />

Privileges<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong> have a similar model <strong>to</strong> secure schema objects and applicati<strong>on</strong><br />

data and system objects and metadata from unauthorized users. This is achieved by<br />

creating two sets of privileges: system (statement) privileges (permissi<strong>on</strong>s) and object<br />

privileges (permissi<strong>on</strong>s). Privileges can be assigned <strong>to</strong> users and roles using the GRANT<br />

statement and removed using the REVOKE statement. Roles are used <strong>to</strong> grant privileges<br />

<strong>to</strong> users, but indirectly, are discussed next.<br />

Roles<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> provides predefined roles, the most familiar being CONNECT, RESOURCE, DBA,<br />

and so <strong>on</strong>. Similarly, <strong>SQL</strong> <strong>Server</strong> has several predefined roles with specific permissi<strong>on</strong>s.<br />

There are two types of predefined roles: fixed server roles and fixed database roles. Both<br />

<str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong> offer user-defined roles.<br />

For more in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <strong>on</strong> the privileges available in <strong>SQL</strong> <strong>Server</strong> and their management,<br />

refer <strong>to</strong> http://msdn.microsoft.com/library/default.asp?url=/library/enus/adminsql/ad_security_94dv.asp.<br />

For in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <strong>on</strong> creating user-defined roles in <strong>SQL</strong> <strong>Server</strong>, refer <strong>to</strong><br />

http://msdn.microsoft.com/library/default.asp?url=/library/enus/adminsql/ad_security_6x5x.asp.<br />

Microsoft <strong>SQL</strong> <strong>Server</strong> 2000 SP3 Security Features and Best Practices is available at:<br />

http://www.microsoft.com/sql/techinfo/administrati<strong>on</strong>/2000/security/securityWP.asp. It<br />

provides a detailed account of <strong>SQL</strong> <strong>Server</strong> security model and best practices.


342 Appendices<br />

Data Dicti<strong>on</strong>ary<br />

The data dicti<strong>on</strong>ary, referred <strong>to</strong> in <strong>SQL</strong> <strong>Server</strong> as the system catalog, is broken up in<strong>to</strong> a<br />

system-level comp<strong>on</strong>ent in the master database and individual database-level<br />

comp<strong>on</strong>ents in each of the other databases. It has the following characteristics:<br />

● Each of the databases c<strong>on</strong>tains tables <strong>to</strong> maintain its own database objects<br />

(tables, indexes, c<strong>on</strong>straints, users, privileges, replicati<strong>on</strong> definiti<strong>on</strong>) and other<br />

system structures (filegroups, files).<br />

● The centralized system catalog in the master database c<strong>on</strong>tains in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> which<br />

is a combinati<strong>on</strong> of <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> c<strong>on</strong>trol files and data dicti<strong>on</strong>ary, such as individual<br />

database names and primary file locati<strong>on</strong>, server level logins, system messages,<br />

c<strong>on</strong>figurati<strong>on</strong> (initializati<strong>on</strong> parameter) values, remote servers, linked servers,<br />

system procedures (such as the DBMS_ <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> s<strong>to</strong>red programs), and so <strong>on</strong>.<br />

The features of the data dicti<strong>on</strong>ary that an <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> DBA is familiar with — system tables,<br />

views, functi<strong>on</strong>s, and procedures — can also be found in <strong>SQL</strong> <strong>Server</strong> in the following<br />

<str<strong>on</strong>g>for</str<strong>on</strong>g>ms:<br />

● System tables<br />

These serve the same functi<strong>on</strong> as <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>’s data dicti<strong>on</strong>ary tables. The system<br />

tables should be used <str<strong>on</strong>g>for</str<strong>on</strong>g> in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <strong>on</strong>ly.<br />

System tables available under the master database s<strong>to</strong>re server-level system<br />

in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong>. For example:<br />

● master..syslogins — Available login accounts<br />

● master..sysdatabases — Available databases<br />

The following tables s<strong>to</strong>re database-level system in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <str<strong>on</strong>g>for</str<strong>on</strong>g> the respective<br />

database:<br />

● sy susers — Available user accounts with privileg es <strong>on</strong> database<br />

● sysobjects — Available objects in database<br />

● sysindexes — Available indexes in database<br />

For a complete listing of system tables and their use, refer <strong>to</strong><br />

http:// msdn.microsoft.com/library/default.asp?url=/library/en-<br />

us/tsqlref/ts_sys_00_690z.asp.<br />

● In<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> schema views<br />

<strong>SQL</strong> <strong>Server</strong> offers in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> schema views which are equivalent <strong>to</strong> the ALL_<br />

views found in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>. In<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> can be retrieved from these views by querying<br />

the corresp<strong>on</strong>ding INFORMATION_SCHEMA.view_name. For example, the views<br />

that are visible <strong>to</strong> a user can be verified by using<br />

INFORMATION_SCHEMA.VIEWS. Below is a list of comm<strong>on</strong> in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> schema<br />

views.<br />

● in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong>_schema.tables — Available tables in a database<br />

● in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong>_schema.columns — Available columns in a database<br />

● in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong>_schema.table_privileges — Available privileges <strong>on</strong> tables in a<br />

database<br />

The in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> schema views <strong>to</strong>pic is discussed at<br />

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_iaiz_4pbn.asp.<br />

● System functi<strong>on</strong>s


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 343<br />

●<br />

Equivalents <str<strong>on</strong>g>for</str<strong>on</strong>g> built-in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>SQL</strong> functi<strong>on</strong>s can be found in <strong>SQL</strong> <strong>Server</strong> under the<br />

System functi<strong>on</strong>s heading. Some comm<strong>on</strong>ly used functi<strong>on</strong>s include:<br />

● User_name(id)<br />

● getdate()<br />

● system_user()<br />

For a list of all available <strong>SQL</strong> <strong>Server</strong> system functi<strong>on</strong>s, refer <strong>to</strong><br />

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_fafz_79f7.asp.<br />

System s<strong>to</strong>red procedures<br />

The system s<strong>to</strong>red procedures aid the administra<strong>to</strong>r in per<str<strong>on</strong>g>for</str<strong>on</strong>g>ming comm<strong>on</strong><br />

functi<strong>on</strong>s by supplementing the DDL. They also provide in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> from system<br />

tables, prepackaged <strong>to</strong> save the administra<strong>to</strong>r from writing his or her own queries<br />

and views. The system s<strong>to</strong>red procedures can be c<strong>on</strong>sidered <strong>to</strong> be the equivalent<br />

of <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>'s DBMS and UTL packages. These procedures are designed <strong>to</strong> be<br />

comprehensive and remove the burden of having <strong>to</strong> remember DDL syntax and<br />

system table names.<br />

For a complete listing of system s<strong>to</strong>red procedures, refer <strong>to</strong><br />

http://msdn.microsoft.com/library/default.asp?url=/library/en-<br />

us/tsqlref/ts_sp_00_519s.asp<br />

Administrati<strong>on</strong><br />

This secti<strong>on</strong> provides brief introducti<strong>on</strong>s <strong>to</strong> <strong>to</strong>pics such as export, import, backup,<br />

recovery, and m<strong>on</strong>i<strong>to</strong>ring.<br />

Export/Import<br />

In <strong>SQL</strong> <strong>Server</strong>, data can be imported and exported using the Data Trans<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong><br />

Services (DTS) <strong>to</strong>ol, Transact-<strong>SQL</strong> statements (INSERT INTO and BULK INSERT), and<br />

Bulk Copy utility (bcp), which provides the same functi<strong>on</strong>ality as <strong>SQL</strong>*Loader.<br />

Export<br />

<strong>SQL</strong> <strong>Server</strong> does not have an equivalent of the <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> export utility <strong>to</strong> move data in<strong>to</strong> a<br />

binary <str<strong>on</strong>g>for</str<strong>on</strong>g>mat file. Individual schema objects can be backed up <strong>to</strong> text-based flat files in<br />

any of the several available file <str<strong>on</strong>g>for</str<strong>on</strong>g>mats, or they can be exported <strong>to</strong> any of the several<br />

OLE DB destinati<strong>on</strong>s and res<strong>to</strong>red using <strong>to</strong>ols and utilities.<br />

One of the following methods can be used <strong>to</strong> extract or spool data in<strong>to</strong> flat files:<br />

● Using the <strong>to</strong>ol osql.exe is similar <strong>to</strong> <strong>SQL</strong>*Plus in the way the users can run<br />

commands at the prompt.<br />

● Using bcp, the bulk copy utility<br />

● Using the D ata Trans<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> Services (DTS) <strong>to</strong>ol<br />

Import<br />

<strong>SQL</strong> <strong>Server</strong> does have an equivalent <strong>to</strong> the <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> import utility, but as menti<strong>on</strong>ed in the<br />

previous secti<strong>on</strong>, individual schema objects that have been exported <strong>to</strong> flat files with any<br />

of the several supported file <str<strong>on</strong>g>for</str<strong>on</strong>g>mats or <strong>to</strong> any OLE DB destinati<strong>on</strong> can be imported in<strong>to</strong> a<br />

database using <strong>on</strong>e of the many <strong>to</strong>ols and utilities.<br />

Three ways that data can be imported in<strong>to</strong> <strong>SQL</strong> <strong>Server</strong> include:


344 Appendices<br />

●<br />

●<br />

●<br />

Using the BULK INSERT command, which acts as an interface <strong>to</strong> the bcp utility.<br />

The structure of the BULK INSERT command is similar <strong>to</strong> the structure of the<br />

c<strong>on</strong>trol file used in <strong>SQL</strong>*Loader.<br />

Using bcp, the bulk copy utility.<br />

Using the Data Trans<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> Services (DTS) <strong>to</strong>ol.<br />

The functi<strong>on</strong>ality and use of bcp, BULK INSERT, and DTS <str<strong>on</strong>g>for</str<strong>on</strong>g> moving data from <str<strong>on</strong>g>Oracle</str<strong>on</strong>g><br />

int o <strong>SQL</strong> <strong>Server</strong> have been dem<strong>on</strong>strated in Chapter 8. DTS has also been discussed in<br />

more detail in Appendix B: "Getting the Best out of <strong>SQL</strong> <strong>Server</strong> 2000 and Windows."<br />

Some additi<strong>on</strong>al references <strong>on</strong> these utilities are:<br />

●<br />

●<br />

●<br />

the "DTS Package Development, Deployment and Per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance" article available<br />

at http://support.microsoft.com/default.aspx?scid=kb;en-us;242391&sd=tech.<br />

For in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <strong>on</strong> different switches available with BULK INSERT, refer <strong>to</strong><br />

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_babz_4fec.asp.<br />

For tips <strong>on</strong> optimizing bulk copy read, refer <strong>to</strong><br />

http: //www.databasejournal.com/features/mssql/article.php/3095511.<br />

Backup<br />

In <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>, backup methods can be categorized at a high level as physical and logical<br />

backups. Comparable methods <str<strong>on</strong>g>for</str<strong>on</strong>g> backing up the database can be found in <strong>SQL</strong> <strong>Server</strong>.<br />

Table A.3 provides a comparis<strong>on</strong> of the available methods:<br />

Table A.3: Backup Methods in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong><br />

Backup Method <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>SQL</strong> <strong>Server</strong><br />

Logical Export bcp or DTS<br />

Physical Cold Cold<br />

Physical Online Full<br />

Physical Incremental Transacti<strong>on</strong> log or<br />

Differential<br />

Physical Archive log Transacti<strong>on</strong> log<br />

Logical Backups<br />

The goal of a logical backup is <strong>to</strong> be able <strong>to</strong> recover at the individual schema object level.<br />

Although <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>'s export and import utilities are designed <str<strong>on</strong>g>for</str<strong>on</strong>g> moving <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> data, they<br />

can be used as a supplemental method of protecting data in an <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> database. It is not<br />

recommended <strong>to</strong> use logical backups as the sole method of data backup.<br />

<strong>SQL</strong> <strong>Server</strong> does not support logical backups <strong>to</strong> proprietary binary <str<strong>on</strong>g>for</str<strong>on</strong>g>mat files. Individual<br />

schema objects, however, can be backed up <strong>to</strong> flat files in any of the several supported<br />

file <str<strong>on</strong>g>for</str<strong>on</strong>g>mats and res<strong>to</strong>red using <strong>to</strong>ols such as the bcp utility and DTS <strong>to</strong>ols.<br />

Physical Backups<br />

In <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>, a physical backup involves making copies of database files including datafiles,<br />

c<strong>on</strong>trol files, and, if the database is in ARCHIVELOG MODE, archived redo log files. The<br />

same is true in <strong>SQL</strong> <strong>Server</strong>, though a backup is viewed <strong>to</strong> be at the database level.<br />

Larger databases can utilize filegroup backups <strong>to</strong> back up secti<strong>on</strong>s of a database. The<br />

physical backups available are:<br />

● Cold (offline) backups. A cold backup or a closed backup can be described as a<br />

backup of <strong>on</strong>e or more database files taken while the database<br />

is closed and is not


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 345<br />

available <str<strong>on</strong>g>for</str<strong>on</strong>g> user access. Even though the term cold backup is not menti<strong>on</strong>ed in<br />

the documentati<strong>on</strong>, the method can be applied <str<strong>on</strong>g>for</str<strong>on</strong>g> per<str<strong>on</strong>g>for</str<strong>on</strong>g>ming backups in <strong>SQL</strong><br />

<strong>Server</strong>.<br />

● Online backups. A backup is termed as an <strong>on</strong>line backup or a hot backup if it is<br />

taken while the database is open and is accessible <strong>to</strong> users. <strong>SQL</strong> <strong>Server</strong> full<br />

backup backs up a complete database and includes transacti<strong>on</strong> log entries. File<br />

and filegroup backups can be made using the BACKUP DATABASE statement or<br />

through Enterprise Manager ->Backup Database -> File and filegroup.<br />

Transacti<strong>on</strong> logs can be backed up separately as well.<br />

Incremental Backups<br />

Physical incremental backups are per<str<strong>on</strong>g>for</str<strong>on</strong>g>med <strong>to</strong> capture <strong>on</strong>ly the changed blocks, thereby<br />

reducing the time and space needed <str<strong>on</strong>g>for</str<strong>on</strong>g> the backups. Incremental backups are<br />

per<str<strong>on</strong>g>for</str<strong>on</strong>g>med after an initial complete backup has been per<str<strong>on</strong>g>for</str<strong>on</strong>g>med. In <strong>SQL</strong> <strong>Server</strong>,<br />

differential backups c<strong>on</strong>tain <strong>on</strong>ly data that has changed since a last full backup.<br />

Differential database backups can be made using the BACKUP DATABASE statement or<br />

through Enterprise Manager -> Backup Database -> Database — differential.<br />

Recovery<br />

The three recovery models offered by <strong>SQL</strong> <strong>Server</strong>—Full, Bulk-logged, and Simple—are<br />

discussed below.<br />

● Full recovery model. This is used when the data is critical and must be<br />

recoverable <strong>to</strong> point of failure. All recovery opti<strong>on</strong>s are available in this recovery<br />

model. This is equivalent <strong>to</strong> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g>’s ARCHIVELOG mode (when the<br />

NOLOGGING opti<strong>on</strong> is not specified at any level), where all transacti<strong>on</strong>s are<br />

logged and logs are archived <str<strong>on</strong>g>for</str<strong>on</strong>g> full recoverability.<br />

● Bulk-logged recovery model. This is the mid-level recovery model available <str<strong>on</strong>g>for</str<strong>on</strong>g><br />

bulk operati<strong>on</strong>s such as bulk copy, SELECT INTO, and text processing. This<br />

recovery model does not provide point-in-time recovery past the beginning of any<br />

bulk operati<strong>on</strong>. This is similar <strong>to</strong> setting the NOLOGGING opti<strong>on</strong> at the tablespace,<br />

object level, or <str<strong>on</strong>g>for</str<strong>on</strong>g> individual commands <strong>to</strong> avoid logging of bulk operati<strong>on</strong>s.<br />

● Simple recovery model. This is used when it is not important <strong>to</strong> completely<br />

recover the database or the lost data can be recreated. This recovery model has<br />

the lowest logging overhead. This is equivalent <strong>to</strong> running the database in<br />

NOARCHIVELOG mode.<br />

For more in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <strong>on</strong> the backup and recovery architecture of <strong>SQL</strong> <strong>Server</strong>, refer <strong>to</strong><br />

http://msdn.microsoft.com/library/en-us/architec/8_ar_aa_9iw5.asp.<br />

A detailed account of the backup and recovery opti<strong>on</strong>s and techniques, as well as<br />

guidance <str<strong>on</strong>g>for</str<strong>on</strong>g> per<str<strong>on</strong>g>for</str<strong>on</strong>g>ming these administrative tasks, is available at<br />

http://www.microsoft.com/technet/prodtechnol/sql/2000/maintain/sqlops4.mspx.<br />

M<strong>on</strong>i<strong>to</strong>ring<br />

M<strong>on</strong>i<strong>to</strong>ring should be per<str<strong>on</strong>g>for</str<strong>on</strong>g>med <str<strong>on</strong>g>for</str<strong>on</strong>g> availability, errors, and per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance.


346 Appendices<br />

Availability<br />

Availability should cover the server(s), node(s), database services, and database.<br />

●<br />

●<br />

●<br />

<strong>Server</strong>. M<strong>on</strong>i<strong>to</strong>ring of the server should also include the network access path from<br />

the applicati<strong>on</strong> or client <strong>to</strong> the server. The most comm<strong>on</strong> method <strong>to</strong> achieve this is<br />

a ping test.<br />

Database Services. A comm<strong>on</strong> mode of m<strong>on</strong>i<strong>to</strong>ring <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> databases is <strong>to</strong> check<br />

<strong>on</strong> the instance-specific processes such as SMON or PMON. Because <strong>SQL</strong> <strong>Server</strong><br />

uses thread architecture, <strong>on</strong>ly the main process (sqlservr.exe) can be m<strong>on</strong>i<strong>to</strong>red.<br />

Database. Even when the services are running, c<strong>on</strong>necting <strong>to</strong> a database may fail<br />

due <strong>to</strong> some errors. A sec<strong>on</strong>d level m<strong>on</strong>i<strong>to</strong>ring involving c<strong>on</strong>necting <strong>to</strong> the<br />

database and per<str<strong>on</strong>g>for</str<strong>on</strong>g>ming some simple tasks should expose such errors.<br />

The command line utility scm (Service C<strong>on</strong>trol Manager) can be used <strong>to</strong> check the health<br />

of a <strong>SQL</strong> <strong>Server</strong> instance. Scripts can also be executed using <strong>SQL</strong> <strong>Server</strong> command line<br />

utilities such as isql or osql.<br />

Errors<br />

In a database envir<strong>on</strong>ment, errors, failures, or faults can occur in a number of areas.<br />

Erro rs have <strong>to</strong> be m<strong>on</strong>i<strong>to</strong>red by viewing (or mining) the error logs. The server event logs<br />

and the database instance logs are a good source <str<strong>on</strong>g>for</str<strong>on</strong>g> errors and violati<strong>on</strong>s.<br />

The event log, which c<strong>on</strong>tains entries <str<strong>on</strong>g>for</str<strong>on</strong>g> all database server instances and other<br />

app licati<strong>on</strong>s running <strong>on</strong> the server, can be accessed through the Microsoft Windows<br />

Eve nt Viewer utility. This can be accessed through Start -> Program -> Administrative<br />

Tools -> Event Viewer. The events in the event log can be filtered by type, source, date<br />

range, and so <strong>on</strong>.<br />

<strong>SQL</strong><br />

<strong>Server</strong> has predefined error codes and error messages (see master..sysmessages<br />

<str<strong>on</strong>g>for</str<strong>on</strong>g> a complete list) that give in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> such as unique error number, severity level, error<br />

state number, and error message <strong>on</strong> all errors.<br />

The <strong>SQL</strong> <strong>Server</strong> error logs provide complete in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> regarding all events, auditing<br />

messages, errors, and so <strong>on</strong>, that have occurred against an instance. The error logs can<br />

be viewed using a text edi<strong>to</strong>r or through Enterprise Manager. In Enterprise Manager, the<br />

logs can be found using <strong>SQL</strong> <strong>Server</strong> Group -> <strong>Server</strong> Instance -> Management -><br />

<strong>SQL</strong> <strong>Server</strong> Logs.<br />

Per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance<br />

Per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance M<strong>on</strong>i<strong>to</strong>r and Task Manager are two of the several <strong>to</strong>ols that can be used <strong>to</strong><br />

m<strong>on</strong>i<strong>to</strong>r resource usage at the server level as well as the <strong>SQL</strong> <strong>Server</strong> instance level. The<br />

following is a listing of the methods by which various server and database resources can<br />

be m<strong>on</strong>i<strong>to</strong>red:<br />

● CPU. Task Manager: Per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance, Per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance M<strong>on</strong>i<strong>to</strong>r: Processor<br />

● Memory. Task Manager: Per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance, Per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance M<strong>on</strong>i<strong>to</strong>r: Memory<br />

● Process. Task Manager: Processes, Per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance M<strong>on</strong>i<strong>to</strong>r: Process<br />

● Virtual Memory. Task Manager: Per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance, Per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance M<strong>on</strong>i<strong>to</strong>r: Paging File<br />

● <strong>Net</strong>work. Task Manager: <strong>Net</strong>working, Per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance M<strong>on</strong>i<strong>to</strong>r: <strong>Net</strong>work Interface<br />

● I/O. Task Manager: Processes, Per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance M<strong>on</strong>i<strong>to</strong>r: LogicalDisk and Pe<str<strong>on</strong>g>for</str<strong>on</strong>g>mance<br />

M<strong>on</strong>i<strong>to</strong>r: PhysicalDisk<br />

● S<strong>to</strong>rage.<br />

My Computer, Windows Explorer<br />

Some references <strong>on</strong> m<strong>on</strong>i<strong>to</strong>ring <strong>SQL</strong> <strong>Server</strong> per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance are:


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 347<br />

●<br />

●<br />

●<br />

●<br />

●<br />

●<br />

"Job <strong>to</strong> M<strong>on</strong>i<strong>to</strong>r <strong>SQL</strong> <strong>Server</strong> 2000 Per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance Activity" is available at<br />

http://support .microsoft.com/default.aspx?scid=kb;EN-US;283696.<br />

"How <strong>to</strong> m<strong>on</strong>i<strong>to</strong>r <strong>SQL</strong> <strong>Server</strong> 2000 blocking" is available at<br />

http://support.microsoft.com/default.aspx?scid=kb;en-us;271509&Product=sql2k.<br />

"How <strong>to</strong> View <strong>SQL</strong> <strong>Server</strong> 2000 Activity Data" is available at<br />

http://support.microsoft.com/default.aspx?scid=kb;en-us;283784&Product=sql2k.<br />

"How <strong>to</strong> View <strong>SQL</strong> <strong>Server</strong> 2000 Blocking Data" is available at<br />

http://support.microsoft.com/default.aspx?scid=kb;en-us;283725&Product=sql2k.<br />

"How To: View <strong>SQL</strong> <strong>Server</strong> 2000 Per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance Data" is available at<br />

http://support.microsoft.com/default.aspx?scid=kb;en-us;283886&Product=sql2k.<br />

Tools and functi<strong>on</strong>s <strong>to</strong> au<strong>to</strong>mate administrati<strong>on</strong> is available at<br />

http://www.microsoft.com/technet/prodtechnol/sql/2000/maintain/sqlops4.mspx.


348 Appendices<br />

The per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance of a <strong>SQL</strong> <strong>Server</strong> installati<strong>on</strong> is dependent <strong>on</strong> several fac<strong>to</strong>rs covering<br />

database design, applicati<strong>on</strong> design, query design, access methods (indexing schemes<br />

and views), hardware, and software resources. The following references cover the entire<br />

breadth of <strong>to</strong>pics that are critical <strong>to</strong> getting the best per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance out of <strong>SQL</strong> <strong>Server</strong>.<br />

● "The Data Tier: An Approach <strong>to</strong> Database Optimizati<strong>on</strong>" is available at<br />

http://www.microsoft.com/resources/documentati<strong>on</strong>/sql/2000/all/reskit/ en-<br />

us/part10/c3361.mspx.<br />

● "Improving <strong>SQL</strong> <strong>Server</strong> Per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance" includes schemas, queries, indexes,<br />

transacti<strong>on</strong>s, s<strong>to</strong>red procedures, executi<strong>on</strong> plans, and tuning <strong>to</strong>pics:<br />

http://msdn.microsoft.com/sql/default.aspx?pull=/library/enus/dnpag/html/scalenetchapt14.asp.<br />

● "How To: Optimize <strong>SQL</strong> Queries" is available at<br />

http://msdn.microsoft.com/sql/default.aspx?pull=/library/enus/dnpag/html/scalenethow<strong>to</strong>04.asp.<br />

● "How To: Optimize <strong>SQL</strong> Indexes" is available at<br />

http://msdn.microsoft.com/sql/default.aspx?pull=/library/enus/dnpag/html/scalenethow<strong>to</strong>03.asp.<br />

● "Microsoft <strong>SQL</strong> <strong>Server</strong> 2000 Index Defragmentati<strong>on</strong> Best Practices" is available at<br />

http://www.microsoft.com/technet/prodtechnol/sql/2000/ma intain/ss2kidbp.mspx.<br />

● "Using Views with a View <strong>on</strong> Per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance" is available at<br />

http://www.microsoft.com/resources/documentati<strong>on</strong>/sql/2000/all/reskit/enus/part10/c3661.mspx.<br />

● "Checklist: <strong>SQL</strong> <strong>Server</strong> Per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance" is available at<br />

http://msdn.microsoft.com/library/default.asp?url=/library/enus/dnpag/html/scalenetcheck08.asp.<br />

● <strong>SQL</strong> <strong>Server</strong> 2000 Operati<strong>on</strong>s <str<strong>on</strong>g>Guide</str<strong>on</strong>g>: System Administrati<strong>on</strong> has very detailed<br />

discussi<strong>on</strong>s <strong>on</strong> <strong>to</strong>pics such as indexes, statistics, au<strong>to</strong>mati<strong>on</strong>, and memory<br />

management:<br />

http://www.microsoft.com/technet/prodtechnol/sql/2000/maintain/sq lops4.mspx.<br />

● "Microsoft S<strong>to</strong>rage <str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g>s – The Right S<strong>to</strong>rage and Productivity <str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g>" is<br />

available at<br />

http://www.microsoft.com/windowsserversystem/s<strong>to</strong>rage/soluti<strong>on</strong>s/rightsoluti<strong>on</strong>/righ<br />

tsoluti<strong>on</strong>.mspx.<br />

● "Windows 2003 Per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance and Scalability" is available at<br />

http://www.microsoft.com/windowsserver2003/evaluati<strong>on</strong>/per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance/perfscaling.<br />

mspx.<br />

Appendix B: Getting the Best Out of <strong>SQL</strong> <strong>Server</strong> 2000<br />

and Windows<br />

This appendix provides references <strong>on</strong> various aspects of a <strong>SQL</strong> <strong>Server</strong> 2000 deployment<br />

that can be exploited <strong>to</strong> ensure optimal per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance in an enterprise envir<strong>on</strong>ment.<br />

Per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance is also critical <strong>to</strong> scalability.<br />

Several of the links provided here have been referenced elsewhere in this guidance, but<br />

they are repeated here <str<strong>on</strong>g>for</str<strong>on</strong>g> your c<strong>on</strong>venience.<br />

Per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 349<br />

Scalability<br />

Scalability is the capability <strong>to</strong> handle increased volume of data of Very Large Databases<br />

(VLDBs) and activity. The size of the VLDBs may be due <strong>to</strong> a few large tables, or a large<br />

number of smaller tables, or a combinati<strong>on</strong> of both. Activity scalability is measured in the<br />

number of user c<strong>on</strong>necti<strong>on</strong>s, resp<strong>on</strong>se time, throughput, and so <strong>on</strong>. <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong><br />

<strong>Server</strong> are c<strong>on</strong>tinually working <strong>on</strong> adding features and functi<strong>on</strong>ality which are directed at<br />

improving their respective products <strong>to</strong> meet these demands. While some of these<br />

features, such as clustering, replicati<strong>on</strong>, and parallelism, are highlighted in specificati<strong>on</strong><br />

sheets and documentati<strong>on</strong>, much of the scalability is built in at the lower levels of the<br />

architecture, such as use of bitmaps instead of lists <strong>to</strong> represent s<strong>to</strong>rage, in-row versus<br />

out-of-row data s<strong>to</strong>rage, and so <strong>on</strong>. The overall scalability is, however, dependent not<br />

<strong>on</strong>ly <strong>on</strong> the RDBMS, but also <strong>on</strong> the hardware and the applicati<strong>on</strong>. The following<br />

references answer questi<strong>on</strong>s about scalability related <strong>to</strong> scaling out, scaling up, data<br />

partiti<strong>on</strong>ing, 64-bit architecture, s<strong>to</strong>rage technology, operating system, and other related<br />

<strong>to</strong>pics.<br />

● "Scaling Out <strong>on</strong> <strong>SQL</strong> <strong>Server</strong>" is available at<br />

http://www.microsoft.com/resources/documentati<strong>on</strong>/sql/2000/all/reskit/enus/part10/c3861.mspx.<br />

● "<strong>SQL</strong> <strong>Server</strong> Scalability FAQ" is available at<br />

http://www.microsoft.com/sql/techinfo/administrati<strong>on</strong>/2000/scalabilityfaq.asp.<br />

● "Microsoft <strong>SQL</strong> <strong>Server</strong> 2000 Scalability Project — <strong>Server</strong> C<strong>on</strong>solidati<strong>on</strong>" is available<br />

at http://msdn.microsoft.com/library/default.asp?url=/library/enus/dnsql2k/html/sql_asphosting.asp.<br />

High Availability<br />

Availability refers <strong>to</strong> the ability <strong>to</strong> c<strong>on</strong>nect <strong>to</strong> and per<str<strong>on</strong>g>for</str<strong>on</strong>g>m acti<strong>on</strong>s against the database<br />

server, the database, and the data. The features in <strong>SQL</strong> <strong>Server</strong> that c<strong>on</strong>tribute <strong>to</strong><br />

availability are discussed here.<br />

"<strong>SQL</strong> <strong>Server</strong> 2000 High Availability Series" provides the most complete set of white<br />

papers <strong>on</strong> planning and deploying a highly available envir<strong>on</strong>ment c<strong>on</strong>taining <strong>SQL</strong> <strong>Server</strong>.<br />

This series is available at:<br />

http://www.microsoft.com/technet/prodtechnol/sql/2000/deploy/harag01.mspx.<br />

Also refer <strong>to</strong> Microsoft <strong>SQL</strong> <strong>Server</strong> 2000 High Availability (Microsoft Press, 2003).<br />

Apart from covering the hardware technologies, the three <strong>SQL</strong> <strong>Server</strong> technologies<br />

covered in this series are:<br />

● Clustering<br />

● Standby database or log shipping<br />

● Replicati<strong>on</strong><br />

These <strong>to</strong>pics are discussed under the following headings.<br />

Clustering<br />

Both <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong> offer high availability support through the use of clusters of<br />

servers. The two DBMSs depend <strong>on</strong> the underlying hardware and system software <strong>to</strong><br />

provide cluster management <strong>to</strong> detect and manage failures. <strong>SQL</strong> <strong>Server</strong> can be run in an<br />

Active-Passive or Active-Active c<strong>on</strong>figurati<strong>on</strong> using the Microsoft Cluster<br />

Services<br />

(MSCS).


350 Appendices<br />

In<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <strong>on</strong> Windows clustering and <strong>SQL</strong> <strong>Server</strong> failover clustering is available at<br />

http://www.microsoft.c om/technet/prodtechnol/sql/2000/maintain/failclus.mspx.<br />

Standby Database or Log Shipping<br />

Both <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong> offer the standby database capability where a copy<br />

(sec<strong>on</strong>dary) of the entire (primary) database is maintained in a separate locati<strong>on</strong> <strong>to</strong><br />

provide recovery from server node and database failures as well as catastrophic<br />

disasters. Changes made <strong>to</strong> the primary are captured in redo or transacti<strong>on</strong> logs, shipped<br />

<strong>to</strong> the sec<strong>on</strong>dary site, and applied <strong>to</strong> the standby database. The applicati<strong>on</strong> of the logs <strong>to</strong><br />

the standby database can be c<strong>on</strong>trolled <strong>to</strong> be near-synchr<strong>on</strong>ous, or lag behind the<br />

primary <strong>to</strong> suit recovery needs.<br />

For more in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> about <strong>SQL</strong> <strong>Server</strong> log shipping, refer <strong>to</strong>:<br />

● The overview <strong>on</strong> log shipping available at<br />

http://msdn.microsoft.com/library/default.asp?url=/library/enus/adminsql/ad_1_server_8elj.asp.<br />

● The FAQ available at http://support.microsoft.com/default.aspx?scid=kb;enus;314515&sd=tech.<br />

● "Microsoft <strong>SQL</strong> <strong>Server</strong> 2000 How <strong>to</strong> Setup Log Shipping" available at<br />

http://support.microsoft.com/default.aspx?scid=%2fsupport%2fsql%2fc<strong>on</strong>tent%2f2<br />

000papers%2fLogShippingFinal.asp.<br />

Replicati<strong>on</strong><br />

Replicati<strong>on</strong> is a set of technologies <str<strong>on</strong>g>for</str<strong>on</strong>g> copying and distributing data and database<br />

objects from <strong>on</strong>e database <strong>to</strong> another and synchr<strong>on</strong>izing the data between them <str<strong>on</strong>g>for</str<strong>on</strong>g><br />

c<strong>on</strong>sistency. Replicati<strong>on</strong> is based <strong>on</strong> the master-slave technique (called publishersubscriber<br />

in <strong>SQL</strong> <strong>Server</strong>) in both <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong>. Replicati<strong>on</strong> is popularly used<br />

<strong>to</strong> provide high availability of shared data over a WAN.<br />

<strong>SQL</strong> <strong>Server</strong> offers the following <str<strong>on</strong>g>for</str<strong>on</strong>g>ms of replicati<strong>on</strong>:<br />

● Snapshot Replicati<strong>on</strong>. This is a materialized view (indexed view in <strong>SQL</strong> <strong>Server</strong>)<br />

c<strong>on</strong>taining a snapshot of data at a particular point in time.<br />

● Transacti<strong>on</strong>al Replicati<strong>on</strong>. This is a progressi<strong>on</strong> from the snapshot, with changes<br />

sent <strong>to</strong> the subscriber at the transacti<strong>on</strong> level. This enables data modificati<strong>on</strong>s<br />

made at the publisher <strong>to</strong> be propagated <strong>to</strong> the subscribers and also enables<br />

subscribers <strong>to</strong> make occasi<strong>on</strong>al updates back <strong>to</strong> the publisher.<br />

● Merge Replicati<strong>on</strong>. Merge replicati<strong>on</strong> is similar <strong>to</strong> the multimaster replicati<strong>on</strong><br />

technique in <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> that allows several instances of the object available at several<br />

<strong>SQL</strong> <strong>Server</strong> sites.<br />

For an overview, planning, <strong>to</strong>ols, implementati<strong>on</strong>, and other details of replicati<strong>on</strong>, refer <strong>to</strong><br />

http://msdn.microsoft.com/library/default.asp?url=/library/enus/replsql/replover_694n.asp.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 351<br />

Features and Tools<br />

A brief overview of some of the <strong>to</strong>ols that are very valuable in managing a <strong>SQL</strong> <strong>Server</strong><br />

envir<strong>on</strong>ment is provided under the following headings.<br />

Per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance M<strong>on</strong>i<strong>to</strong>r<br />

Per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance M<strong>on</strong>i<strong>to</strong>r is the most important <strong>to</strong>ol in m<strong>on</strong>i<strong>to</strong>ring <strong>SQL</strong> <strong>Server</strong> per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance.<br />

When <strong>SQL</strong> <strong>Server</strong> is installed <strong>on</strong> a server, it adds a set of measuring and m<strong>on</strong>i<strong>to</strong>ring<br />

counters <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>SQL</strong> <strong>Server</strong> instances.<br />

In additi<strong>on</strong> <strong>to</strong> visually m<strong>on</strong>i<strong>to</strong>ring per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance counters, the per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance of <strong>SQL</strong> <strong>Server</strong><br />

can be logged using counter logs. All counters available <str<strong>on</strong>g>for</str<strong>on</strong>g> m<strong>on</strong>i<strong>to</strong>ring are also available<br />

<str<strong>on</strong>g>for</str<strong>on</strong>g> logging whose set up is separate from the m<strong>on</strong>i<strong>to</strong>ring.<br />

Similar <strong>to</strong> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> Enterprise Manager, where events can be set up <strong>to</strong> track space,<br />

resources, availability, per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance, and faults, alerts can be set up <strong>to</strong> track <strong>SQL</strong> <strong>Server</strong><br />

activity using per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance m<strong>on</strong>i<strong>to</strong>r alerts and <strong>SQL</strong> <strong>Server</strong> Agent.<br />

The "M<strong>on</strong>i<strong>to</strong>ring <strong>SQL</strong> <strong>Server</strong> Per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance" chapter in <strong>SQL</strong> <strong>Server</strong> 2000 Administra<strong>to</strong>r’s<br />

Pocket C<strong>on</strong>sultant (Stanek, 2000) is a good reference <str<strong>on</strong>g>for</str<strong>on</strong>g> using Per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance M<strong>on</strong>i<strong>to</strong>r. It<br />

is available at<br />

http://www.microsoft.com/technet/prodtechnol/sql/2000/books/c10ppcsq.mspx.<br />

Profiler<br />

The <strong>SQL</strong> Profiler utility can be used <strong>to</strong> m<strong>on</strong>i<strong>to</strong>r the per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance of instance comp<strong>on</strong>ents,<br />

Transact-<strong>SQL</strong> statements, s<strong>to</strong>red procedures, and auditing activity. This utility provides a<br />

robust set of functi<strong>on</strong>ality that allows you <strong>to</strong> opti<strong>on</strong>ally include a variety of events, report<br />

in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> (data columns), and filtering capabilities.<br />

The article "How To: Use <strong>SQL</strong> Profiler" provides in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <strong>on</strong> how <strong>to</strong> track l<strong>on</strong>g running<br />

queries and heavily used s<strong>to</strong>red procedures. It is available at<br />

http://msdn.microsoft.com/sql/default.aspx?pull=/library/en-<br />

us/dnpag/html/scalenethow<strong>to</strong>15.asp.<br />

<strong>SQL</strong> <strong>Server</strong> Health and His<strong>to</strong>ry Tool (<strong>SQL</strong>H2)<br />

This <strong>to</strong>ol allows collecti<strong>on</strong> of data from a running instance of <strong>SQL</strong> <strong>Server</strong> which can then<br />

be reviewed and reported <strong>on</strong>. For more in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <strong>on</strong> <strong>SQL</strong>H2, refer <strong>to</strong><br />

http://www.microsof<br />

t.com/downloads/details.aspx?FamilyID=eedd10d6-75f7-4763-86de-<br />

d2347b8b5f89&DisplayLang=en.<br />

The <strong>to</strong>ol is especially useful <str<strong>on</strong>g>for</str<strong>on</strong>g> measuring service uptime and per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance trends.<br />

DTS<br />

Data Trans<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> Services (DTS) offer import and export of data by providing a set of<br />

<strong>to</strong>ols that let you extract, trans<str<strong>on</strong>g>for</str<strong>on</strong>g>m, and c<strong>on</strong>solidate data from disparate sources in<strong>to</strong><br />

single or multiple destinati<strong>on</strong>s supported by DTS c<strong>on</strong>nectivity. By using DTS <strong>to</strong>ols <strong>to</strong><br />

graphically build DTS packages, or by programming a package with the DTS object<br />

model, you can create cus<strong>to</strong>m data movement soluti<strong>on</strong>s tailored <strong>to</strong> the specialized data<br />

transfer needs.<br />

For more in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <strong>on</strong> DTS, refer <strong>to</strong> the "Data Trans<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> Services (DTS) in<br />

Microsoft <strong>SQL</strong> <strong>Server</strong>" white paper available at<br />

http://msdn.microsoft.com/<strong>SQL</strong>/sqlwarehouse/DTS/default.aspx.


352 Appendices<br />

Query Analyzer<br />

T he <strong>SQL</strong> Query Analyzer is a graphical <strong>to</strong>ol that can be used <strong>to</strong> execute queries directly<br />

a gainst the database. It also has the functi<strong>on</strong>ality <strong>to</strong> debug query per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance problems<br />

such as Show Executi<strong>on</strong> Plan, Show <strong>Server</strong> Trace, Show Client Statistics and Index<br />

Tuning Wizard.<br />

An overview of Query Analyzer is available at<br />

http://msdn.microsoft.com/library/default.asp?url=/library/en-<br />

us/qryanlzr/qryanlzr_1<br />

zqq.asp.<br />

For an overview of some of the important features of query analyzer, refer <strong>to</strong><br />

http://www.sql-server-per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance.com/query_analyzer_tips.asp.<br />

Index Tuning Wizard<br />

The Index Tuning Wizard allows you <strong>to</strong> select and create an optimal set of indexes and<br />

statistics based <strong>on</strong> input from Query Analyzer or a <strong>SQL</strong> Profiler log <str<strong>on</strong>g>for</str<strong>on</strong>g> a <strong>SQL</strong> <strong>Server</strong><br />

database without requiring an expert understanding of the structure of the database, the<br />

w orkload, or the internals of <strong>SQL</strong> <strong>Server</strong>.<br />

For in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <strong>on</strong> the features and use of the Index Tuning Wizard, refer <strong>to</strong> "Index<br />

Tuning Wizard <str<strong>on</strong>g>for</str<strong>on</strong>g> Microsoft <strong>SQL</strong> <strong>Server</strong> 2000" at<br />

http://msdn.microsoft.com/library/default.asp?url=/library/en-<br />

us/dnsql2k/html/itw<str<strong>on</strong>g>for</str<strong>on</strong>g>sql.asp.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 353<br />

Appendix C: Baselining<br />

This appendix is c<strong>on</strong>cerned with creating baselines, capturing statistics, and comparing<br />

and reporting results.<br />

Creating Baselines<br />

B aselines are a collecti<strong>on</strong> of facts and figures that reflect the state of a system. Most<br />

comm<strong>on</strong>ly, the term baseline is used with respect <strong>to</strong> per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance. In the Stabilizing<br />

Phase, this term is used <strong>to</strong> refer <strong>to</strong> a snapshot of the entire system specificati<strong>on</strong>.<br />

Unlike a new development pr oject where there is no reference point, the state of the<br />

current soluti<strong>on</strong> can be captured in a migrati<strong>on</strong> project. This can be used as a baseline<br />

f or comparis<strong>on</strong> with the migrated soluti<strong>on</strong> being tested.<br />

After every successful<br />

cycle of testing, it is recommended that all elements, such as<br />

scripts, applicati<strong>on</strong>s, applicati<strong>on</strong> c<strong>on</strong>figurati<strong>on</strong>, database c<strong>on</strong>figurati<strong>on</strong>, and databases,<br />

a re backed up and are baselined with appropriate tags <str<strong>on</strong>g>for</str<strong>on</strong>g> identificati<strong>on</strong>. Baselines from<br />

each cycle of testing can be compared with each other <strong>to</strong> see the progressi<strong>on</strong> <strong>to</strong>wards a<br />

soluti<strong>on</strong> that can be packaged <str<strong>on</strong>g>for</str<strong>on</strong>g> producti<strong>on</strong>.<br />

You should create a baseline during the Stabilizing Phase. These baseline values can be<br />

used later while troubleshooting per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance problems and also <str<strong>on</strong>g>for</str<strong>on</strong>g> proactive m<strong>on</strong>i<strong>to</strong>ring.<br />

The Per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance M<strong>on</strong>i<strong>to</strong>r, also known as System M<strong>on</strong>i<strong>to</strong>r <strong>to</strong>ol, can be used <strong>to</strong> m<strong>on</strong>i<strong>to</strong>r<br />

key system resources (CPU, memory, Disk I/O, network, as well as <strong>SQL</strong> <strong>Server</strong><br />

counters) while you run the Stabilizing Phase tests.<br />

The following tables (A.4 through A.8) list some of the per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance m<strong>on</strong>i<strong>to</strong>r counters that<br />

you can use <str<strong>on</strong>g>for</str<strong>on</strong>g> creating a baseline. These counters can also be used <str<strong>on</strong>g>for</str<strong>on</strong>g> general<br />

m<strong>on</strong>i<strong>to</strong>ring of the soluti<strong>on</strong> after deployment.<br />

Table A.4: Memory Management<br />

Per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance Descripti<strong>on</strong><br />

M<strong>on</strong>i<strong>to</strong>r Counters<br />

\Memory\Available Available MBytes is the amount of physical memory available<br />

Mbytes<br />

<strong>to</strong> processes running <strong>on</strong> the computer, in Megabytes. Lack of<br />

memory puts pressure <strong>on</strong> the CPU and Disk I/O.<br />

\Memory\Pages/sec Pages/sec is the rate at which pages are read from or written<br />

<strong>to</strong> disk<br />

<strong>to</strong> resolve hard page faults. Hard page faults occur<br />

when<br />

a process requires code or data that is not in its working<br />

set or elsewhere in physical memory and must be retrieved<br />

from disk. Note that some paging will usually be present<br />

because of the way the operating system works, but the<br />

optimal level <str<strong>on</strong>g>for</str<strong>on</strong>g> average<br />

pages/sec should be close <strong>to</strong> 0.


354 Appendices<br />

Table A.5: <strong>Net</strong>work Analysis<br />

Per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance Descripti<strong>on</strong><br />

M<strong>on</strong>i<strong>to</strong>r Counters<br />

\<strong>Net</strong>work Interface Bytes Total/sec is the rate at which bytes are sent and<br />

(<strong>Net</strong>work card)\Bytes received over each network adapter, including framing<br />

Total/sec<br />

characters. Average value should be less than 50% of NIC<br />

capacity.<br />

\<strong>Net</strong>work Segment\ % The percentage of network bandwidth in use <strong>on</strong> a network<br />

<strong>Net</strong> Utilizati<strong>on</strong><br />

segment. <strong>Net</strong>work M<strong>on</strong>i<strong>to</strong>r Driver can be installed and used <strong>to</strong><br />

m<strong>on</strong>i<strong>to</strong>r the network utilizati<strong>on</strong>. The threshold value varies<br />

based <strong>on</strong> the network c<strong>on</strong>figurati<strong>on</strong>.<br />

Table A.6: CPU M<strong>on</strong>i<strong>to</strong>ring<br />

Per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance M<strong>on</strong>i<strong>to</strong>r<br />

Counters<br />

\Processor% Processor<br />

Time<br />

\Processor\% Privileged<br />

Time and \Processor\%<br />

User Time<br />

\System\C<strong>on</strong>text<br />

switches/sec<br />

\System\Processor Queue<br />

Length<br />

Descripti<strong>on</strong><br />

This counter is the primary indica<strong>to</strong>r of processor activity,<br />

and it displays the average percentage of busy time<br />

observed during the sample interval. It is calculated by<br />

m<strong>on</strong>i<strong>to</strong>ring the time that the service is inactive and<br />

subtracting that value from 100%.<br />

* Privileged Time is the percentage of elapsed time that the<br />

process threads spent executing code in privileged mode.<br />

Average values above 10% indicate possible CPU pressure.<br />

* User Time is the percentage of elapsed time the processor<br />

spends in the user mode.<br />

* Privileged Time should be about 15% less than the <strong>to</strong>tal<br />

User Time.<br />

This counter indicates the combined rate at which all the<br />

processors are switched from <strong>on</strong>e thread <strong>to</strong> another. The<br />

pressure <strong>on</strong> memory can cause page faults, which can<br />

cause an increase in c<strong>on</strong>text switch/sec value, and a<br />

decrease in the overall per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance.<br />

This counter indicates the number of threads in the<br />

processor queue. There is a single queue <str<strong>on</strong>g>for</str<strong>on</strong>g> processor<br />

time, even <strong>on</strong> computers with multiple processors. A<br />

sustained processor queue length of less than 10 threads<br />

per processor is normally acceptable, dependent <strong>on</strong> the<br />

workload. In other words, there are more threads ready <strong>to</strong><br />

run than the current number of processors can service in an<br />

optimal way.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 355<br />

Table A.7: Disk I/O M<strong>on</strong>i<strong>to</strong>ring<br />

Per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance M<strong>on</strong>i<strong>to</strong>r<br />

Counters<br />

\PhysicalDisk\Avg. Disk<br />

Queue Length<br />

\PhysicalDisk\Current Disk<br />

Queue Length<br />

\PhysicalDisk\Avg. Disk<br />

sec/Read<br />

\PhysicalDisk\Avg. Disk<br />

sec/Write<br />

Descripti<strong>on</strong><br />

* Avg. Disk Queue Length is the average number of<br />

requests (both read and write) that were queued <str<strong>on</strong>g>for</str<strong>on</strong>g> the<br />

selected disk during the sample interval.<br />

* Current Disk Queue Length is the number of requests<br />

outstanding <strong>on</strong> the disk at the time the per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance data<br />

is collected. These numbers should be less than two per<br />

usable physical disk in the RAID array, and may be higher<br />

<strong>on</strong> the SAN systems.<br />

Average time in sec<strong>on</strong>ds <strong>to</strong> read/write data <strong>to</strong> the disk.<br />

Table A.8: M<strong>on</strong>i<strong>to</strong>ring <strong>SQL</strong> <strong>Server</strong> M<strong>on</strong>i<strong>to</strong>ring<br />

Per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance M<strong>on</strong>i<strong>to</strong>r<br />

Counters<br />

\<strong>SQL</strong><strong>Server</strong>:Access<br />

Methods\Free Space<br />

Scans/sec<br />

\<strong>SQL</strong><strong>Server</strong>:Access<br />

Methods\Full Scans/sec<br />

\<strong>SQL</strong><strong>Server</strong>:Latches\Total<br />

Latch Wait Time (ms)<br />

\<strong>SQL</strong><strong>Server</strong>:Locks(Total)\Lock<br />

Timeouts/sec and Lock Wait<br />

Time (ms)<br />

\<strong>SQL</strong><strong>Server</strong>:Locks(Total)\Numb<br />

er of Deadlocks/sec<br />

\<strong>SQL</strong><br />

<strong>Server</strong>:Databases\Transacti<strong>on</strong><br />

s/sec<br />

\<strong>SQL</strong><strong>Server</strong>:Buffer<br />

Manager\Buffer cache hit ratio<br />

Descripti<strong>on</strong><br />

Number of scans initiated <strong>to</strong> search <str<strong>on</strong>g>for</str<strong>on</strong>g> free space <strong>to</strong><br />

insert a new record fragment. Inserts <strong>on</strong> a heap with<br />

clustered index will impact per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance as against a<br />

heap with no clustered indexes.<br />

Tables with missing indexes, or when <strong>to</strong>o many rows<br />

are requested, end up with unrestricted full scans of the<br />

base table or indexes. This baseline counter can be an<br />

indica<strong>to</strong>r of an increase in the use of temporary tables<br />

because they do not tend <strong>to</strong> have indexes.<br />

<strong>SQL</strong> <strong>Server</strong> uses latches <strong>to</strong> protect the integrity of<br />

internal structures. This counter m<strong>on</strong>i<strong>to</strong>rs the <strong>to</strong>tal wait<br />

time <str<strong>on</strong>g>for</str<strong>on</strong>g> latch requests that had <strong>to</strong> wait in the last<br />

sec<strong>on</strong>d.<br />

Lock Timeouts counter indicates the number of lock<br />

requests that timed out. This includes internal requests<br />

<str<strong>on</strong>g>for</str<strong>on</strong>g> NOWAIT locks. Lock Wait Time (ms) indicates the<br />

<strong>to</strong>tal wait time (in millisec<strong>on</strong>ds) <str<strong>on</strong>g>for</str<strong>on</strong>g> locks in the last<br />

sec<strong>on</strong>d. Lock Timeouts should be low and Wait Time<br />

should be zero.<br />

Number of lock requests that resulted in a deadlock.<br />

Should be zero.<br />

Number of transacti<strong>on</strong>s started <str<strong>on</strong>g>for</str<strong>on</strong>g> the database. It is an<br />

excellent indica<strong>to</strong>r of growth related <strong>to</strong> transacti<strong>on</strong> load.<br />

Percentage of pages that were found in the buffer pool<br />

without having <strong>to</strong> incur a read from disk. The higher the<br />

value of the buffer cache hit ratio the better. In a<br />

transacti<strong>on</strong> processing system where a set user base is


356 Appendices<br />

Per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance M<strong>on</strong>i<strong>to</strong>r<br />

Counters<br />

Descripti<strong>on</strong><br />

operating against the database, this value may reach<br />

98-99 percent. If this value is small, then adding<br />

memory <strong>to</strong> the <strong>SQL</strong> <strong>Server</strong> may help. This should be<br />

looked at with table scan frequency and might indicate<br />

that indexes/partiti<strong>on</strong>ing would improve per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance.<br />

\<strong>SQL</strong><strong>Server</strong>:<strong>SQL</strong> Recompilati<strong>on</strong> adds overhead <strong>on</strong> the processor.<br />

Statistics\<strong>SQL</strong> Re-<br />

Compilati<strong>on</strong>s/sec<br />

\<strong>SQL</strong><strong>Server</strong>:Batch<br />

Requests/sec and<br />

\<strong>SQL</strong><strong>Server</strong>:General<br />

Statistics\User C<strong>on</strong>necti<strong>on</strong>s<br />

\<strong>SQL</strong><strong>Server</strong>:Memory<br />

Manager\Memory Grants<br />

Pending<br />

\<strong>SQL</strong><strong>Server</strong>:Memory<br />

Manager\Target <strong>Server</strong><br />

Memory (KB)<br />

\<strong>SQL</strong><strong>Server</strong>:Memory<br />

Manager\Total <strong>Server</strong> Memory<br />

(KB)<br />

C<strong>on</strong>sistent high values <str<strong>on</strong>g>for</str<strong>on</strong>g> this counter should be<br />

investigated.<br />

These counters, al<strong>on</strong>g with Transacti<strong>on</strong>s/sec, are a<br />

good indica<strong>to</strong>r of load <strong>on</strong> the server.<br />

Current number of processes waiting <str<strong>on</strong>g>for</str<strong>on</strong>g> a workspace<br />

memory grant. This value should remain around 0.<br />

The <strong>to</strong>tal amount of dynamic memory the server is<br />

willing <strong>to</strong> c<strong>on</strong>sume. On a dedicated server, this value<br />

should remain close <strong>to</strong> the actual physical memory size.<br />

The <strong>to</strong>tal amount of dynamic memory the server is<br />

currently c<strong>on</strong>suming. On a dedicated server, this value<br />

should remain close <strong>to</strong> the actual physical memory size.<br />

You must determine which server you will use <strong>to</strong> m<strong>on</strong>i<strong>to</strong>r <strong>SQL</strong> <strong>Server</strong>. If you run<br />

Per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance M<strong>on</strong>i<strong>to</strong>r <strong>on</strong> the same machine as the <strong>SQL</strong> <strong>Server</strong>, it should not add major<br />

overhead, except some disk I/O and disk space requirement <str<strong>on</strong>g>for</str<strong>on</strong>g> the per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance log files,<br />

depending <strong>on</strong> counters that you are m<strong>on</strong>i<strong>to</strong>ring and the interval. A large number of<br />

counters with a short sampling interval might require a lot of disk space; however, larger<br />

intervals will produce less accurate results. If you run Per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance M<strong>on</strong>i<strong>to</strong>r <strong>on</strong> a different<br />

machine, be aware that it might c<strong>on</strong>gest traffic <strong>on</strong> your network.<br />

For the purpose of creating the baseline, if you have disk space available <strong>on</strong> the <strong>SQL</strong><br />

<strong>Server</strong> machine, it is recommended you run the Per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance M<strong>on</strong>i<strong>to</strong>r <strong>on</strong> the same<br />

machine, add as many counters as desired, and use the short sampling interval. Once<br />

you have established the baseline, <str<strong>on</strong>g>for</str<strong>on</strong>g> proactive m<strong>on</strong>i<strong>to</strong>ring you can m<strong>on</strong>i<strong>to</strong>r just the<br />

counters absolutely required and increase the interval.<br />

To create the baseline chart, follow these steps:<br />

1. Click Start, then All Programs, then Administrative Tools, and then<br />

Per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance.<br />

2. Expand Per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance Logs and Alerts node in the tree in the left pane.<br />

3. Right-click Counter Logs and select New Log Settings.<br />

4. Provide a name, click OK, add the counters, verify the details <strong>on</strong> the Log Files<br />

and Schedule tab, and click OK.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 357<br />

Capturing Statistics<br />

Some of the points <strong>to</strong> be c<strong>on</strong>sidered <str<strong>on</strong>g>for</str<strong>on</strong>g> capturing statistics are:<br />

●<br />

●<br />

●<br />

●<br />

Types of data. The type of data being captured — qualitative or quantitative.<br />

Characte ristic. The statistic must be relevant <strong>to</strong> the test being per<str<strong>on</strong>g>for</str<strong>on</strong>g>med. It must<br />

suit the comparis<strong>on</strong>s being made or analysis <strong>to</strong> be per<str<strong>on</strong>g>for</str<strong>on</strong>g>med. CPU usage<br />

measurement is an example of a statistic that is relevant <strong>to</strong> testing.<br />

Unit of measurement. The unit of measurement would be dependent <strong>on</strong> the<br />

magnitude of the measured characteristic. An example is measuring and<br />

comparing memory: the unit <strong>to</strong> be used is bytes or Mbytes.<br />

Frequency. The frequency of measurement of a statistic can be a critical decisi<strong>on</strong>.<br />

Too much data can be cumbersome and <strong>to</strong>o little could be harmful.<br />

Some examples of resources <strong>on</strong> which statistics can be captured are:<br />

● Memory usage of the system<br />

● Memory usage of the database<br />

● CPU usage<br />

● Disk I/O rate<br />

● Number of user c<strong>on</strong>necti<strong>on</strong>s <strong>to</strong> the database<br />

● Procedure cache usage<br />

● Number of transacti<strong>on</strong>s executed per sec<strong>on</strong>d<br />

● Data cache usage<br />

● <strong>Net</strong>work bandwidth usage<br />

Comparing and Reporting Results<br />

Test results have <strong>on</strong>ly as much value as the inferences that can be drawn from them.<br />

Test results can have either a qualitative value or a quantitative value. In a development<br />

proj ect, the expected behavior of the soluti<strong>on</strong> is based solely <strong>on</strong> business requirements.<br />

For a migrati<strong>on</strong>, measurements from the existing soluti<strong>on</strong> <str<strong>on</strong>g>for</str<strong>on</strong>g>m the expected result.<br />

During the testing, the data from the migrated soluti<strong>on</strong> is compared with the expected<br />

results. Deviati<strong>on</strong>s from expected results cannot be c<strong>on</strong>strued as defects. As a result,<br />

analyzing and reporting results is a <strong>to</strong>pic of serious c<strong>on</strong>sequence. A thorough analysis of<br />

the results has <strong>to</strong> be made and c<strong>on</strong>clusi<strong>on</strong>s drawn based <strong>on</strong> several measurable and<br />

n<strong>on</strong>-measurable fac<strong>to</strong>rs (assumpti<strong>on</strong>s). The capabilities of the systems available <str<strong>on</strong>g>for</str<strong>on</strong>g><br />

per<str<strong>on</strong>g>for</str<strong>on</strong>g>ming stabilizati<strong>on</strong> tests may be <strong>on</strong>e such fac<strong>to</strong>r.


358 Appendices<br />

Appendix D: Installing Comm<strong>on</strong> Drivers and<br />

Applicati<strong>on</strong>s<br />

This appendix c<strong>on</strong>tains installati<strong>on</strong> in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <str<strong>on</strong>g>for</str<strong>on</strong>g> FreeTDS, unixODBC, and ActiveState<br />

Perl:<br />

● FreeTDS provides an implementati<strong>on</strong> of the Tabular Data Stream (TDS) pro<strong>to</strong>col,<br />

emulating the different versi<strong>on</strong>s of TDS that are used by <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> and <strong>SQL</strong> <strong>Server</strong>.<br />

● unixODBC is an implementati<strong>on</strong> of the ODBC pro<strong>to</strong>col and API <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>UNIX</strong>; the<br />

unixODBC library allows applicati<strong>on</strong>s r unning under <strong>UNIX</strong> <strong>to</strong> communicate with<br />

database servers, such as <strong>SQL</strong> <strong>Server</strong>, usin g ODBC. Applicati<strong>on</strong>s developed<br />

using unixODBC can execute under <strong>UNIX</strong> and SFU.<br />

● ActiveState Perl is the industry-standard Perl distributi<strong>on</strong>. This Perl distributi<strong>on</strong> can<br />

be used from within the Window envir<strong>on</strong>ment.<br />

Installing FreeTDS<br />

A precompiled and directly installable versi<strong>on</strong> of FreeTDS (currently versi<strong>on</strong> 0.62.3) is<br />

available at http://interopsystems.com/<strong>to</strong>ols. This can be installed under SFU 3.5 using<br />

the pkg_add command. The package ca n be downloaded from<br />

C<strong>on</strong>figuring FreeTDS<br />

When FreeTDS is installed, you should c<strong>on</strong>figure it <strong>to</strong> c<strong>on</strong>nect <strong>to</strong> your <strong>SQL</strong> <strong>Server</strong><br />

databases using the following procedure:<br />

To c<strong>on</strong>figure FreeTDS c<strong>on</strong>nectivity, follow these steps:<br />

1. Move <strong>to</strong> the /usr/local/etc direc<strong>to</strong>ry and edit the freetds.c<strong>on</strong>f file. This file c<strong>on</strong>tains<br />

in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> about the Sybase and <strong>SQL</strong> <strong>Server</strong> database servers it can access and<br />

the versi<strong>on</strong>s of T DS <strong>to</strong> use.<br />

2. Add the following entries <strong>to</strong> the end of the file. Replace aa. aa.aa.aa with the IP<br />

address or DNS name of the <strong>UNIX</strong> computer running <strong>SQL</strong> <strong>Server</strong> (DNS name is<br />

recommended), and bbbb with the port that <strong>SQL</strong> <strong>Server</strong> is listening <strong>to</strong> <strong>on</strong> this<br />

computer (<strong>SQL</strong> <strong>Server</strong> usually listens <strong>on</strong> port 1433) .<br />

[<strong>SQL</strong><strong>Server</strong>]<br />

host = servername<br />

port = bbbb<br />

tds versi<strong>on</strong> = 8.0<br />

Note The name, <strong>SQL</strong><strong>Server</strong>, does not have <strong>to</strong> be the same as the name of the<br />

computer running <strong>SQL</strong> <strong>Server</strong> — it is an identifier used by the FreeTDS library<br />

functi<strong>on</strong>s <strong>to</strong> locate the entry in this file. It is a name that uniquely identifies this<br />

entry in the c<strong>on</strong>figurati<strong>on</strong> file, and is used wi th the -S opti<strong>on</strong> <str<strong>on</strong>g>for</str<strong>on</strong>g> most of the scripts.<br />

3. Save the file.<br />

Testing the FreeTDS C<strong>on</strong>figurati<strong>on</strong><br />

You can test the FreeTDS c<strong>on</strong>figurati<strong>on</strong> using tsql, a <strong>to</strong>ol provided with FreeTDS, by<br />

following this procedure:


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 359<br />

To test the installati<strong>on</strong> of FreeTDS, follow these steps:<br />

1. At a shell prompt, type the following command. Replace server with the entry in<br />

freetds.c<strong>on</strong>f that you want <strong>to</strong> test (<strong>SQL</strong><strong>Server</strong>), and password with the sa password<br />

<str<strong>on</strong>g>for</str<strong>on</strong>g> the selected server:<br />

–U sa –P password<br />

Windows NT Authenticati<strong>on</strong>, called "integrated security," is not supported by<br />

FreeTDS.<br />

2. At the 1> prompt, type the following commands. The result should be a list of<br />

databases available <strong>on</strong> the selected server:<br />

SELECT name FROM sysdatabases<br />

4.<br />

tsql –S server<br />

Go<br />

3. At the 1> prompt, type the following commands. The result should be a list of<br />

c<strong>on</strong>necti<strong>on</strong>s currently established <strong>to</strong> the selected server:<br />

EXEC sp_who<br />

Go<br />

At the 1> prompt, type the following command <strong>to</strong> leave tsql.<br />

exit<br />

Installing unixODBC<br />

unixODBC is available in source <str<strong>on</strong>g>for</str<strong>on</strong>g>m (in the file unixODBC-2.2.6.tar.gz) from the<br />

unixODBC Web site at http://www.unixodbc.com. This guide uses unixODBC versi<strong>on</strong><br />

2.2.6. The procedures assume you have already downloaded the file unixODBC-<br />

2.2.6.tar.gz.<br />

To install unixODBC in <strong>UNIX</strong>, follow these steps:<br />

1. Log in <strong>to</strong> <strong>UNIX</strong> as the root user.<br />

2. At a shell prompt, access the direc<strong>to</strong>ry where the downloaded unixODBC source<br />

code is located (default/usr/local/unixODBC), and then type the following command<br />

<strong>to</strong> unzip the file unixODBC-2.2.6.tar.gz <strong>to</strong> the file unixODBC-2.2.6.tar.<br />

gunzip unixODBC-2.2.6.tar.gz<br />

3. Type the following command <strong>to</strong> unpack the file unixODBC-2.2.6.tar in<strong>to</strong> the<br />

direc<strong>to</strong>ry unixODBC-2.2.6:<br />

tar xvf unixODBC-2.2.6.tar<br />

4. Move <strong>to</strong> the unixODBC-2.2.6 direc<strong>to</strong>ry and type the following command <strong>to</strong><br />

generate the files needed <strong>to</strong> build unixODBC. This command will generate a<br />

number of messages <strong>on</strong> the screen as it examines your <strong>UNIX</strong> c<strong>on</strong>figurati<strong>on</strong> and<br />

generates the appropriate make files.<br />

./c<strong>on</strong>figure<br />

Note The c<strong>on</strong>figure script uses a number of well-known tricks <strong>to</strong> ascertain which<br />

<strong>to</strong>ols and libraries are available that it can use <strong>to</strong> compile unixODBC. If the<br />

c<strong>on</strong>figure script fails, it is usually because the script cannot find a particular <strong>to</strong>ol,<br />

file, or library. You can run the script supplying parameters <strong>to</strong> help it analyze your<br />

envir<strong>on</strong>ment. Execute ./c<strong>on</strong>figure -h <str<strong>on</strong>g>for</str<strong>on</strong>g> more details.<br />

5. Type the following command <strong>to</strong> build unixODBC. As be<str<strong>on</strong>g>for</str<strong>on</strong>g>e, you will see a large<br />

number of messages as the build process progresses:<br />

make<br />

6. Type the following command <strong>to</strong> install unixODBC:<br />

make install


360 Appendices<br />

7. Type the following command <strong>to</strong> check that unixODBC was installed successfully:<br />

/usr/local/bin/isql<br />

If unixODBC is installed correctly, you will see the following message:<br />

**********************************************<br />

* unixODBC - isql<br />

*<br />

**********************************************<br />

* Syntax<br />

*<br />

*<br />

*<br />

* isql DSN [UID [PWD]] [opti<strong>on</strong>s] *<br />

* *<br />

* Opti<strong>on</strong>s *<br />

*<br />

* -b batch.(no prompting etc)<br />

*<br />

*<br />

* -dx delimit columns with x *<br />

* -x0xXX delimit columns with XX, where *<br />

*<br />

* -w<br />

x is in hex, ie 0x09 is tab<br />

wrap results in an HTML table<br />

*<br />

*<br />

* -c column names <strong>on</strong> first row. *<br />

* (<strong>on</strong>ly used when -d) *<br />

* -mn limit column display width <strong>to</strong> n *<br />

* -v verbose. *<br />

* --versi<strong>on</strong> versi<strong>on</strong> *<br />

* *<br />

* Notes<br />

*<br />

* isql supports redirecti<strong>on</strong> and piping<br />

*<br />

*<br />

*<br />

* <str<strong>on</strong>g>for</str<strong>on</strong>g><br />

*<br />

batch processing. *<br />

*<br />

* Examples *<br />

*<br />

*<br />

* cat My.sql | isql WebDB MyID MyPWD -w *<br />

* *<br />

* Each line in My.sql must c<strong>on</strong>tain *<br />

* exactly 1 <strong>SQL</strong> command except <str<strong>on</strong>g>for</str<strong>on</strong>g> the *<br />

* last line which must be blank. *<br />

* *<br />

* Please visit; *<br />

* *<br />

* http://www.unixodbc.org *<br />

* pharvey@codebydesign.com *<br />

* nick@easysoft.com *<br />

**********************************************<br />

Installing ActiveState Perl<br />

ActiveState Perl can be downloaded from the ActiveState Web site at<br />

http://www.activestate.com. ActiveState Perl is available in prebuilt binary <str<strong>on</strong>g>for</str<strong>on</strong>g>m <str<strong>on</strong>g>for</str<strong>on</strong>g> Linux,<br />

Solaris, and Windows, but the source code is also available and can be used <strong>to</strong> build<br />

ActiveState Perl <strong>on</strong> other <strong>UNIX</strong> plat<str<strong>on</strong>g>for</str<strong>on</strong>g>ms.


<str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> <str<strong>on</strong>g>Oracle</str<strong>on</strong>g> <strong>on</strong> <strong>UNIX</strong> <strong>to</strong> <strong>SQL</strong> <strong>Server</strong> <strong>on</strong> Windows 361<br />

This secti<strong>on</strong> describes how <strong>to</strong> install ActiveState Perl using the prebuilt Microsoft Installer<br />

(MSI) package ActivePerl-5.6.1.635-MSWin32-x86.msi.<br />

To install ActiveState Perl under Windows, follow these steps:<br />

1. Execute the file ActivePerl-5.6.1.635-MSWin32-x86.msi. Windows Installer starts<br />

the installati<strong>on</strong>.<br />

2. In the ActivePerl 5.6.1 Build 635 Setup screen, click Next.<br />

3. In the ActivePerl 5.6.1 Build 635 License Agreement screen, select I accept the<br />

terms in the License Agreement and click Next.<br />

4. In the Cus<strong>to</strong>m Setup screen, make sure all features are selected <strong>to</strong> be installed<br />

(the default) and click Next.<br />

5. In the New features in PPM screen, clear the checkbox <str<strong>on</strong>g>for</str<strong>on</strong>g> Enable PPM3 <strong>to</strong> send<br />

profile info <strong>to</strong> ASPN and click Next.<br />

6. In the Choose Setup Opti<strong>on</strong>s screen, check all four opti<strong>on</strong>s and click Next.<br />

7. In the Ready <strong>to</strong> Install screen, click Install. The Installing ActivePerl 5.6.1 Build<br />

635 screen will appear and indicate the progress of the installati<strong>on</strong> process.<br />

8. In the Completing the ActivePerl 5.6.1 Build 635 Setup Wizard screen, remove<br />

the check mark from Display the release notes and click Finish.


362 Appendices<br />

Appendix E: Reference Resources<br />

For detailed discussi<strong>on</strong> of the c<strong>on</strong>cepts and practices presented in this guide, you should<br />

refer <strong>to</strong> the following resources.<br />

● For additi<strong>on</strong>al in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <strong>on</strong> migrati<strong>on</strong>, refer <strong>to</strong> the <strong>UNIX</strong> Migrati<strong>on</strong> Project <str<strong>on</strong>g>Guide</str<strong>on</strong>g><br />

(UMPG) at<br />

HTUhttp://www.microsoft.com/technet/itsoluti<strong>on</strong>s/migrati<strong>on</strong>/unix/umpg/default.mspxUTH.<br />

● Details about Windows Services <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>UNIX</strong> (SFU) are available at<br />

HTUhttp://www.microsoft.com/windows/sfu/productinfo/overview/default.aspUTH.<br />

● Microsoft <str<strong>on</strong>g>Soluti<strong>on</strong></str<strong>on</strong>g>s Framework (MSF) models and disciplines are available at<br />

HTUhttp://www.microsoft.com/msfUTH.<br />

● For guidance <strong>on</strong> the structure of operati<strong>on</strong>s, refer the Microsoft Operati<strong>on</strong>s<br />

Framework (MOF) available at HTUhttp://www.microsoft.com/mofUTH.<br />

● For additi<strong>on</strong>al in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong> <strong>on</strong> migrating <strong>UNIX</strong> applicati<strong>on</strong>s <strong>to</strong> Microsoft Windows,<br />

see the <strong>UNIX</strong> Applicati<strong>on</strong> Migrati<strong>on</strong> <str<strong>on</strong>g>Guide</str<strong>on</strong>g> at<br />

HTUhttp://go.microsoft.com/fwlink/?LinkId=30832UTH<br />

●<br />

●<br />

●<br />

Specific guidance <strong>on</strong> the Microsoft Operati<strong>on</strong>s Framework (MOF) quadrants is<br />

available in the "Process Model <str<strong>on</strong>g>for</str<strong>on</strong>g> Operati<strong>on</strong>s" white paper at<br />

HTUhttp://www.microsoft.com/technet/itsoluti<strong>on</strong>s/techguide/mof/mofpm.mspxUTH.<br />

For specific guidance <strong>on</strong> operating the soluti<strong>on</strong>, download the <str<strong>on</strong>g>Migrating</str<strong>on</strong>g> High<br />

Per<str<strong>on</strong>g>for</str<strong>on</strong>g>mance Computing (HPC) Applicati<strong>on</strong>s from <strong>UNIX</strong> <strong>to</strong> Windows guide at<br />

HTUhttp://go.microsoft.com/fwlink/?LinkID=23112UTH.<br />

For m<strong>on</strong>i<strong>to</strong>ring the deployed soluti<strong>on</strong>, refer <strong>to</strong><br />

HTUhttp://www.microsoft.com/business/reducecosts/efficiency/manageability/default.m<br />

spxUTH.<br />

● For best practices regarding m<strong>on</strong>i<strong>to</strong>ring, refer <strong>to</strong><br />

HTUhttp://www.microsoft.com/business/reducecosts/efficiency/manageability/bestpracti<br />

ces.mspxUTH.<br />

● For planning a <strong>SQL</strong> <strong>Server</strong> 2000 installati<strong>on</strong>, refer <strong>to</strong> the Microsoft Web site at<br />

HTUhttp://www.microsoft.com/sql/techinfo/planning/default.aspUTH.<br />

● For programming <strong>SQL</strong> <strong>Server</strong> 2000, refer the developer <strong>to</strong>pics at<br />

HTUhttp://www.microsoft.com/sql/techinfo/development/2000/default.aspUTH.<br />

● <strong>SQL</strong> <strong>Server</strong> Books Online is available at HTUhttp://msdn.microsoft.com/library/enus/startsql/getstart_4fht.aspUTH.<br />

● For <strong>SQL</strong> <strong>Server</strong> 2000 Resource Kit in<str<strong>on</strong>g>for</str<strong>on</strong>g>mati<strong>on</strong>, refer the Microsoft Web site at<br />

HTUhttp://www.microsoft.com/sql/techinfo/reskit/default.aspUTH.<br />

● For managing and maintaining <strong>SQL</strong> <strong>Server</strong> 2000, refer the <strong>SQL</strong> <strong>Server</strong> 2000<br />

Operati<strong>on</strong>s <str<strong>on</strong>g>Guide</str<strong>on</strong>g> at<br />

HTUhttp://www.microsoft.com/technet/treeview/default.asp?url=/technet/prodtechnol/sql<br />

/maintain/operate/opsguide/default.aspUTH.

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

Saved successfully!

Ooh no, something went wrong!