Conversion to DB2- code changes are the exception, not the ruleMarcin Marczewski – IMTE CEE Team LeaderMarcin.Marczewski@p...
Agenda■   Conversion: technical challenges■   DB2 Oracle Compatibility Features■   Tools & tasks (Conversion to DB2 step b...
Conversion Challenges                         Transact-SQLOracleSQL and                                             DB2s S...
Easy Migration with DB2 9.7          Oracle DB Compatibility Features in DB2 9.7      ● Out-of-the-box support for Oracles...
Breadth of Oracle DB Compatibility Features in DB2 9.7                                    ■   Not based on a specific Orac...
Support to Oracle SQL Dialect and PL/SQL ■   Native PL/SQL support        – The DB2 engine now includes a PL/SQL compiler ...
Enhanced Concurrency Control ■   Some applications used to need tweaking because of differences     in the concurrency con...
Extended and More Flexible Data Type System ■   New data types add support to non-standard Oracle types       – Basic and ...
Other Features ■   Oracle-specific JDBC extensions        – DB2 9.7 JDBC driver provides, among other things, support     ...
Continuous Effort ■   DB2 Fix Packs include new feature requests and refinements that continue     to improve the level of...
Configuring Compatibility Mode ■   DB2 9.7 Oracle DB Compatibility Features            – Registry variable: DB2_COMPATIBIL...
Summary of PL/SQL Support in DB2 9.7    You can compile:         ● PL/SQL procedures         - CREATE [OR REPLACE] PROCED...
PL/SQL Code in DB2                                                 Creating a PackageCREATE PACKAGE sample IS             ...
PL/SQL Code in DB2CREATE PROCEDURE add_dept (dept_no IN emp_dept) ISBEGIN                                                 ...
Conversion to DB2® – Tasks and Tools                                   © 2011 IBM Corporation
Migration Roadmap  1- Assessment tools accurate rapid      – Understand the environment to be migrated      – Estimate eff...
Conversion step by step(I)  17                      © 2011 IBM Corporation
1- Assessment                                                   tools accurate       rapid ■   Assessing the environment  ...
CAQ - Conversion Assessment Questionnaire ■   Conversion Assessment Questionnaire (CAQ)        – Gather metrics and techni...
MEET DB2• Migration Enablement Evaluation Tool for DB2   Identifies code that uses features not supported      in DB2 9.7...
MEET DB2 - Reports ■   Invoke MEET.bat to run the     utility on Windows■    Running MEET for Openbravo     (DDL code anal...
MEET DB2 Report – PL/SQL Coverage■   MEET results for Openbravo               ■   DDL code analysis results – 99,4% compat...
MEET DB2 Report – Technical Summary  23                   © 2010 IBM Corporation   © 2011 IBM Corporation
Conversion step by step (II) ■   DDL code extracted ■   DDL code analyzed          –objects that require additional       ...
2 - Database Conversion                                                            tools   automated ■   Create target DB2...
Conversion step by step (III) ■   Create target DB2 database for Openbravo     (with DB2 Oracle Compatibility Features ena...
IBM Data Movement Tool – How to Use2. Set up the tool■   Run IBMDataMovementTool.sh (Linux/UNIX) or    IBMDataMovementTool...
IBM Data Movement Tool – How to Use3. Extracting Objects and Data■   Click on “Extract DDL/Data”        –Extracts objects’...
IBM Data Movement Tool – How to Use4. Extraction Results■   Files are created in the specified Output Directory         DD...
IBM Data Movement Tool – How to Use5. Deploying Objects to DB2  30                    © 2010 IBM Corporation   © 2011 IBM ...
IBM Data Movement Tool :: Using Auto Fix ■   IDMT does not modify any PL/SQL code ■   Auto Fix is a simple tool that makes...
Conversion step by step (V) Before:          ...          IF DBMS_SQL.IS_OPEN(exec_cursor) THEN          ... After:       ...
IBM Data Movement Tool – How to Use5. Data movement to DB2  33                    © 2010 IBM Corporation   © 2011 IBM Corp...
Conversion step by step (IV)  34                      © 2010 IBM Corporation   © 2011 IBM Corporation
minimal changes for3 - Application Code Conversion                               standard interfaces■    Configure DB2 acc...
Conversion step by step (V) Before: After: ■   Changed connection properties ■   DB2 driver in use     36                 ...
Conversion Roadmap - Before and After DB2 9.7               Months/Years                                     Days/Weeks 1....
Conversion step by step ■   Oracle-based application     analyzed and converted     to DB2 during this event! ■   Code cha...
Questions?             © 2011 IBM Corporation
Upcoming SlideShare
Loading in...5
×

Db2 migration m_marczewski

580

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
580
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
6
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Db2 migration m_marczewski

  1. 1. Conversion to DB2- code changes are the exception, not the ruleMarcin Marczewski – IMTE CEE Team LeaderMarcin.Marczewski@pl.ibm.com © 2011 IBM Corporation
  2. 2. Agenda■ Conversion: technical challenges■ DB2 Oracle Compatibility Features■ Tools & tasks (Conversion to DB2 step by step – summary)■ Questions 2 © 2011 IBM Corporation
  3. 3. Conversion Challenges Transact-SQLOracleSQL and DB2s SQL/PL (based on SQL/PSM)PL/SQL ■ Applications are locked to the chosen RDBMS – Moving to a different RDBMS requires extensive rewrite of code – Your teams skill set cannot be leveraged ■ DB2 9.7 for LUW introduces a revolutionary approach to the way you can port your application 3 © 2011 IBM Corporation
  4. 4. Easy Migration with DB2 9.7 Oracle DB Compatibility Features in DB2 9.7 ● Out-of-the-box support for Oracles SQL and PL/SQL dialects ● Improved concurrency control ● Extended data type support ● … and more SQL*Plus PL/SQL scripts Oracle SQL Packages Changes are the exception, not the rule! 4 © 2011 IBM Corporation
  5. 5. Breadth of Oracle DB Compatibility Features in DB2 9.7 ■ Not based on a specific Oracle Database version In average, out-of-the-box compatibility ratio of – Driving factor was to add 90% - 99% support to the most used features in Oracle applications■ Result of a work with a wide range of apps. from partners & clients – Big (185k statements) – Small (2k statements) – Different industries – Different solutions – Different countries 5 © 2011 IBM Corporation
  6. 6. Support to Oracle SQL Dialect and PL/SQL ■ Native PL/SQL support – The DB2 engine now includes a PL/SQL compiler – No translation. No emulation. DB2 SERVER DB2 SQL PL SQL PL COMPILER SQL Unified Runtime Oracle PL/SQL Engine PL/SQL COMPILER ■ Several benefits – Developers can continue working in the language they are familiar with – One source code against both Oracle and DB2 – Both PL/SQL and SQL PL perform at the same speed 6 © 2011 IBM Corporation
  7. 7. Enhanced Concurrency Control ■ Some applications used to need tweaking because of differences in the concurrency control between Oracle and DB2 – “Readers dont block writers and writers dont block readers” ■ New isolation level named Currently Committed – Eliminate conflicts between Read workloads and Write workloads – Optimize throughput for mixed workloads – Log-based control → No management overhead 7 © 2011 IBM Corporation
  8. 8. Extended and More Flexible Data Type System ■ New data types add support to non-standard Oracle types – Basic and complex PL/SQL types BOOLEAN NUMBER %TYPE, %ROWTYPE ... VARRAY REF CURSOR VARCHAR2 ■ Implicit Casting and Type Resolution – Strings and numbers can be compared, assigned, and operated on in a very flexible fashion – Untyped NULLs and parameter markers can be used in many more places • DB2 defers the type resolution until a value is assigned “2.34” 2.34 8 © 2011 IBM Corporation
  9. 9. Other Features ■ Oracle-specific JDBC extensions – DB2 9.7 JDBC driver provides, among other things, support for calling procedures with reference cursor and VARRAY parameters ■ Support for OCI applications – DB2CI supports 150+ OCI functions ■ SQL*Plus scripts support using CLPPlus – CLPPlus: a new command line interface for execution of SQL statements and database commands. ■ Moving away from Oracle Forms – Partnership between IBM & RealEase – Automated conversion of Oracle Forms to Java http://realeasellc.com 9 © 2011 IBM Corporation
  10. 10. Continuous Effort ■ DB2 Fix Packs include new feature requests and refinements that continue to improve the level of compatibility. ■ Some examples from Fix Pack 1: – The OCI application compatible DB2CI client – FORALL and BULK COLLECT support – The SUBSTRB function and refinements to SUBSTR ■ Some examples from Fix Pack 2: – The IBM Data Server Provider for .NET has been enhanced – Added support to Oracles NCHAR, NVARCHAR and NCLOB data types – Ability to use default parameters and named parameters in UDFs – Obfuscation with DBMS_DDL.WRAP and DBMS_DDL.CREATE_WRAPPED ■ Fix Pack 3 is expected to provide an even higher level of compatibility. 9.7.3 9.7.2 9.7.1 9.7 GA 10 © 2010 IBM Corporation © 2011 IBM Corporation
  11. 11. Configuring Compatibility Mode ■ DB2 9.7 Oracle DB Compatibility Features – Registry variable: DB2_COMPATIBILITY_VECTOR • Accepts hexadecimal values (NULL or 00 to FFF) • Recommended value for Oracle migration is ORA (same as FFF) Bit Position Compatibility Feature Comment 1 (0x01) ROWNUM Synonym for ROW_NUMBER() OVER() 2 (0x02) DUAL Enables the DUAL dummy table 3 (0x04) (+) Outer join operator 4 (0x08) Hierarchial queries Using CONNECT BY clause 5 (0x10) NUMBER * 6 (0x20) DATE * Enables DATE as TIMESTAMP(0) 7 (0x40) VARCHAR2 * 8 (0x80) TRUNCATE TABLE 9 (0x100) Character literals Character and Graphic string constants whose byte length is less than 255 are assigned the data types CHAR and GRAPHIC (instead of VARCHAR and VARGRAPHIC) respectively. 10 (0x200) Collection methods Enables the use of methods to perform operations on arrays, such as first, last, next, and previous. Enables the use of parentheses in place of square brackets in references to specific elements in an array; Eg:array1(i) refers to element i of array1. 11 (0x400) Data dictionary- Data dictionary-compatible views are created when the database is created compatible views * 12 (0x800) PL/SQL Compilation Enables compilation and execution of PL/SQL statements * Must be set BEFORE database creation - It cannot be changed later 11 © 2011 IBM Corporation
  12. 12. Summary of PL/SQL Support in DB2 9.7  You can compile: ● PL/SQL procedures - CREATE [OR REPLACE] PROCEDURE ● PL/SQL functions - CREATE [OR REPLACE] FUNCTION ● PL/SQL triggers - CREATE [OR REPLACE] TRIGGER ● PL/SQL anonymous blocks - BEGIN ... END ● PL/SQL packages - CREATE [OR REPLACE] PACKAGE ● PL/SQL package bodies - CREATE [OR REPLACE] PACKAGE BODY  Features: – Data types: NUMBER, VARCHAR2, NCHAR, NCLOB, NVARCHAR, DATE, %TYPE, %ROWTYPE, … ● Basics: NULL, assignments, IF, CASE, EXIT, LOOP, … – System defined functions: TO_CHAR, TO_NUMBER, TO_NCLOB, TO_NCHAR, LPAD, RPAD, … ● Packages ● REF CURSORS ● SQL dialects: TRUNCATE TABLE, ROWNUM, DUAL, CONNECT BY, … ● Implicit casting (aka Weak Typing) ● Data Dictionary-compatible views ● And more! 12 © 2011 IBM Corporation
  13. 13. PL/SQL Code in DB2 Creating a PackageCREATE PACKAGE sample IS Collection Types TYPE emps_array IS VARRAY(30) OF VARCHAR2(6); PROCEDURE get_dept_emp ( Default parameter dno IN emp.deptno%TYPE DEFAULT 1, emps_dno OUT emps_array );END sample; Creating a Procedure/CREATE PACKAGE BODY sample IS %TYPE – links to PROCEDURE get_dept_emp ( column data type dno IN emp.deptno%TYPE, emps_dno OUT emps_array) IS BULK COLLECT INTO BEGIN IF dno IS NOT NULL THEN Added in FP1 SELECT empno BULK COLLECT INTO emps_dno FROM emp WHERE deptno=dno; FOR x in emps_dno.FIRST .. emps_dno.LAST LOOP DBMS_OUTPUT.PUT_LINE(emps_dno(x)); END LOOP; Exception handling END IF; EXCEPTION WHEN OTHERS THEN DBMS_OUTPUT.PUT_LINE(SQLCODE: || SQLCODE); END get_dept_empno;END sample;/ %ROWTYPE – links to a table row definitionCREATE TYPE emp_dept IS TABLE OF emp%ROWTYPE; 13 © 2011 IBM Corporation
  14. 14. PL/SQL Code in DB2CREATE PROCEDURE add_dept (dept_no IN emp_dept) ISBEGIN FORALL now supported FORALL deptno Added in FP1 IN dept_no.FIRST .. dept_no.LAST INSERT INTO emp_dept VALUES dept_no(deptno);…END; %ROWTYPE…CREATE PROCEDURE emp_infoIS CURSOR empcur IS SELECT ename, deptno FROM emp; myvar empcur%ROWTYPE;BEGIN %FOUND and %NOTFOUND OPEN empcur; LOOP EXIT WHEN empcur%NOTFOUND; DBMS_OUTPUT.PUT_LINE( myvar.ename || in department || myvar.deptno ); END LOOP; CLOSE empcur; Built-in PackagesEND;… Obfuscation with DBMS_DDL.WRAP New in FP2CREATE PROCEDURE emp_info WRAPPED SQL09072aBcDefg12AbcasHGJG6JKHhgkjFGHHkkkljljk878979HJHui99 14 © 2011 IBM Corporation
  15. 15. Conversion to DB2® – Tasks and Tools © 2011 IBM Corporation
  16. 16. Migration Roadmap 1- Assessment tools accurate rapid – Understand the environment to be migrated – Estimate effort 2- Database Conversiontools automated – Move DB objects (tables, functions, SPs, etc) and data minimal changes for 3- Application Code Conversion standard interfaces – Point application to DB2 server 4- Perform Functional Verification – Execute regular set of tests for the application(s) 16 © 2011 IBM Corporation
  17. 17. Conversion step by step(I) 17 © 2011 IBM Corporation
  18. 18. 1- Assessment tools accurate rapid ■ Assessing the environment – Gather details about applications and databases to be migrated. Eg: • What DB interface (JDBC, ADO.NET, etc) ? • What PL/SQL features in use not yet supported by DB2 ■ Tools – Conversion Assessment Questionnaire (CAQ) – MEET DB2 • Need help assessing complexity? • Contact the Information Management Technology Ecosystem team • askdata@ca.ibm.com 18 © 2011 IBM Corporation
  19. 19. CAQ - Conversion Assessment Questionnaire ■ Conversion Assessment Questionnaire (CAQ) – Gather metrics and technical details about applications and the database environment 19 © 2011 IBM Corporation
  20. 20. MEET DB2• Migration Enablement Evaluation Tool for DB2  Identifies code that uses features not supported in DB2 9.7  Windows only. Requires Java.  Available for IBMers and Business Partners at: http://tinyurl.com/meetdb2 • Clients should contact their IBM reps.  HTML report • Provides summary statistics • Lists details and source code line number96.6% of PL/SQL statementsimmediately transferable to IBM DB2 20 © 2010 IBM Corporation © 2011 IBM Corporation
  21. 21. MEET DB2 - Reports ■ Invoke MEET.bat to run the utility on Windows■ Running MEET for Openbravo (DDL code analysis) 21 © 2010 IBM Corporation © 2011 IBM Corporation
  22. 22. MEET DB2 Report – PL/SQL Coverage■ MEET results for Openbravo ■ DDL code analysis results – 99,4% compatibility 22 © 2010 IBM Corporation © 2011 IBM Corporation
  23. 23. MEET DB2 Report – Technical Summary 23 © 2010 IBM Corporation © 2011 IBM Corporation
  24. 24. Conversion step by step (II) ■ DDL code extracted ■ DDL code analyzed –objects that require additional attention identified ■ Application code analyzed 24 © 2010 IBM Corporation © 2011 IBM Corporation
  25. 25. 2 - Database Conversion tools automated ■ Create target DB2 database ■ Move Oracle database objects and data to DB2 – Extract DDL, PL/SQL objects and data from source database – Recreate objects on DB2 database – Load data into DB2 database ■ Tools – IBM Data Movement Tool • Includes the AutoFix tool, which increases out-of-the-box compilation of PL/SQL source files. – Optionally: Optim Development Studio 2.2 25 © 2011 IBM Corporation
  26. 26. Conversion step by step (III) ■ Create target DB2 database for Openbravo (with DB2 Oracle Compatibility Features enabled) 26 © 2010 IBM Corporation © 2011 IBM Corporation
  27. 27. IBM Data Movement Tool – How to Use2. Set up the tool■ Run IBMDataMovementTool.sh (Linux/UNIX) or IBMDataMovementTool.cmd (Windows) 27 © 2010 IBM Corporation © 2011 IBM Corporation
  28. 28. IBM Data Movement Tool – How to Use3. Extracting Objects and Data■ Click on “Extract DDL/Data” –Extracts objects’ DDL and data from Oracle database to flat files. 28 © 2010 IBM Corporation © 2011 IBM Corporation
  29. 29. IBM Data Movement Tool – How to Use4. Extraction Results■ Files are created in the specified Output Directory DDL for objects DDL for objects using using DB2 syntax * PL/SQL syntax Script files Directories * Includes data type mapping and small adjustments 29 © 2010 IBM Corporation © 2011 IBM Corporation
  30. 30. IBM Data Movement Tool – How to Use5. Deploying Objects to DB2 30 © 2010 IBM Corporation © 2011 IBM Corporation
  31. 31. IBM Data Movement Tool :: Using Auto Fix ■ IDMT does not modify any PL/SQL code ■ Auto Fix is a simple tool that makes quick fixes to PL/SQL code while maintaining the semantics of the code. – Integrated into IDMT – Increases out-of-the-box compatibility ratio of PL/SQL code Specify file to process Creates a script and the output directory that you can execute to process the selected file Click button to run the tool 31 © 2010 IBM Corporation © 2011 IBM Corporation
  32. 32. Conversion step by step (V) Before: ... IF DBMS_SQL.IS_OPEN(exec_cursor) THEN ... After: ... DBMS_SQL.IS_OPEN(exec_cursor,is_open); IF is_open = 1 THEN ... Before: ... p VARCHAR2(32767); ... After: ... p VARCHAR2(32672); ... ■ PL/SQLstatements that required additional adjusted 32 © 2010 IBM Corporation © 2011 IBM Corporation
  33. 33. IBM Data Movement Tool – How to Use5. Data movement to DB2 33 © 2010 IBM Corporation © 2011 IBM Corporation
  34. 34. Conversion step by step (IV) 34 © 2010 IBM Corporation © 2011 IBM Corporation
  35. 35. minimal changes for3 - Application Code Conversion standard interfaces■ Configure DB2 access interface – Standardized interfaces: JDBC, ADO.NET, PDO, etc. • Focus on changing connection strings/configuration. Eg: Class.forName(“com.ibm.db2.jcc.DB2Driver”) DriverManager.getConnection(“jdbc:oracle:thin:@server.com:5000:db1”) Class.forName(“com.ibm.db2.jcc.DB2Driver”) DriverManager.getConnection(“jdbc:db2://server.com:5000/db1”) – Application that use Oracles OCI can leverage DB2CI: • DB2CI is an OCI compatible client that supports 150+ OCI functions – Other interfaces... might require more work (Eg: Pro*C) ■ No concurrency problems: Currently Committed isolation level provides same behavior as Oracles statement level isolation. –“Writers dont block readers” 35 © 2010 IBM Corporation © 2011 IBM Corporation
  36. 36. Conversion step by step (V) Before: After: ■ Changed connection properties ■ DB2 driver in use 36 © 2010 IBM Corporation © 2011 IBM Corporation
  37. 37. Conversion Roadmap - Before and After DB2 9.7 Months/Years Days/Weeks 1. Map schema and data types 1. Map schema and data types • Different types behavior. Eg: DATE • Support to VARCHAR2, • Separate DDL for different RDBMS 2. Move data NUMBER, DATE 3. Translate PL/SQL code 2. Move data (Triggers/Procedures/Functions) • Automated with IBM Data • Missing built-in functions & packages Movement Tool • Missing functionality: REF CURSORs, %TYPE, … 3. Run your shared code 4. Translate SQL in application logic • Native support (manual) – NO EMULATION!! • Untyped expressions (thousands of occurences) • Minor adjustments 5. Debugging 4. Test and Tuning • Hard to fix concurrency problems 6. Test and Tuning •  It is even possible to share one source for both DB2 and Oracle 37 © 2011 IBM Corporation 37
  38. 38. Conversion step by step ■ Oracle-based application analyzed and converted to DB2 during this event! ■ Code changes are the exception not the rule 38 © 2011 IBM Corporation
  39. 39. Questions? © 2011 IBM Corporation
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×