DB2 for z/os Stored Procedure support in Data Server Manager

Similar documents
DB2 for z/os: Programmer Essentials for Designing, Building and Tuning

IBM Data Studio for Mainframe Developers. David Simpson, Senior Technical Advisor Themis, Inc.

Empowering DBA's with IBM Data Studio. Deb Jenson, Data Studio Product Manager,

Introduction to IBM Data Studio, Part 1: Get started with IBM Data Studio, Version and Eclipse

Introduction to IBM Data Studio, Part 1: Get started with IBM Data Studio, Version and Eclipse

DB2 Stored Procedure and UDF Support in Rational Application Developer V6.01

This page intentionally left blank

Business Insight Authoring

Using SQL Developer. Oracle University and Egabi Solutions use only

Defining an ODBC data source

DB Change Manager. User Guide. Version 17.0 Published December 2017

Using the IMS Explorer with the IMS Catalog Hands-on Lab

Using IBM Rational Business Developer wizards to create a Web application

Using the IMS Universal Drivers and QMF to Access Your IMS Data Hands-on Lab

IBM DB Getting started with Data Studio Hands-On Lab. Information Management Cloud Computing Center of Competence.

APEX Times Ten Berichte. Tuning DB-Browser Datenmodellierung Schema Copy & Compare Data Grids. Extension Exchange.

Test/Debug Guide. Reference Pages. Test/Debug Guide. Site Map Index

Build and Deploy Stored Procedures with IBM Data Studio

Themis and Themis, Inc. are trademarks of Themis, Inc.

Enterprise Data Catalog for Microsoft Azure Tutorial

DBArtisan XE Pro and DBArtisan Evaluation Guide

Embarcadero DB Optimizer 1.0 Evaluation Guide. Published: July 14, 2008

Millennium Expert/Enterprise Installation Guide Version Table of Contents

IBM DB2 11 DBA for z/os Certification Review Guide Exam 312

DB2 QMF Data Service Version 12 Release 1. Studio User's Guide IBM SC

Managing IBM Db2 Analytics Accelerator by using IBM Data Server Manager 1

Managing Automation for SAP BOBJ Enterprise Processes

Perceptive Nolij Web. Administrator Guide. Version: 6.8.x

DbSchema Forms and Reports Tutorial

Guided Exercise 1.1: Setting up the sample OpenEdge Data Object Services

Database Explorer Quickstart

Enterprise Modernization for IBM System z:

IBM Optim Query Workload Tuner for DB2 for z/os 4.1. Hands-on Labs

DbSchema Forms and Reports Tutorial

IBM. Database Database overview. IBM i 7.1

EUSurvey OSS Installation Guide

Teradata Studio Express

DB2 for z/os Stored Procedures Update

Imagine. Create. Discover. User Manual. TopLine Results Corporation

Product Documentation. DB Optimizer. Evaluation Guide. Version Published November 27, 2009

Embarcadero PowerSQL 1.1 Evaluation Guide. Published: July 14, 2008

2015 Beta 2 Tutorials

Rapid SQL 7.5 Evaluation Guide. Published: September 28, 2007

ORACLE SQL DEVELOPER

IBM i Version 7.2. Database Database overview IBM

Getting Started with Xpediter/Eclipse

At the shell prompt, enter idlde

Teiid Designer User Guide 7.5.0

Building a Simple Workflow Application for the Sybase Unwired Server [Part 3]

Product Overview. Technical Summary, Samples, and Specifications

WebSphere. Clips and Tacks: Getting started with the IBM BPM suite of products

IMS Hands-on Lab - Using The New IMS Explorer To Access Your IMS Data

Optimize Enterprise Generation Language (EGL) applications using purequery

Content Matrix. Evaluation Guide. February 12,

BMC Remedy Action Request System Using a BIRT Editor to Create or Modify Web Reports

Oracle Enterprise Manager Oracle Database and Application Testing. Data Masking Lab. Session S318966

Fastrack to federated replication

Composer Help. Import and Export

EnterpriseTrack Reporting Data Model Configuration Guide Version 17

WPS Workbench. user guide. "To help guide you through using the WPS user interface (Workbench) to create, edit and run programs"

IBM DB2 Control Center

Logi Ad Hoc Reporting Management Console Usage Guide

User Guide Zend Studio for Eclipse V6.1

VMware AirWatch Database Migration Guide A sample procedure for migrating your AirWatch database

Including Dynamic Images in Your Report

IBM z/os Management Facility Hands-on Lab

Where did Visual Explain Go?

Oracle Database 10g Express

Real Application Security Administration

Tool Create Database Diagram Sql Server 2008 R2

Installing SQL Server Developer Last updated 8/28/2010

Table of Contents DATA MANAGEMENT TOOLS 4. IMPORT WIZARD 6 Setting Import File Format (Step 1) 7 Setting Source File Name (Step 2) 8

Creating a Dashboard Prompt

BEAWebLogic. Portal. Tutorials Getting Started with WebLogic Portal

Sql Server 2008 Query Table Schema Management Studio Create

Toad Data Point - Professional Edition. The Toad Data Point Professional edition includes the following new features and enhancements.

Using UCMDB Integration Studio to Setup Integration with Service Manager

Logi Ad Hoc Reporting System Administration Guide

ZENworks Reporting System Reference. January 2017

Embarcadero DB Optimizer 1.5 Evaluation Guide. Published: March 16, 2009

Talend Open Studio for Data Quality. User Guide 5.5.2

appcompass Developer s Guide For: appcompass Data Integration Studio appcompass Business Rules Studio appcompass Visual Studio Editions

This presentation is for informational purposes only and may not be incorporated into a contract or agreement.

SAS Model Manager 2.2. Tutorials

Contents Overview... 5 Downloading Primavera Gateway... 5 Primavera Gateway On-Premises Installation Prerequisites... 6

IBM DB2 Query Patroller. Administration Guide. Version 7 SC

Automatically Generate Xml Schema From Sql Server Tables

Toad for IBM DB About Toad for IBM DB2. New Features. Contents. General Features. Database Map. Monday, November 2, 2015

Chapter 1. Introduction to SASLE and Statistics

Console Guide. Version 4.4

HP Database and Middleware Automation

Using Apama with Software AG Designer

QS-AVI Address Cleansing as a Web Service for IBM InfoSphere Identity Insight

From business need to implementation Design the right information solution

Logi Ad Hoc Reporting System Administration Guide

Quick Start Guide TABLE OF CONTENTS COMMCELL ARCHITECTURE OVERVIEW COMMCELL SOFTWARE DEPLOYMENT INSTALL THE COMMSERVE SOFTWARE

IBM Database Conversion Workbench 3.5

BUILD YOUR OWN SAP FIORI APP IN THE CLOUD Exercise Week 5

Enterprise Vault.cloud CloudLink Google Account Synchronization Guide. CloudLink to 4.0.3

Rapid SQL XE and Rapid SQL Evaluation Guide

Transcription:

DB2 for z/os Stored Procedure support in Data Server Manager This short tutorial walks you step-by-step, through a scenario where a DB2 for z/os application developer creates a query, explains and tunes it, then wraps the query inside a native SQL stored procedure. It will also discuss briefly the differences between Data Studio and Data Server Manager (DSM). Data Studio is not going away Contrary to some rumors, Data Studio is not going away. What is happening is that the database / subsystem administration support available in Data Studio for DB2 for LUW and DB2 for z/os have been replicated in DSM. Our current objective is not to replace the application development capabilities of Data Studio, but to gradually move the database administration support to DSM. Thus, support for features in DB2 for z/os version 12, and all subsequent versions, will only be added in DSM. You can still use Data Studio with DB2 for z/os V11 and below. The following table shows you, at a high-level, that most of the features in Data Studio are also in DSM. Feature Data Studio DSM (Dec 2016) v2.1.2 Local Help content Yes Yes Database catalog filter Yes Yes Database overview diagrams Yes No Integrated query editor (SQL and XQuery) with query formatting SQL builder Yes No Routine test configuration Yes No Database configuration check for routine development Yes No Yes Yes Stored procedure editor and debugger Yes No debugger, only SQL PL User-defined function editor and debugger Yes No debugger, only SQL PL XML editor, schema editor, and annotated XSD mapping editor Yes No Data Web Services development and deployment Yes No SQL outline view Yes No Statistics advisor Yes Yes Query environment capture Yes Yes Access plan graph generation Yes Yes

Feature Data Studio DSM (Dec 2016) v2.1.2 Create, alter, or drop single database objects Yes Partially IBM InfoSphere Federation Server support Yes Yes View and edit privileges for DB2 data server objects and authorization IDs Impact analysis - report on dependencies Yes Yes Generate DDL Yes No Generate maintenance and data preservation commands Compare, sync, and migrate objects Yes No Export rows from the SQL results view (csv only ) Yes Yes Load data with SQL Yes No Browse or edit data and filter the view by columns and rows Yes Yes Yes Yes No Yes DB2 for z/os Database Administration Most DB2 for z/os DBAs do not rely on, or use, Data Studio for managing their DB2 for z/os subsystems. Instead, they use DB2 for z/os tools, such as: IBM Administration Tool for DB2 for z/os Computer Associates Database Administration Suite for DB2 for z/os BMC s Database Administration Tool for DB2 for z/os. Application developers, on the other hand, use Data Studio to gain insight into the DB2 for z/os catalog and develop queries and stored procedures. DSM is not designed to be an application development tool, however, one can still use DSM to develop native SQL Stored Procedures. Installing DSM for z/os Just as with Data Studio, you will need to install DSM on a Linux, Unix or Windows environment. However, unlike Data Studio, you only need to set up DSM once. You connect to the DSM server through your web browser, using the URL specified when the DSM server was set up. Also, installing Data Studio requires Eclipse and Installation Manager. Neither are needed to install DSM. Finally, Data Studio objects are contained in projects stored within a workspace. DSM objects are stored in-memory or in a Derby database (for the no-charge version) supplied by DSM. NOTE: This tutorial does not go through the DSM server setup. You can download the no-charge DSM from the following web site: Launching DSM 1 Open a new tab in the browser; and enter the DSM server following URL, for example: http://9.30.42.106:11080/console (SD: If this is different for all users, I don t think we need an example)

2 Enter the user id and password you specified during set up in corresponding fields below. You can add additional users that can access DSM through the Users and Privileges section. 3 Click Log In to launch the DSM Welcome page. The navigation bar on the left of the console allows you to select tasks to perform. These menu options expand into functional categories that let you directly access the base product function. Contrast this to Data Studio s Task Launcher which uses the tabs across the view to access detailed functions. Creating a database connection profile As with Data Studio, we need to create a connection to the database.

4 From the navigation bar, select Settings >Managed Connections 5 In the Managed Connections view, click Add to add a new connection to your subsystem. 6 In the Add Database Connection dialog, fill in the fields using the hints given below: Data Connection name: select a descriptive name for this connection (e.g. QA_DB2v11). Data server type: select DB2 for z/os from the drop-down list Obtain the location, hostname, and port number from the results when you issue DISPLAY DDF from TSO or console. The User ID and Password you enter should have the required privileges to connect to, and manage certain DB2 catalog tables as well as execute privilege to certain DB2-supplied stored procedures. Visit this link: https://www.ibm.com/developerworks/community/wikis/home?lang=en#!/wiki/w377e39cb6e13_4 2a7_b752_005b67cb913f/page/Privileges%20Required%20for%20DSM%20on%20DB2%20zOS for more information on required DSM privileges for DB2 for z/os. Your completed dialog should look like the screen capture below:

7 Click Test Connection. If the connection is successful, click OK. The newly created database connection should now appear in the Database Connection grid. Using the SQL Editor The SQL Editor in DSM performs functions similar to those of the SQL Editor in Data Studio. In Data Studio, you need to first create a project (specifically, a Data Development project) from which you can create queries and stored procedures. As in Data Studio, you need to associate a database connection to the query or stored procedure. DSM uses a drop-down list called the DB Picker, to select the managed connection. 8 Click the DB picker and select your newly created connection.

9 From the right navigation area, click Run SQL. If asked to do so, re-enter your password. You can also check the Save this user ID and password checkbox for future use. You should see: In the Other materials for this tutorial, we provide you with a file that you can import into the SQL editor. You may also simply enter the query straight into the SQL Editor pane. 10 Select Script > Open from Client.

A file browser dialog box is launched. Navigate to where you saved the query from the Other Materials folder. 11 After you click OK, the query is inserted in the script area. 12 Save the script for future use by selecting Script >Save. 13 The default name will be Script1, but you can specify a different name that is more descriptive. If you specify a name that already exists, DSM will let you know and will ask if you want to replace the original script. 14 Click OK. DSM will save it under the Saved Scripts tab. Let us proceed to running and tuning our query. 15 In the far right-hand side of the SQL Editor, click the Options button. The Current SQLID is the authorization ID that will be used when the query is executed. The Default schema is the high-level qualifier (HLQ) of the unqualified tables used in the query. We are using the sample tables shipped with DB2 for z/os. For DB2 for z/os V11, the HLQ for the sample tables is DSN81110.

Click the Options button again to dismiss the dialog. 16 To test this query, select Run > Run All The outcome of the execution is shown in the Result area. You can click the Log and Log Result Set links in the View results column to see the execution log and returned result set.

Optimizing a single query Before we embed this query inside a stored procedure, let s make sure that it is optimized. DSM allows you to create the access plan graph for a query and/or run the statistics and index advisors for the query. 17 Go back to the SQL Editor area. This time, select Run > Explain. We want to find out the query s access plan graph. The statement s Access Plan Graph is shown. Note that since there are two sub-select statements in our query, DSMz will have a tab for each sub-select. 18 Hover over the nodes to get the details of each operation. 19 Click Environment & Explain Options. Details about the Explain settings are shown. 20 Now, let s tune the query. Click Run SQL to go back to the SQL Editor. Click Run > Tune to tune the statement. 21 In the Select Tuning Activities To Run page, specify the Default schema (DSN81110) and specify the authorization ID under which this will run. Note that this ID should have access to the EXPLAIN tables. For our example, the Default SQLID as DSMADM. You can also replace the system-generated job Job name with a more descriptive one (e.g. TuneTest01).

22 Scroll-down to see the Explain options. Expand this section. We will not change anything here. 23 Scroll down further and expand the Advanced options. De-select the checkbox for Re- EXPLAIN the SQL statement.

24 Click Run. A message box opens, explaining that you must refresh the console to see when the tuning job has completed. Click OK.

Although the Indexes check box is checked, the base version of DSM does not allow you to invoke the Index Advisor. The DSM used to create this tutorial is the Enterprise version. Also, as you create your tuning jobs or other jobs, please note that different job numbers will be generated for you by DSM. However, most jobs are annotated, e.g. Query Tuning, RUNSTATS, etc. You can use the Filter function in the Tuning Jobs or Job History views to find the job you want to view. 25 After the dialog is dismissed, DSM will direct you to the Tuning Jobs view, where you can see the progress of this tuning job. 26 Click the Refresh icon to update the Status of the job. When the status is Succeeded, select the job, then click on View Results. Once again, the view is refreshed, and a new tab for the Tuning Results (your job name) is created. The default initial tab is Recommendations. Here you see a summary of the generated recommendations to improve the query s performance. We see that there are two Statistics recommendations and one Index recommendation. Let s look at the Statistics recommendation.

27 Click the 2 in the current tab page, or simply click RUNSTATS Script. You can choose to run the recommended RUNSTATS job now or later. Let s check the index recommendation first. 28 Click Index Script. DSM allows you to run the recommended DDL to create the index, run the query as if the recommended index was created with Test Candidate Indexes, or, new in DSM 2.1.1, run an Impact Analysis to see whether other queries would be affected by the creation of the new index. For this tutorial, we will skip executing the tuning recommendations. That will be for another tutorial. We will continue as if the query is well-tuned. Creating a native SQL stored procedure Now that we have tuned our query, let s embed it into a native SQL stored procedure. 29 Still in the SQL Editor, make sure the DSMz_Script1 script is still checked in the Saved Scripts grid. 30 Scroll down and check the row Template SQL Stored Procedure. 31 Click Replace.

The SQL Editor area is refreshed and both the script and the SQL stored procedure template are shown.

The next series of steps assumes a familiarity with SQL Stored Procedure syntax and commands. This tutorial does not cover how to code a SQL stored procedure. Please refer to the Knowledge Center to learn the components, sections, valid SQL statements and control statement to use within a SQL stored procedure. Please see: http://www.ibm.com/support/knowledgecenter/ssepek_11.0.0/apsg/src/tpc/db2z_sql procedure.html You may see some errors at first. Don t panic. This is because we need to specify a different statement terminator, to indicate when the CREATE PROCEDURE statement ends. 32 Click the Options button. 33 Change the Statement Terminator to @, as shown below. 34 If not set, change the Current SQLID to the authorization ID that will create the stored procedure, and the Default Schema to the HLQ for the unqualified tables in the query (i.e. DSN81110). 35 Click the Options button again to dismiss this panel. The resulting SQL Editor area may show errors. Ignore them for now. We will need to: a. Remove the OR REPLACE keyword in the CREATE PROCEDURE statement b. Qualify the stored procedure with your given User ID. c. Cut and paste the query inside the SQL stored procedure declaration area. d. Add a cursor declaration e. Add a line to leave the cursor open.

The resulting code will look like this: 36 Click Script > Save to save the stored procedure in DSM. The Save Script dialog opens. 37 Name the stored procedure with a name of your choice (e.g. DSM_MYSQLSP), as shown in the screen cap below.

38 Click OK to complete the action. The new script is shown in the Saved Scripts tab in the bottom of the SQL Editor. 39 In the SQL Editor, select Run > Run All. This will create the stored procedure.

When the CREATE PROCEDURE completes, DB2 for z/os creates a catalog entry for this procedure. We can view this procedure along with other objects, using DSM. Viewing stored procedures 40 From the navigation bar, select Administer > Application Objects > Stored Procedures 41 Filter the result set by entering PROCEDURE1 in the Filter by Name field.

42 Verify that the new stored procedure is created under DSMUSER01 (or under the HLQ you specified for the procedure in the CREATE PROCEDUREL DDL). 1.1.2 Creating a new version of the stored procedure You can use the SQL Editor to alter or create a new version of a native SQL stored procedure. Let us modify our recently created procedure. 43 Click the procedure name, PROCEDURE1. A new tab is added that shows the properties, dependencies and current privileges of the procedure. 44 Click Open in SQL Editor. A new tab is created. 45 In the SQL Editor, add a VERSION line and modify the FETCH FIRST statement to fetch 10 rows instead of 3.

46 Ensure the options for CURRENT SQLID and Default schema is set, as in step 1.1.1 32. 47 Click the Options button and change the Statement Terminator to @, as shown below. 48 If not set, change the Current SQLID to authorization ID used to run the DDL, and the Default Schema to DSN81110. (Can you guess why?) 49 Click the Options button again to dismiss this panel.

50 Select Run > Run All to create the new version. 51 Click the Procedure Explorer tab to verify the new version by clicking the Refresh button. 52 Click one of the inactive procedures to see the properties. Native SQL Stored procedures do not run in WLM address spaces unless it is being debugged. When you create a native SQL Stored procedure, DB2 for z/os automatically assigns the default WLM application environment, set during installation or migration. You can debug native SQL stored procedures using Data Studio. You need to make sure that the required WLM is available and is started. 53 Click the Dependencies tab. This will show you what database objects this stored procedure impacts.

Conclusion In this tutorial, we have shown how you can use DSM to create, view, and alter Native SQL stored procedures. You can still use Data Studio to produce the same results and, for now, it is also the preferred tool for continuing to develop your Native SQL stored procedures.