Download "Developing DB2 SPs using Developer Workbench ...


Published on

  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide
  • Note: Content Assist requires an assigned connection to happen. So, if the editor is launched from the Database Explorer launch bar as opposed to the connection folder, content assist is not active.
  • Saved statements are “imported” later on. Execute using the Run > Run SQL
  • * Some setup required on the z/OS side to enable actual costing
  • To launch the wizard, you need to Create a data development project Right-click > New > Other Expand the Data folder > SQLJ Applications > SQLJ File
  • Java stored procedures pertain to both dynamic SQL (JDBC) and static SQL (JDBC) Java stored procedures
  • When deploying a native SQL SP using binaries, the tooling will call the built in procedure SYSPROC.DSNTBIND and pass in a constructed BIND PACKAGE DEPLOY command containing any options specified by the user. The bind option ACTION(REPLACE) is always used. The COPYVER() option will always be specified and the version-id passed in will be that of the native SQL procedure selected for deploy. The REPLVER() version-id will be set to the same as the one for COPYVER. This will ensure that the procedure's versions match up between the source and target DB2 systems. All other options (e.g., WLM environment, runtime options, external security etc...) will be ignored by the tooling.
  • Source, parameter list and options are stored in catalog Procedural statements are converted to a native representation and stored in packages Run native SQL stored procedure executes the package. This is the package that DB2 for z/OS creates on behalf of native SQL SPs.
  • The CREATE PROCEDURE statement registers a SQL procedure as a new object with an initial version. Default value is “V1”. Additional versions can be added with the ALTER statement with the ADD VERSION clause. One or more versions of a procedure may exist, but only one version is active. When a routine is first created, that initial version is active. The new CURRENT ROUTINE VERSION special register can be used to override which version is the active one for a connection. This does not, however, result in a change to the active version recorded in the catalog. The special register allows a level of control to invoke a routine version without having to fully activate it.
  • In DB2 for z/OS, the default version is V1. DWB is different so user can identify easily the Version id.
  • For native PSM, the “procedure options” have been expanded to allow the user to specify the usual routine options, bind options and runtime options. Routine options such as: DETERMINISTIC, CALLED ON NULL INPUT, MODIFIES SQL, etc. Bind options such as: ISOLATION LEVEL, REOPT, VALIDATE(BIND / RUN) Runtime options such as: ASUTIME, WLM ENVIRONMENT
  • 1 - User may not have specified these keywords in V8 NFM; or may have edited them out of the DDL.
  • - Each jar in the Jars folder in the Database Explorer (under its respective Schema node) will have a drop option in its context menu. It is necessary to have supporting jars in the Database Development project so that they are available for local Java stored procedure compilation and for setting the proper associations on the server. - Supporting jars contain classes referenced by another class in another jar. In LUW, it is enough to simply install the jars because of the way jars are searched at runtime. In z/OS, the - Properties view extracts information from SYSIBM.SYSJAROBJECTS.
  • Deployment of supporting jars: When a supporting jar is imported or drag and dropped to a project, a Jars folder will be created. The folder contains the supporting jars. Each jar will have information regarding the location of the jar file in the local file system, the SQL jar name, and the Java Path. 2. Deployment of a complex Java stored procedure The deploy process will deploy all of the jars specified in the Java path, so that the user doesn’t have to do so before deploying the Java stored procedure New Stored Procedure changes The New Stored Procedure wizard, the user will be able to select a jar node from the Jars folder, under the same Database Development project, where the procedure should be packaged in.
  • Prior to V9, if customers wanted to debug a SQL SP, they had to purchase the IBM Distributed Debugger. To debug a Java SP, the customer had 2 options Create comparable DDL and SQL on a DB2 for LUW connection and use the Distributed Debugger to debug the Java SP on the client. When the debugging is successful, copy and paste the Java SP to DB2 for z/OS; OR Write a bunch of System.out.println and System.err.println Check redbook for setting up JAVAERR and JAVAOUT DD statements with JDK 1.3; or using the JAVAENV variable, WORK_DIR to set up the files for receiving the println output.
  • Example of nesting: SQL stored procedure that calls a Java stored procedure, or a Java stored procedure that calls an SQL stored procedure. .Net addin, IBM Database tools for Visual Studio 2005 also exploits the Unified Debugger in their tool.
  • ALTER SP to switch from ALLOW to DISALLOW will require a recompile of the routine to remove or insert the debugger hooks. Switching from ALLOW to DISALLOW will require a recompile Switching from DISALLOW to DISABLE will NOT require a recompile; changes catalog information only Switching from DISABLE to ALLOW or DISALLOW is not permitted. Routine must be dropped first. DEBUG_MODE = 1, enabled; 0 – not enabled; N – can never be enabled
  • The user can define XML Queries and test them out in DWB. After they are created satisfactorily, they can be embedded in applications and stored procedure bodies. All created XML Query artifacts are stored in the XML Queries folder in a Data Development Project.
  • You must build an example instance document for every document you intend to include in the query. This is necessary so that the query builder knows the structures of the documents to build the appropriate XPaths, etc.
  • You must also associate the instance documents you supplied (or created in this wizard) with an XML column from the database. Select each column and click on the Associate… button to bring up a dialog that allows you to navigate to XML columns in the database. You can do this at a later time, but if you do not do it up front, you will be prompted for this association every time you execute the query in the tooling.
  • You can drag and drop resources from the left-hand side of the XQuery editor to the palette on the right-hand side. When you build the query, you can drill down elements and go up from where you drilled down.
  • The upper right button allows you to step up the hierarchy and the one next to the resource in the palette (For Logic) allows you to drill-down for refinement.
  • You can view the source that is generated for the XML Query by clicking on the Source tag in the lower-left of the editor. Note that you cannot modify the Source pane to change the query in this release; it is only for reading.
  • There are a few ways of executing the XML Query. First you save the editor and then you can go to the created XML query in the XML Queries folder and launch the Run… action. If you did not associate the documents with XML columns when creating the query, you will be required to do so at this time.
  • To launch the Migrate DC wizard, select File->New->Other... then Select Data"DB2 Development Center Project" and click Next. OR: File->Import... .Select Data"DB2 Development Center Project" and click Next. Development Center supported multiple database connections per project; DWB projects have single connections.
  • Download "Developing DB2 SPs using Developer Workbench ...

    1. 1. Developing DB2 stored procedures using Developer Workbench Marichu Scanlon IBM Silicon Valley Lab San Jose, CA, USA [email_address]
    2. 2. Agenda <ul><li>Overview </li></ul><ul><li>Basic Eclipse concepts </li></ul><ul><li>DWB concepts </li></ul><ul><li>SQL tools </li></ul><ul><li>Stored procedure and UDF development </li></ul><ul><li>Ad-hoc database development </li></ul><ul><li>SQLJ development </li></ul><ul><li>Advanced Topics </li></ul>
    3. 3. IBM Developer Workbench (DWB) <ul><li>Data application development tool </li></ul><ul><ul><li>User-defined functions </li></ul></ul><ul><ul><li>Stored procedures </li></ul></ul><ul><ul><li>SQL scripts </li></ul></ul><ul><ul><li>Develop, deploy, test, debug </li></ul></ul><ul><li>Integration tool </li></ul><ul><ul><li>Data objects with Java applications </li></ul></ul><ul><li>Eclipse based </li></ul><ul><ul><li>Common team support interface </li></ul></ul><ul><ul><li>Common user experience model </li></ul></ul><ul><li>Runs on Windows or Linux workstations </li></ul><ul><li>Connects to DB2 UDB for z/OS </li></ul><ul><ul><li>Works also with DB2 UDB for iSeries and LUW, as well as Derby </li></ul></ul><ul><ul><li>Connect to DB2 for z/OS V9 currently in Beta </li></ul></ul>
    4. 4. Activities and benefits of DWB <ul><li>Builds, parses and runs SQL statements </li></ul><ul><li>Visually explains execution of SQL statements </li></ul><ul><li>Guides developing of stored procedures and user defined functions </li></ul><ul><li>Deploys stored procedures and user defined functions </li></ul><ul><li>Provides a single debugger for SQL and Java SPs </li></ul><ul><li>Helps keep track of history </li></ul>
    5. 5. Activities and benefits of DWB <ul><li>Increases code reuse </li></ul><ul><ul><li>Access supporting Java jars during development </li></ul></ul><ul><li>Makes development of SQLJ applications easier </li></ul><ul><li>Creates modules for binary deployment </li></ul><ul><li>Supports runtime binding of package variations for stored procedures </li></ul><ul><li>Helps working with XML </li></ul><ul><li>Maps XML schemas (XSD) to relational schemas </li></ul>
    6. 6. Eclipse <ul><li>A consortium of companies developing open source development platforms </li></ul><ul><ul><li>Initiated by IBM </li></ul></ul><ul><ul><li>Currently most successful open source project by number of contributing participants </li></ul></ul><ul><li>The major delivery is the Eclipse Integrated Development Environment (IDE) </li></ul><ul><ul><li>Defines extensibility interfaces and integration points </li></ul></ul><ul><ul><li>Several specialized projects extend the basic IDE (Web Tools Project – WTP, Data Tools Project – DTP) </li></ul></ul>
    7. 7. Eclipse concepts <ul><li>Workspace </li></ul><ul><ul><li>The space to save all user metadata – scripts, XSD, configuration </li></ul></ul><ul><ul><li>Implemented by root directory on the filesystem </li></ul></ul><ul><ul><li>Can not be nested </li></ul></ul><ul><ul><li>Can be shared </li></ul></ul><ul><ul><li>User works in exactly one workspace at a certain point of time </li></ul></ul><ul><ul><li>Set when starting the environment </li></ul></ul>
    8. 8. Eclipse concepts <ul><li>Project </li></ul><ul><ul><li>A logical storage concept used to store related user metadata </li></ul></ul><ul><ul><li>Assigned to one workspace </li></ul></ul><ul><ul><li>Implemented as a directory in a workspace </li></ul></ul><ul><ul><li>Can be shared </li></ul></ul><ul><ul><li>User can work in any number of projects at the same time </li></ul></ul><ul><ul><li>Can be dynamically opened and closed </li></ul></ul><ul><li>View </li></ul><ul><ul><li>A visual tool providing defined functionality that can be placed on the user interface </li></ul></ul><ul><ul><li>Examples are: property view, error log view, data output view, project explorer </li></ul></ul>
    9. 9. Eclipse concepts <ul><li>Editor </li></ul><ul><ul><li>A visual tool assigned to a specific type of element (SQL script, project, XSD) able to modify the element </li></ul></ul><ul><li>Perspective </li></ul><ul><ul><li>Saved configuration of views, editors, and menus typically used to realize specific activities (for example SQLJ development) </li></ul></ul><ul><ul><li>One perspective is active </li></ul></ul><ul><ul><li>Any number of perspectives can be defined </li></ul></ul><ul><ul><li>User can change perspectives </li></ul></ul>
    10. 10. Most important Eclipse concepts Database view Project view Editor Properties view Perspec-tive Output view
    11. 11. DWB concepts <ul><li>Data Project Explorer view </li></ul><ul><ul><li>Displays projects and is starting point for development features </li></ul></ul><ul><ul><li>Development objects are saved independently of the database </li></ul></ul><ul><ul><li>Deployment and execution assigned with the database </li></ul></ul><ul><li>Database Explorer view </li></ul><ul><ul><li>Defines Connections to databases using JDBC interface </li></ul></ul><ul><ul><li>Ad-hoc features for stored procedures, user defined functions and SQL </li></ul></ul>
    12. 12. DWB concepts <ul><li>Data output view </li></ul><ul><ul><li>Reporting of execution related activities and results </li></ul></ul><ul><li>Data perspective </li></ul><ul><ul><li>Tools for development of SQL applications </li></ul></ul><ul><ul><li>Default perspective </li></ul></ul><ul><li>Java perspective </li></ul><ul><ul><li>Tools for development of SQLJ applications </li></ul></ul><ul><li>Note: to change perspectives, click on </li></ul><ul><ul><li>Window > Open Perspective </li></ul></ul>
    13. 13. Database connection <ul><li>Defined in the Database Explorer </li></ul><ul><ul><li>Type of the database </li></ul></ul><ul><ul><li>Server address </li></ul></ul><ul><ul><li>Port </li></ul></ul><ul><ul><li>JDBC driver </li></ul></ul><ul><li>Context dependent start of ad-hoc functions </li></ul><ul><li>Database explorer is “reverse-engineered” catalog of objects saved in databases </li></ul><ul><ul><li>Filtering of objects available </li></ul></ul>
    14. 14. Data Development Project <ul><li>Assigned to database connection </li></ul><ul><ul><li>Capabilities dependent on the type of the database </li></ul></ul><ul><li>Functions dependent on objects being manipulated </li></ul><ul><li>Logical folders for object types </li></ul><ul><ul><li>SQL scripts </li></ul></ul><ul><ul><li>Stored Procedures </li></ul></ul><ul><ul><li>User-Defined Functions </li></ul></ul><ul><ul><li>XML Schema Documents (XSD) </li></ul></ul><ul><li>Contains objects being developed </li></ul><ul><ul><li>Everything created in the database explorer must be saved in a project </li></ul></ul>
    15. 15. SQL Tools <ul><li>SQL builder </li></ul><ul><ul><li>User interface to visually build and edit SQL-DML statements </li></ul></ul><ul><ul><li>Syntax and some semantic validation (e.g. table/column resolution, correlation ids) </li></ul></ul><ul><ul><li>Possibility to omit specified schema from generated SQL for portability </li></ul></ul><ul><ul><li>Launch Visual Explain and Actual Costing (z/OS) </li></ul></ul><ul><ul><li>Keyword highlighting and content assist </li></ul></ul>
    16. 16. SQL Tools <ul><li>SQL editor </li></ul><ul><ul><li>Supports multiple statements with configurable statement terminator </li></ul></ul><ul><ul><li>Supports execution of any valid SQL statement </li></ul></ul><ul><ul><li>Keyword highlighting and content assist </li></ul></ul><ul><li>SQL wizard </li></ul><ul><ul><li>Launched from or embedded within other wizards to assist with SQL creation </li></ul></ul>
    17. 17. SQL builder <ul><li>Guided statement creation </li></ul><ul><li>Three pane editor </li></ul><ul><ul><li>SQL statement </li></ul></ul><ul><ul><li>Graphical description </li></ul></ul><ul><ul><li>Statement options </li></ul></ul><ul><li>You can parse and save SQL statements in your project for re-use or further development </li></ul><ul><li>You can execute the SQL statement and view the results in the Data Output View </li></ul>
    18. 18. SQL editor <ul><li>Edit any SQL statement </li></ul><ul><li>Execute the content of the editor (even without saving) </li></ul><ul><li>Format SQL </li></ul><ul><li>Content tip </li></ul><ul><li>Content assist </li></ul>
    19. 19. Stored procedure and UDF development <ul><li>Display existing routines from a database server </li></ul><ul><li>Create a new DB2 or Derby routine via a wizard </li></ul><ul><li>Import a routine source file or copy an existing procedure into the development project </li></ul><ul><li>Edit the procedure source and properties with the routine editor </li></ul>
    20. 20. Stored procedure and UDF development <ul><li>Build and deploy the procedure to a database </li></ul><ul><li>Export procedures for IDE independent batch deployment </li></ul><ul><li>Run a routine </li></ul><ul><li>Debug stored procedures (SQL and Java for DB2, Java for Derby) </li></ul><ul><li>Drag and drop routines from a database connection to the project </li></ul>
    21. 21. Creating stored procedure or UDF The New action launches a multi-page wizard that allows you to customize the generated stored procedure The first page allows the selection of the language: Java using JDBC, Java using SQLJ and SQL
    22. 22. Creating stored procedure and UDF The SQL page of the wizard allows you to import existing SQL statements, write your own with the SQL wizard or manually type or paste it in
    23. 23. Store procedure and UDF – actual cost Actual cost of running the SQL statement can be invoked from the SQL Statement page of the create procedure wizard. Only available for projects connected to a DB2 z/OS
    24. 24. Stored procedure and UDF – visual explain You can invoke Visual Explain for the given SQL statement from within the wizard. You can also invoke it from within the routine editor for SQL routines. Visual Explain is available for DB2 z/OS V8 (windows clients) and DB2 LUW.
    25. 25. Stored procedure and UDF – import The import action launches a multi-page wizard that allows you to create a stored procedure or UDF by importing a routine source file or by selecting an existing routine from another project . In a source file with multiple routines, only one routine can be imported at a time
    26. 26. Stored procedure and UDF – editor and actions <ul><li>Routine editor supports both the project and Database Explorer </li></ul><ul><li>Actions available on a stored procedure in your project </li></ul><ul><li>Results of execution displayed in the Data Output view </li></ul>
    27. 27. Stored procedure and UDF – deployment, execution <ul><li>Develop on one database, deploy it to a different database server (e.g. develop on DB2 LUW and deploy to DB2 z/OS) </li></ul><ul><li>Specify the schema qualifier during deploy </li></ul><ul><li>The Run action executes a call of the stored procedure </li></ul><ul><li>Run asks for input parameter values </li></ul>
    28. 28. Stored procedure and UDF – export and deploy <ul><li>Export to file system </li></ul><ul><ul><li>Generates DB2 script file, for Java an ANT script and a properties file for customization </li></ul></ul><ul><ul><li>Allows deployment of the stored procedure independent of the IDE </li></ul></ul><ul><li>Batch Deploy for Java and external SQL SPs </li></ul><ul><ul><li>Properties file for customized settings </li></ul></ul><ul><ul><ul><li>Target database, username and password, procedure options like WLM environment </li></ul></ul></ul><ul><ul><ul><li>To deploy run from command prompt: ant -buildfile [filename].xml </li></ul></ul></ul><ul><li>Batch deploy for native SQL routines on z/OS V9 or SQL routintes on LUW </li></ul><ul><ul><li>Customize the DB2 script file directly </li></ul></ul>
    29. 29. Ad-hoc database development functions
    30. 30. SQLJ database development functions <ul><li>New SQLJ File Wizard </li></ul><ul><ul><li>Generates code based on IBM or user customized templates </li></ul></ul><ul><li>SQLJ Editor </li></ul><ul><ul><li>SQLJ clause highlighting </li></ul></ul><ul><ul><li>Syntax errors within SQLJ statements and Java code are flagged in the editor and task view </li></ul></ul><ul><ul><li>Code assist for Java statement </li></ul></ul><ul><ul><li>Wizards provided to insert new SQLJ clauses </li></ul></ul><ul><li>SQLJ translation </li></ul>
    31. 31. SQLJ database development functions <ul><li>Customize/Bind of SQLJ Profiles </li></ul><ul><ul><li>Generates Ant scripts to customize SQLJ profiles and bind packages to the target database </li></ul></ul><ul><li>Debugging </li></ul><ul><ul><li>Supports using the .sqlj file as the source file during debugging </li></ul></ul>
    32. 32. Stored Procedure and UDF development tooling: Language and Server Support Not supported SQL (scalar and table), special table UDFs (MQSeries) Not supported Not supported before v8 new-function mode; no table UDFs User Defined Functions Derby (IBM Cloudscape) DB2 LUW V8 – V9 DB2 iSeries: V5R1,V5R2 - V5R3 - DB2 zOS V7 – V9 Java Java (JDBC and SQLJ) and SQL SQL Java (JDBC and SQLJ) and SQL Java (JDBC and SQLJ) and SQL Stored Procedures
    33. 33. SQL Tools SQL editor SQL builder Any database that DWB supports Any database that DWB supports Database Server
    34. 34. Stored Procedure/UDF tooling and SQL statements: Special Features Support Routine development tooling in Data Development Project Routine debugging Statement Cost from routine wizard Visual Explain Special Feature DB2 (LUW, iSeries, z/OS) and Derby (IBM Cloudscape) Java and SQL procedures for DB2 v9 and Java procedure for Derby (IBM Cloudscape) DB2 z/OS DB2 LUW and DB2 z/OS (Client Windows platform) Database Server
    35. 35. SQLJ Tooling SQL customization SQLJ translation DB2 v8 and v9 for z/OS and LUW, V5 for iSeries Any supported DWB database given a valid sqlj.jar for the target database. Database Server
    36. 36. Additional Features for DB2 for z/OS in Developer Workbench Marichu Scanlon IBM Silicon Valley Lab San Jose, CA, USA [email_address]
    37. 37. Agenda <ul><li>V8 and V9: </li></ul><ul><ul><li>Enhanced deploy functions for stored procedures </li></ul></ul><ul><ul><li>Package variation for SQL and SQLJ stored procedures </li></ul></ul><ul><ul><li>Unified Debugger for SQL and Java stored procedures </li></ul></ul><ul><li>V9 only: </li></ul><ul><ul><li>Native SQL stored procedures </li></ul></ul><ul><ul><li>Multiple jar support for Java stored procedures </li></ul></ul><ul><ul><li>XML Support </li></ul></ul><ul><li>V8 only </li></ul><ul><ul><li>DC Project Migration </li></ul></ul>
    38. 38. Enhanced deploy functions in DWB <ul><li>Deploy SQL and Java stored procedures to unlike servers </li></ul><ul><ul><li>DB2 for LUW to DB2 for iSeries </li></ul></ul><ul><ul><li>DB2 for LUW to DB2 for z/OS </li></ul></ul><ul><ul><li>DB2 Cloudscape (Java only) to DB2 LUW </li></ul></ul><ul><li>Deploy DB2 for LUW, iSeries and z/OS Java stored procedures from an exported file using ant script </li></ul><ul><li>Deploy DB2 for z/OS SQL Stored Procedures from an exported file using ant script </li></ul><ul><li>Binary Deploy of DB2 for LUW and DB2 for z/OS stored procedures to a like server </li></ul><ul><ul><li>Optionally copy the source as well </li></ul></ul>
    39. 39. Deploy Wizard external changes User needs to enter the target dataset for the load module Specify “Deploy using binaries if available in the database”
    40. 40. Binary Deploy of DB2 for z/OS stored procedures <ul><li>Requirements / Restrictions </li></ul><ul><ul><li>External SQL stored procedures </li></ul></ul><ul><ul><ul><li>Need to customize z/OS enablement stored procedure job, DSNTIJCC </li></ul></ul></ul><ul><ul><ul><li>Setup authorization for z/OS enablement stored procedures </li></ul></ul></ul><ul><ul><ul><li>Target load library needs to be preallocated </li></ul></ul></ul><ul><ul><li>Java stored procedures </li></ul></ul><ul><ul><ul><li>Connect to target z/OS server with IBM DB2 Universal Driver </li></ul></ul></ul><ul><ul><ul><li>Cannot binary deploy Java stored procedures originally built using DSNTJSPP </li></ul></ul></ul><ul><ul><li>Native SQL stored procedures </li></ul></ul><ul><ul><ul><li>Only the following bind options are valid for binary deploy of native SQL stored procedures </li></ul></ul></ul><ul><ul><ul><ul><li>target COLLECTION ID </li></ul></ul></ul></ul><ul><ul><ul><ul><li>QUALIFIER </li></ul></ul></ul></ul><ul><ul><ul><ul><li>OWNER </li></ul></ul></ul></ul>
    41. 41. Package Variation - overview <ul><li>Create variations of packages with different bind options for SQL and SQLJ java stored procedures on a DB2 z/OS system. </li></ul><ul><li>Display the packages under the Package folder in the Database Explorer. </li></ul><ul><li>Allow users to select the package of their choice before executing the stored procedure using Collection ID field in Run Settings Options panel. </li></ul><ul><li>Allow users to view the properties of these packages in the Properties View. </li></ul><ul><li>Allow users to drop these packages from the Database Explorer. </li></ul><ul><li>Available from the Database Explorer as packages are associated only with the DB2 server. </li></ul>
    42. 42. Package Variation Usage <ul><li>Initially deploy a SQL or SQLJ stored procedure on a DB2 z/OS server using NO COLLID option </li></ul><ul><ul><li>Allows the user to select the collid at runtime. </li></ul></ul><ul><li>Bind the collid you want the new package to reside in using, otherwise will get -805 at execution time. </li></ul><ul><li>In Database Explorer, create new package variation </li></ul><ul><ul><li>Right-click on Stored Procedure -> Packages -> New </li></ul></ul><ul><li>Specify bind options for Bind Copy in the Package Variations wizard. </li></ul><ul><li>Click Finish to deploy the new package to the server. </li></ul>
    43. 43. Package Variation – executing the stored procedure <ul><li>Select another collection id </li></ul><ul><ul><li>Right-click on Stored procedure > Run Settings > Options tab > Collection ID > Browse button </li></ul></ul><ul><li>Displays list of collection Ids associated with this package. </li></ul><ul><li>Right-click on Stored procedure > Run to execute this package. </li></ul>
    44. 44. Package Variation - properties <ul><li>Select specific package from the Database Explorer </li></ul><ul><li>Select Package tab to view the properties in the Properties View </li></ul>
    45. 45. Native SQL Stored Procedures <ul><li>DB2 for z/OS V9 now supports 2 kinds of SQL SPs: </li></ul><ul><ul><li>External or Generated-C SQL stored Procedure </li></ul></ul><ul><ul><ul><li>User specifies FENCED or EXTERNAL keywords in the Create Procedure DDL </li></ul></ul></ul><ul><ul><li>Native SQL stored procedure </li></ul></ul><ul><li>Features of Native SQL stored procedures: </li></ul><ul><ul><li>Ability to version a stored procedure </li></ul></ul><ul><ul><li>Ability to “activate” a particular version of a stored procedure </li></ul></ul>
    46. 46. Native SQL stored procedures - Versioning <ul><li>SAME schema, procedure name, number of parameters, and parameter type </li></ul><ul><li>Allows difference in procedure body, parameter names and options </li></ul><ul><li>Only one version is ACTIVE </li></ul><ul><ul><li>When routine is first created, the initial version is activated </li></ul></ul><ul><ul><li>“Activate” a version by right-click on stored procedure > Set Active </li></ul></ul><ul><li>Create additional versions from the Database Project Explorer only </li></ul><ul><ul><li>Right-click on specific stored procedure > Add Version </li></ul></ul>
    47. 47. Create new Native SQL SP <ul><li>Create using the Create SP wizard </li></ul><ul><ul><li>Right-click on Stored Procedure > New </li></ul></ul><ul><li>DWB Version default = VERSION1 </li></ul><ul><li>Versions show in same level as the first version in the Data Project Explorer </li></ul>
    48. 48. Adding a Version <ul><li>To create a new version of a SP: Right-click on SP > New Version </li></ul><ul><li>Versions must have the same SP name and number of parameters and parameter types </li></ul><ul><ul><li>Can change some parm attribute, e.g. VARCHAR(20) to VARCHAR(200) </li></ul></ul><ul><li>Body of the procedure can be changed </li></ul><ul><li>Procedure options can be changed (e.g. ISOLATION CS to ISOLATION RR) </li></ul><ul><li>Can set ALLOW and DISALLOW debug </li></ul>
    49. 49. Native SQL SP – Procedure options <ul><li>WLM environment can be specified only when “Enable for debugging” is checked </li></ul><ul><ul><li>Click “Advanced” button </li></ul></ul><ul><li>Procedure options specified in the Create Procedure DDL </li></ul><ul><li>Collection ID is initially set to schema; specify different collection id in PACKAGE bind option </li></ul><ul><li>Build owner set through CURRENT SQLID field in project properties </li></ul>
    50. 50. Native SQL SP – Migration / Fallback issues <ul><li>When DB2 for z/OS server migrates to V9 new function mode </li></ul><ul><ul><li>External stored procedures without FENCED or EXTERNAL 1 keywords can be “converted” to native SQL stored procedures by redeploying the routine. DB2 assigns a version of V1. </li></ul></ul><ul><li>When DB2 for z/OS server re-enters V9 compatibility mode </li></ul><ul><ul><li>Disallow changes to native SQL stored procedures </li></ul></ul><ul><ul><li>Allow Run capabilities only </li></ul></ul><ul><ul><li>Disallow drag and drop of native sql stored procedures to a project associated with a connection in compatibility mode. </li></ul></ul>
    51. 51. Multiple Jar Support <ul><li>Allows users to reference classes in other jar files installed in the server </li></ul><ul><li>Exploits the SQLJ.ALTER_JAVA_PATH function </li></ul><ul><ul><li>Java stored procedures can reference classes that are neither in the CLASSPATH of the associated Java stored procedure WLM proc, OR in the jar that the stored procedure resides in. </li></ul></ul><ul><li>Ability to associate an installed jar file with a Java path </li></ul>
    52. 52. Multiple Jar Support – Database Explorer <ul><li>View / browse all jars installed on the server </li></ul><ul><li>View jars that are dependent on a particular jar </li></ul><ul><li>Drop supporting jars </li></ul><ul><ul><li>A “supporting jar” is a jar that will be referenced by another jar at runtime. </li></ul></ul><ul><li>Drag and drop/paste a supporting jar from the Database Explorer to a Database Development project for use by one or more routines </li></ul><ul><li>View the catalog data and Java path in the Property Browser for each jar </li></ul>
    53. 53. Multiple Jar Support Dependencies folder Java Path
    54. 54. Multiple Jar Support - Data Project Explorer <ul><li>Add supporting jars to a stored procedure via: </li></ul><ul><ul><li>Import Wizard - imports a jar from the file system </li></ul></ul><ul><ul><ul><li>This creates a Jar node in the Stored Procedure folder </li></ul></ul></ul><ul><ul><li>Drag and drop from Database Explorer </li></ul></ul><ul><li>Deploy one or multiple supporting jars to the server using the Deploy Jar wizard. </li></ul><ul><li>Ability to drop or replace the jar if already installed in the server; or to exit deployment. </li></ul><ul><li>Edit the supporting jar characteristics, such as Java path during deploy. </li></ul><ul><li>Deploy Java stored procedure and all its supporting jars into the same jar file </li></ul>
    55. 55. DB2 Unified Debugger <ul><li>Development Center v8.2 had SQL Debugger for debugging DB2 for z/OS external SQL stored procedures; no support for debugging Java stored procedures. </li></ul><ul><li>DB2 9 One debugger for multiple platforms. Shipped with: </li></ul><ul><ul><li>DB2 for LUW V9 </li></ul></ul><ul><ul><li>DB2 for zSeries V8 and V9, and </li></ul></ul><ul><ul><li>DB2 for iSeries V5R4 </li></ul></ul><ul><li>DWB is the client front end that: </li></ul><ul><ul><li>allows users to remotely debug server side SQL and Java stored procedures. </li></ul></ul><ul><ul><li>allows users to perform source-level debugging using the Debug Perspective </li></ul></ul>
    56. 56. DB2 for z/OS V9 Unified Debugger Features <ul><li>Stand alone mode support </li></ul><ul><ul><li>Debugging a single a SQL/Java procedure </li></ul></ul><ul><ul><li>Debugging a nested SQL/Java procedures </li></ul></ul><ul><li>Cross-language application support </li></ul><ul><ul><li>Nested SQL/Java procedures </li></ul></ul><ul><ul><li>C#/VB application calling SQL procedures </li></ul></ul><ul><li>Cross-platform support </li></ul><ul><ul><li>DB2 for z/OS v8/v9, DB2 for LUW v8/v9, DB2 for iSeries v5r4 </li></ul></ul><ul><li>Client or Server-side Session Manager </li></ul><ul><ul><li>for .Net, Session Manager is only on Server </li></ul></ul>
    57. 57. DB2 Unified Debugger features <ul><li>For V9, supports debugging a specific version of a native SQL stored procedure </li></ul><ul><li>CREATE / ALTER options </li></ul><ul><ul><li>Specify DISALLOW / ALLOW / DISABLE DEBUG MODE </li></ul></ul><ul><ul><li>WLM ENVIRONMENT FOR DEBUG (for Native PSM) </li></ul></ul><ul><li>New column in SYSIBM.SYSROUTINES: DEBUG_MODE </li></ul><ul><li>Session Manager can be on the client or server. </li></ul><ul><ul><li>If on the client, user can point to any z/OS system to debug. </li></ul></ul>
    58. 58. Unified Debugger - Preferences <ul><li>Select where Session Manager will be launched </li></ul><ul><li>Session Manager on DB2 V9 for LUW can be started when DB2 starts </li></ul><ul><ul><li>Need to setup port in the services file </li></ul></ul><ul><li>WLM Environment to be used by the stored procedure when debugging can be specified in the Preferences > </li></ul><ul><li>Session Manager on DB2 for z/OS started by issuing console command: </li></ul><ul><ul><li>START DB2UDSMD </li></ul></ul>
    59. 59. Unified Debugger – Debug Perspective <ul><li>DWB leverages the Debug Perspective of Eclipse </li></ul><ul><li>Has all of standard debug views (source code, variables, call stack, and break points) </li></ul><ul><li>Supports all standard debug commands (step into, step over, set break point, update variable…) </li></ul>
    60. 60. Unified Debugger – Debug Perspective variables source Debug commands
    61. 61. Query building – launching the XML Query builder
    62. 62. Query building – specifying representative documents for the XML Query builder
    63. 63. Query building – XML Query builder – associating documents with XML columns to query against
    64. 64. Query building – XML Query builder work area
    65. 65. Query building – stepping into and out of resources in the XML Query builder
    66. 66. Query building – XML Query builder source view
    67. 67. Query building – running an XML Query
    68. 68. Migrating a Development Center Project to DWB <ul><li>Reuse projects created in DC; continue work in DWB </li></ul><ul><li>Existing projects can exploit DWB functions </li></ul><ul><li>Migrate projects using the Migrate DC Project wizard </li></ul><ul><li>Wizard allows creating new connections if an existing connection is not found </li></ul>
    69. 69. Migrate DC Project wizard <ul><li>Input DC project must be a .dcp file </li></ul><ul><li>Point to the .dcp file using a File Browser </li></ul><ul><li>Once project is loaded, all DC project connections are shown </li></ul><ul><ul><li>DC projects allowed multiple connections; DWB projects only have one </li></ul></ul><ul><li>DWB will attempt to match the selected connection to existing connections in the Database Explorer. </li></ul>
    70. 70. References <ul><li>IBM Redbook, “DB2 for z/OS Stored Procedures: Through the Call and Beyond”, SG24-7083-00 </li></ul><ul><ul><li> </li></ul></ul><ul><li>“ Build once, deploy everywhere: Binary deploy of DB2 for z/OS stored procedures”; </li></ul><ul><ul><li> </li></ul></ul><ul><li>“ Create package variations for z/OS DB2 stored procedures” </li></ul><ul><ul><li> </li></ul></ul>
    71. 71. References <ul><li>“ DB2 Developer Workbench, Part 1: Developer Workbench concepts and basic tasks”; </li></ul><ul><ul><li> </li></ul></ul><ul><li>“ DB2 Developer Workbench, Part 2: Developer Workbench and stored procedures”; </li></ul><ul><ul><li> </li></ul></ul><ul><li>“ DB2 Developer Workbench, Part 3: Developer Workbench and XML”; </li></ul><ul><ul><li> </li></ul></ul>