IBM Software Group Peggy Rader - [email protected]DB2 Development Center Advanced Topics for z/OS IBM Software Group | DB2 Information Management Software Agenda Getting Started Environment Settings JDBC Driver Support Using Java SDK 1.3.1 and SDK 1.4.1 Multiple versions of SQL and Java SPs Miscellaneous February 2005 (c) IBM Corporation 1-2
30
Embed
DB2 Development Center Advanced Topics for z/OS Software Group Peggy Rader - [email protected] DB2 Development Center Advanced Topics for z/OS IBM Software Group | DB2 Information
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
IBM Software Group | DB2 Information Management Software
Select Different Build Utility
Create New SPSelect different Build utility on the Options->Advanced->z/OS Options->Build Options->Build utilityPopdown list appears
Example shows SQL Build Utility-- Java selection
similar --
February 2005 (c) IBM Corporation 31-32
IBM Software Group | DB2 Information Management Software
Select Different Build Utility...Update Existing SP
From Project View, select SP-->Right click->Properties->Options->Advanced->Build Options->Build utility
If previously created successfully, drop will fail as proc will have different datasets
Popdown selection
list
IBM Software Group | DB2 Information Management Software
Miscellaneous TopicsUsing code fragmentsMultiple SQL statements with a single result setMultiple SQL statements with multiple result setsUse DC to Copy/Paste SPs between serversDeploying SQL or Java stored procedures without recompiling
February 2005 (c) IBM Corporation 33-34
IBM Software Group | DB2 Information Management Software
Using Code Fragments - SQL Stored ProceduresHeader fragment
Enter code that the wizard will insert in the stored procedure header
Variable declaration fragment
Enter code that the wizard will insert in the stored procedure variable declaration section
Exception handlers fragment
Enter code that the wizard will insert in the stored procedure exceptions handlers section
Pre-return fragmentEnter code that the wizard will insert in the stored procedure pre-return section
IBM Software Group | DB2 Information Management Software
Using Code Fragments - Java Stored ProceduresHeader fragment
Enter code that the wizard will insert in the stored procedure header
Imports fragmentEnter code that the wizard will insert in the stored procedure import section
Data fragmentEnter code that the wizard will insert in the stored procedure data section
Method fragmentEnter code that the wizard will insert in the stored procedure method section
February 2005 (c) IBM Corporation 35-36
IBM Software Group | DB2 Information Management Software
Multiple SQL Statements with a Single Result SetUsing the new wizard when creating SQL or Java stored procedures
From the Definition panel, click the "..." to the right of the Statement setting
# of Result sets
IBM Software Group | DB2 Information Management Software
Multiple SQL Statements with a Single Result Set
On the SQL Statement panel, select
Generate Multiple SQL statements
Click the Add buttonGenerates another SQL statement window
Click OK to generate CASE statement code
February 2005 (c) IBM Corporation 37-38
IBM Software Group | DB2 Information Management Software
Multiple SQL Statements with a Single Result Set ...
--Declare cursorsDECLARE cursor1 CURSOR WITH RETURN FOR
SELECT SCHEMA,NAME,WLM_ENVIRONMENT FROM SYSIBM.SYSROUTINES;DECLARE cursor2 CURSOR WITH RETURN FOR
SELECT SCHEMA,NAME FROM SYSIBM.SYSROUTINES;--Cursor left open for client applicationOPEN cursor1;--Cursor left open for client applicationOPEN cursor2;
END P1
Sample code generated for SQL
IBM Software Group | DB2 Information Management Software
Use DC to Copy/Paste SPs Between ServersSupports different platforms
z/OS to z/OS, Windows, Linux, Unix or i5/OSWindows to Windows, Linux, Unix, z/OS or i5/OSUnix to Unix, z/OS, Linux, Windows or i5/OSLinux to Linux, Unix, z/OS, Windows or i5/OSi5/OS to i5/OS, z/OS, Windows, Linux or Unix
Requires same DDL supported on source and target serverOpen Project
Add DB Connection for Source and Target ServerSelect SP folder in Source Server
Select SP folder on Target ServerRight Click->PasteModify SP as needed
Windows SP to z/OS requires WLM Environment addedBuild SP
February 2005 (c) IBM Corporation 41-42
IBM Software Group | DB2 Information Management Software
Use DC to Copy/Paste SPs Between Servers ...
Select DB8A z/OS V8 server
Create DEVL7083.JAVATEST SPCopy from z/OS V8 Server
IBM Software Group | DB2 Information Management Software
Use DC to Copy/Paste SPs Between Servers ...
Select DB2G OS/390 DB2 V7 server
Paste DEVL7083. JAVATESTUpdate WLM Environment to DB2GDEJ1 via SP propertiesBuild SP
February 2005 (c) IBM Corporation 43-44
IBM Software Group | DB2 Information Management Software
Deploying SQL Stored Procedures Without RecompilingCurrently, no direct support in DC or other IBM productSteps
Registering the stored procedureBefore registering the DDL, you may need to update the COLLID, WLM AE name, and the SCHEMACopy the DBRMs from the source server and bind the DBRMs in the target serverCopy the compiled SQL module into the production data setGrant execute authorization on the stored procedure
See SG24-7083 Appendix C.1.11 Sample REXX execs for configuration management
IBM Software Group | DB2 Information Management Software
Deploying SQL Stored Procedures Without Recompiling...Promotion of external stored procedures - Compile only once
February 2005 (c) IBM Corporation 45-46
IBM Software Group | DB2 Information Management Software
Deploying Java Stored Procedures Without RecompilingCurrently, no direct support in DC or other IBM productDC installs the compiled Java class bytes and *.ser file (SQLJ only) in the DB2 catalog as a BLOB
SYSIBM.SYSJARCONTENTS
See SG24-7083 Deploying SQL or Java stored procedures without recompiling *
Java stored procedures
* Sample code for steps on next 3 slides found in Redbook, Chapter 29.5.5
IBM Software Group | DB2 Information Management Software
Deploying Java Stored Procedures Without Recompiling ...Extract Java SP from source DB2 server catalogFTP Java SP as JAR or *.CLASS (and *.ser files for SQLJ) from source to target DB2 serverFTP DBRMs (SQLJ only) from source to target DB2 server
Using Legacy JDBC Driver
Bind DBRMs in target DB2 server
February 2005 (c) IBM Corporation 47-48
IBM Software Group | DB2 Information Management Software
Deploying Java Stored Procedures Without Recompiling ...Register procedure in target DB2 server
Modify DDL as necessary (COLLID, WLM ENVIRONMENT)
On target DB2 serverIf SP executed from DB2 catalog
Call SQLJ.INSTALL.JARIf SP executed from JVM Classpath
Update Java SP execution WLM proc //JAVAENV DD statement classpath with JAR
Grant EXECUTE authorization
IBM Software Group | DB2 Information Management Software
Deploying Java Stored Procedures Without Recompiling ...Compile once -
External proceduresDevelopment Production
Extract SPDB2
CatalogModified
DDLDefine stored
procedure
Copy JAR or CLASS
and SER
Call SQLJ.INSTALL_JAR
Bind DBRMsDB2
DBRM lib
HFSHFS
DBRMs Copy
Update WLMproc
DB2 Catalog
//JAVAENV ..CLASSPATH
Runfrom DB2 Catalog
Yes
No
February 2005 (c) IBM Corporation 49-50
IBM Software Group | DB2 Information Management Software
DC 8.2 - FP7Topics
IBM Software Group | DB2 Information Management Software
New DC 8.2 SupportGenerate SP for
Universal JDBC driver on DB2 for z/OS V8Maximum size of JDBC and SQLJ stored procedures increased from 32 KB to 10 MB when using the Universal JDBC driver
applies to both Java source and JAR
New Environment SettingsProvides default build for Java SPs
Select Legacy JDBC driver or Universal JDBC driverSupports COLLID value
Server Connection support for Build processLegacy JDBC Driver type 2 connectivityUniversal JDBC Driver type 2 connectivityUniversal JDBC Driver type 4 connectivity
New
New
February 2005 (c) IBM Corporation 51-52
IBM Software Group | DB2 Information Management Software
DC 8.2 used for Changing JDBC DriversApplies to z/OS DB2 V8 onlyCan use DC to migrate SP from Legacy JDBC driver to Universal Driver
Select existing SP into DC Project that uses Legacy JDBC driverModify SP Properties
Select Build Options"Uncheck" use DSNTJSPPUpdate WLM proc to point to proc with //JAVAENV support for Universal JDBC driver
e.g. JCC_HOME must point to driver, default ->/usr/lpp/db2/db2810/jccRebuild
IBM Software Group | DB2 Information Management Software
DC 8.2 Security Enhancements for Secondary Auth IDs
Database Connection Options
SQL Schema or SQL ID
If it exists, used for SET CURRENT SQLID
Package ownerBuild owner
February 2005 (c) IBM Corporation 53-54
IBM Software Group | DB2 Information Management Software
DC 8.2 Security Enhancements for Secondary Auth IDs ...Package owner
Used for package creating and package bindingThe package owner must hold all the privileges required to create and bind the package for the stored procedure, including
BINDADDCREATE ON COLLECTIONAll privileges necessary for executing the SQL statements within the stored procedure package
If no secondary authorization ID is specified here, the Logon Userid is used
IBM Software Group | DB2 Information Management Software
DC 8.2 Security Enhancements for Secondary Auth IDsBuild owner
Applies to the procedure registration in the DB2 catalogMust hold the CREATEIN ON SCHEMA privilegeIf no authorization name is specified for ‘Build owner’, the SQL ID becomes the default ‘Build owner’If no secondary authorization ID is specified here, the Logon Userid is used
February 2005 (c) IBM Corporation 55-56
IBM Software Group | DB2 Information Management Software
DC 8.1 or DC 8.2 and Secondary Auth IDs
Explicitly update Bind Options during initial Build
IBM Software Group | DB2 Information Management Software
DC SQL Debugger on z/OS DB2 V8
Running SQL Debugger on multi-IP address clientLike a home network
SQL Debugger daemon selects defaultIP Address
First in the list as presented in an IPCONFIG command promptPort
4553
To override default requires FP8IP address to use is the address to the MVS host that your DB2 V8 resides onIf processing behind a firewall
PORT address must be opened for input/output on the server
FP8 required
February 2005 (c) IBM Corporation 57-58
IBM Software Group | DB2 Information Management Software
New Redbook on DB2 for z/OS Stored Procedures
SG24-7083www.redbooks.ibm.com
Includes additional
material - See Appendix C
Refreshed November
2004
IBM Software Group | DB2 Information Management Software
Additional InformationIBM Websites
DB2 Development Centerhttp://www-106.ibm.com/developerworks/db2/zones/db2dc/index.html
Data Management Developer Domainhttp://www7b.software.ibm.com/dmdd/
DB2 for z/OS Stored Procedure Infohttp://www.ibm.com/software/data/db2/os390/spb/
RedbooksSG24-5485: Developing Cross-Platform DB2 Stored proceduresSG24-5945: Java Stored Procedures Learning by ExampleSG24-7083: DB2 for z/OS Stored Procedures: Through the CALL and Beyond
White PapersJDBC drivers supported by the DB2 Stored Procedure Builder and DB2 Development Center for OS/390 and z/OS
http://www-106.ibm.com/developerworks/db2/library/techarticle/dm-0408rader/index.htmlJava SDKs for DB2 Development Center on OS/390 and z/OS
http://www-106.ibm.com/developerworks/db2/library/techarticle/dm-0409rader/Getting Started - DB2 Dev Ctr to Create SQL and Java SPs - 2 Parts