Post on 02-Jun-2018
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 1/147
®
IBM Software Group
© 2013 IBM CorporationLast Update: November, 2013
Jon Sayles, Rat ional System z pr oduc ts - jsay les@u s.ibm .com
Module 8 - The Data Tools – SQL Code/Test and DB2 Table Access
Including IBM Data Studio v4.1
Note that these slides can be used with RDz versions: 8.0.3
9.0
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 2/147
2 © 2013 IBM Cor oration
IBM Trademarks and Copyrights © Copyright IBM Corporation 2011, 2012, 2013. All rights reserved.
The information contained in these materials is provided for informational purposes only, andis provided AS IS without warranty of any kind, express or implied. IBM shall not beresponsible for any damages arising out of the use of, or otherwise related to, thesematerials. Nothing contained in these materials is intended to, nor shall have the effectof, creating any warranties or representations from IBM or its suppliers or licensors, oraltering the terms and conditions of the applicable license agreement governing the useof IBM software. References in these materials to IBM products, programs, or services donot imply that they will be available in all countries in which IBM operates.
This information is based on current IBM product plans and strategy, which are subject tochange by IBM without notice. Product release dates and/or capabilities referenced inthese materials may change at any time at IBM‟s sole discretion based on marketopportunities or other factors, and are not intended to be a commitment to future productor feature availability in any way.
IBM, the IBM logo, the on-demand business logo, Rational, the Rational logo, and other IBMRational products and services are trademarks or registered trademarks of theInternational Business Machines Corporation, in the United States, other countries orboth. Other company, product, or service names may be trademarks or service marks ofothers.
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 3/147
3 © 2013 IBM Cor oration
The RDz Workbench Curriculum
Module 1 -The RDz Workbench and introduction to Eclipse
Module 2 – Editing Your COBOL Programs
Module 3 – Analyzing COBOL Programs Module 4 – Remote Systems – Connect, Navigate and Search
Module 5 – Remote Systems – Dataset Access and Organization
Module 6 – Remote Systems – ISPF 3.x, Batch Jobs and Host Emulation
Module 7 – MVS Subprojects – Organizing PDS Members and SCM Checkout
Module 8 - The Data Tools – SQL Code/Test and DB2 Table Access
Module 9 - Debugging z/OS COBOL Applications
Module 10 – RDz/Endevor Integration Through CARMA
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 4/147
4 © 2013 IBM Cor oration
Course Overview
Audience
This course is designed for application developers who have learned or
programmed in COBOL, and who need to do z/OS Traditional Development andMaintenance as well as build leading-edge applications using COBOL andRational Developer for System z.
Prerequisites
This course assumes that the student has a basic understanding and knowledgeof software computing technologies, and general data processing terms,concepts and vocabulary, as well as a working knowledge of COBOL and z/OS.
Knowledge of SQL (Structured Query Language) is assumed for databaseaccess is assumed as well.
Basic PC and mouse-driven development skills, terms and concepts are also
assumed.
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 5/147
5 © 2013 IBM Cor oration
If you are not a DB2/SQL expert…
Many (in the thousands of) books exist that do an excellent job teaching SQL.
Additionally, sites exist on the Internet (GOOGLE: “SQL tutorials” – or “Learn SQL”)for online (and typically free) education.
IBM Also supplies excellent SQL and DB2 documentation:DB2 Documentation
SQL Getting Started
SQL Reference Manual
Message (error code) Reference. Cached pdf version of full guide.
DB2 Application Development Guide with example embedded SQL programs.Triggers in DB2
Constraints in DB2
And there are plenty of non-IBM sites to learn about SQL:Http://en.wikipedia.org/wiki/SQL
Note: In order for you to get the above links to work, view the PowerPoint inSlide Show mode.
Here is an example of COBOL database access: http://publib.boulder.ibm.com/infocenter/dzichelp/v2r2/index.jsp?topic=/com.ibm.db29.doc.apsg/db2z_sa
m
plecoboldrdathreepartnames.htm
*** Notes
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 6/147
6 © 2013 IBM Cor oration
If You Are Using IBM Data Studio + RDz – Version 9 and Later
If you have installed IBM Studio and RDz version 9 and later some of the cosmetic (U.I.) andsome of the product features and techniques described in this material will be very differentfrom prior releases.
Look for v9 in the slide header for details of minor differences in the functionality
And there is a separate „deep-dive‟ section in these slides for RDz v9+Data Studioinstallation, configuration and usage
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 7/1477 © 2013 IBM Cor oration
UNIT
Topics:
The RDz Workbench
The Data Perspective and Connecting to DB2
Understanding DB2 objects and dependencies
Editing and managing DB2 table data
Coding and testing SQL
The V9 Data Studio + RDz Features
Workshops and Appendices
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 8/1478 © 2013 IBM Cor oration8
z/OS Development,Maintenance and Production Application Support
Access Datasets/Source Files
Program Analysis
EnterpriseModernization
Source Development
CICSWeb Services
IMS SoapIMS Web 2.0
Source Navigation• Windows (Standard) Navigation• ISPF PF-keys + extensible Hot-keys• Outline View• Hover• Open Declaration / Arrow keys• Open copybooks
• Windows metaphor• Edit/Browse/View• “Favorites” – “Most recently used”
ISPF and RDz Source Editing• PF-Keys• Hexedit• Prefix Area Commands• Command Line Commands• Colorized statement support• Local History• PC Source editing functionality• Code refactoring
• DB2 Stored Procedure generation• Comment/Un-comment multiple lines• Access to 3270 Emulation within Eclipse• All development options “preference-enabled”
Generate:• WSDL• WSBIND file• XSD files• Deployment manifest• Stub modules• Test and Deploy WSDL• Use Cases:• Bottom Up• Top Down• Meet in the middle
Generate
• XML/WSDL
• COBOL/PLI converters
• Manifest files
Use Cases:
• Bottom Up
• Top down (PL/I only)
• Meet in the middle
SCM:• IBM: Team Concert, SCLM, ClearCase• CA: Endevor, Panvalet, Librarian,
• Serena: Changeman• ISPW
RDz Functional Taxonomy – a Partial List
Submitting/Managing Jobs
• Submit and Locate Job• Integration with JES• Job Organization options (Filters)• Show JCL• Cancel/Purge
Windows Screen Real Estate• Size-able views• Multi-window development• Source Filters• Collapse/Expand paragraphs/sections
• SCM functional integration• PDS Support• Migrate/Recall Support• Local and Remote file support• Tooling support in single or across multiple LPARs
• Source and PDS Search• QSAM Data File Search• Browse Load Module• Search Load Library• Use of Regular Expressions
Program Logic tools• Control Flow Analysis• Data Flow Analysis
• Data Model Analysis• Where used/Where Referenced
Content Assist• COBOL, PL/I, Assembler
• SQL: Embedded, Interactive• CICS statements
Dataset Management CICSService Flows• 3270 "screen scraping"• Aggregate transactions• Automate processes• Expose as web services
Syntax Check and Build• Real-time validation• Local and Remote Syntax Checking• Integration with z/OS Build Process
Test and Debug• Integration with PD Tools/Debug Tool• Integration with Xpeditor and CA-Intertest
Editing Data Sources
• DB2 Table Editor• IMS Segment Editor• QSAM File Editor• VSAM File Editing with File Manager• Integration with File-Aid Plug-ins
• Allocate/ Rename/Delete• Create GDG Model• Create VSAM Dataset• Search• Compress
Code Quality• Code Review• Source Format• File Compare• All of the above functionality
Copy Files• Within an LPAR• Across LPARs• LPAR PC
Functional Integration with z/OS REXX/CLIST/3rd Party Tools:• Menu Manager• HATS
• Eclipse Plug-in Integration RDz Product Integration
Languages• COBOL, PL/I, Assembler, Java, C/C++• JCL/CLIST/REXX
• SQL code/test• BMS/MFS• WSDL, HTML, XML• 4GLs supported with Eclipse Tooling
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 9/1479 © 2013 IBM Cor oration
The Data Perspective – RDz's Data Tools
The Data Perspective allows you to access your datasources, and to view and add test rows, edit your tables,create and test/execute SQL statements interactively.
Access the Data Perspective from the Window menu Window > Open Perspective > Other… > Data
The Data Perspective has a number views andtools you will work with: Data Source Explorer
Shows Connections – which contain
– Schemas and tables
– Processing options
Data Output
– Shows the results of running SQL queries
Data Project Explorer For Data Analysts
SQL Statement Wizard
For building SQL statements interactively
Stored Procedure Wizard
For building COBOL, PL/I, Java and SQL
Stored Procedures interactively
D a t a T o o l s
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 10/14710 © 2013 IBM Cor oration
Why use the RDz Data Tools?
We currently use SPUFI and QMF for doing z/OS DB2 work, why change?
Two reasons:
1. Productivity:
The RDz Data Tools have vastly superior means of: – SQL statement testing
– Managing your DB2 table test data
– Full-screen table editing
– Simple data export/import
– Doing DBA tasks
– Understanding your relational data model
Easy access from the RDz Workbench
– The tools are completely integrated into eclipse
2. Cost Savings - z/OS MIPS reduction:
RDz is substantially less expensive thanTSO/SPUFI or QMF for doing
DB2/SQL development
JDBC** Drivers – Ziip/Zaap
See Slide Note on ODBC
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 11/14711 © 2013 IBM Cor oration** Requires Data Studio
What can you do with the RDz Data Tools?
Three things:1. Investigate and analyze your DB2 Data Model:
What are the DB2 "objects"? How do they relate (what are the dependencies)
2. Modify and manage DB2 Test Data:
Understand what's in your test bed
Add/Change/Delete/Copy/Paste table values
Filter table rows and columns **
3. Code, test, analyze SQL:
Interactive
Embedded
Graphical
Visual Explain **
Other aspects of the data tools that are "out of scope" for this session:
DBA Utilities
Creating/Deploying/Testing DB2 Stored Procedures
Mass Data and Schema migration
Working with IMS Databases – through the Data Tools
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 12/147
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 13/147
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 14/14714 © 2013 IBM Cor oration
Filtering Schemas and Tables – DB2 on z/OS
Your DB2 instance on z/OS,databases could easilycontain:
Tens of thousands of tables
Hundreds of Schemas
To simplify working on yourprojects - Filter the availableDB2 objects as follows:
Un-check: □ Disable Filter
Enter: DDS0001In:
Expression
Name
Click Finish to connect toDB2 and return to theData Source Explorer
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 15/14715 © 2013 IBM Cor oration
Filtering Schemas and Tables – v9 + Data Studio
Using Data Studio you will be prompted for a Physical datamodel
Click Next > without specifying anything
In V9 after un-checking Disable filter, specify your initialSchema filter from the Expression – not Selection option
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 16/147
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 17/14717 © 2013 IBM Cor oration
The Data Source Explorer – Connected
Once you're connected, the Data Source Explorer presents"meta-data" about the database objects accessiblethrough your connection as follows:
- Databases within the connection – and within the database: Schemas (the high-level qualifier of the resource owner)
Within each Schema relational object resources (DBMS-dependent) - including:
Synonyms
Stored Procedures
(if DB2 for z) – Federated Stored Procedures Tables and within tables:
– Column definitions
– Relational constraints (primary and foreign key rules)
– Indexes
– Triggers
– User-defined functions
Views The Properties view can be helpful in expanding the information
presented.
Many additional context menu options exist off these entries
V9 Note:The Data Source Explorer looks slightly different with DataStudio. But it functions in the same way.
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 18/14718 © 2013 IBM Cor oration
V9 Note:
Data > Sample Contents looks andfunctions slightly differently.
Exploring Meta Data
Use your mouse to expand/collapseDB2 object meta-data categories
Information is presented hierarchically – according to the structure in the DDLthat was used to create the object
All of the meta-data shown in theExplorer is pulled dynamically from theDB2 Catalog, making it 100%
Accurate
Current
The Context Menu provides (much)additional functionality:
Select a DB2 object
Right-click
Context options pop-up in themenu and sub-menus
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 19/14719 © 2013 IBM Cor oration
Exploring Table Meta Data – v9
IBM Data Studio provides a graphicalview of DB2 Table value distributions
This view shows column cardinality (i.e. The number of discrete values in eachselected column, throughout the Table)
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 20/14720 © 2013 IBM Cor oration
Overview Diagram – 1 of 3
So what can we do with the Data Source Explorer? Let‟s start by having a look at our tables andtable relationships (Parent/Child tables associated by defined Primary/Foreign key constraints)
From the Data Source Explorer:
Expand a folder for a database and navigate the schemas: Right-click a schema select: Add to Overview Diagram
Select the tables, views, synonyms, etc. you wish to see
Notes:
This kind of diagram (seeresults on next slide)is often called an"Entity-RelationshipDiagram" – because itdraws out therelationships betweenyour DB2 "entities" – tables/views/synonyms
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 21/14721 © 2013 IBM Cor oration
(Data Model) Overview Diagram – 2 of 3
The Diagram Tool shows all of the tables, views and synonyms selected through our connection as entities, andtheir relationships as defined by Primary/Foreign key SQL specifications. This allows us to understand thingslike how to join tables, and where data exists in relation to other table values.
We can also use the Diagram Tool to navigate in the Data Source Explorer Right-click over Results
Select:
Navigate >
Show in >
Database Explorer
Note the different icons for:
Tables:
Events, Entrants, Results
Employee
Views:
Race_Report
Local_Referrals
Synonym:
L_R
Notes:
If you select a large number of tables this diagram can take some time to materialize
To read the diagram shown here:
Each Entrant and Event can have many Result rows
Race_Report is a relational View based on the Results table
Local_Referrals is a relational View based on the Entrants table
Tables
Table relationships
Views
Synonym
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 22/14722 © 2013 IBM Cor oration
(Data Model) Overview Diagram – 3 of 3
By default, the Overview Diagram shows only DB2 object names and their relationships. You might wishto show additional attributes. To do this:
Select the object
Right-click and select: Filters > Show/Hide Compartment > <your option>
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 23/14723 © 2013 IBM Cor oration
Generate Table DDL
You may wish to access/modify/etc. one or more of your DB2 table's DDL. To do this you'll needthe original DDL – which is obtained from: Generate Table DDL
From the Data Source Explorer: Right-click over the table name
Select: Generate DDL…
Follow the wizard
Check/Un-check selections
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 24/14724 © 2013 IBM Cor oration
UNIT
Topics:
The RDz Workbench
The Data Perspective and connecting to DB2
Understanding your DB2 objects and dependencies Editing and managing DB2 table data
Coding and testing SQL
The V9 Data Studio + RDz Features
Workshops and Appendices
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 25/14725 © 2013 IBM Cor oration
The Data Source Explorer – Data Context Menu
You can work with relational objects:
View Schemas, Tables, Table Columns, ReferentialIntegrity Constraints, Indexes, Synonyms, Aliases
Re-Create the SQL data definition language statementsfor the relational objects – from the System Catalog
For individual tables:
View the table contents
View column contents (row cardinality)
Edit table values
Extract/Load the table using a comma-delimited file Perform a DCLGEN operation
Data Source Explorer - Context Menu, Data options
Viewing a table's
column definitions
Note:
v9 content onthe next slide
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 26/147
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 27/147
9
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 28/147
28 © 2013 IBM Cor oration
Sample Table Contents – Read/Only View of a Table's Row Values – v9 Version 9 provides Browse, Edit, Sample Contents and
New “Select” Script
The # of rows returned is for Edit and “New Select Script” configurable inPreferences
Caution about the Browse Data and Sample ContentsThese options ignore the Preferences setting for maximum number of rows to return fromDB2, and on a very large table will cause Workbench performance problems
9
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 29/147
29 © 2013 IBM Cor oration
Sample Table Contents – New “Select” Script – v9 Instead of Browse Data or
Sample Contents, useNew “Select” Script
Press F5 to run the SQL
S C S C
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 30/147
30 © 2013 IBM Cor oration
Data > Sample Contents – Display Row Values in a Single Column
It can be also useful to view the sample contents of individual columns – forvarious reasons:
Applications:
Test data coverage
Testing and debugging values
DBA:
Candidate indexing
SQL performance issues related to data volume
Steps: Select a table
Expand Columns, and select a column
Right-click
Select:
Data Sample Contents
Sample Contents of a table column
1. Discrete column values
2. The number of occurrences found in thetable for each value (Cardinality)
While this technique worksin v9, see prior slide onMultivariate feature
E ti R C t t
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 31/147
31 © 2013 IBM Cor oration
Exporting Row Content
Used to save row values off as:
HTML
XMLPlain text
XLS (spreadsheet) format
Steps:
From the Result window:
Right-click
Select which rows to export
Select the Export Format
– Browse to the file name
– Be sure to enter the .file extension
Click Finish
Note that you can export the resultsof any SQL statementReduces the effort to build xml and/or
HTML or .csv reports off of DB2 data
T bl Editi V i 1 f 2
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 32/147
32 © 2013 IBM Cor oration
Table Editing Version – 1 of 2
Another very common requirement for SQL programming is to customize your test data. Rather than fussing withinteractive SQL INSERT/UPDATE/DELETE statements using QMF or SPUFI, try this:
From the Data Source Explorer
Right-click over a table
Select: Data > Edit
V9 and IBM DataStudio provide TableRow/Column Filters
T bl R V l Editi 2 f 2
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 33/147
33 © 2013 IBM Cor oration
Table Row Value Editing – 2 of 2
The table editor allows you to: Modify (update) values - Add (insert) new rows - Delete Rows
Set individual field values to null
Select image files (for columns of type: Blob/Clob)
All values are saved (committed) or not (rolled-back) at once when you press Ctrl/S
Note that using the Data Perspective you could: 1. Run a SQL Statement,2. View the SQL results, 3. Modify table data values in order to test different WHEREclause conditions, 4. Re-run the SQL Statement, etc.
See Slide Notesfor a technical explanation of the data access and locking
factors for “Sample Data” and Table Editing – through the RDz data tools.
T bl Filt i ( 9) 1 f 2
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 34/147
34 © 2013 IBM Cor oration
Table Filtering (v9) – 1 of 2
From the Data Source Explorer
Right-click over a table
Select: Data > Edit Data
Click: Filter the data
This opens the Table Data Filter dialog
Use the dialog to:
Add > Columns
Add Row Selection
Click Add
Open the Columndrop-down
Open the Operatordrop-down
Specify a search value
T bl Filt i ( 9) 2 f 2
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 35/147
35 © 2013 IBM Cor oration
Table Filtering (v9) – 2 of 2
The Data Studio table editor – in data filtering mode allows you to: Modify (update) values - Add (insert) new rows - Delete Rows
Set individual field values to null
Select image files (for columns of type: Blob/Clob)
All values are saved (committed) or not (rolled-back) at once when youpress Ctrl/S
C t i i th ( 8) D t P ti P f
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 36/147
36 © 2013 IBM Cor oration
Customizing the (v8) Data Perspective – Preferences
A number of optionsare available for
managing, controllingand customizing thebehavior of the featuresin the Data Perspective
From:Window
Preferences
– Data Management
– SQL Development
(Important) Result set options:
Max row count controls table Edit
Max display row count controls Sample Contents
Preferences
for SQL Query
Customization
C t i i th (v9) D t P ti P f
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 37/147
37 © 2013 IBM Cor oration
Customizing the (v9) Data Perspective – Preferences
Data Studio provides a much large set of tools – with the associatedpreferences/options for setup, configuration , customization, etc.
(again) from:
Window
Preferences
– Data Management
– SQL Development
Preferences
for Data Studio
Customization
Additional IBM Data Studio Tooling for Working With DB2 Objects 1 of 3
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 38/147
38 © 2013 IBM Cor oration
Additional IBM Data Studio Tooling for Working With DB2 Objects – 1 of 3
Provided you have the necessary level ofauthority in your DB2 subsystem, you can dothe following:
Work with DB2Databases
andTablespaces
Work with DB2
Storage Groups
Perform certain traditional DBAfunctions against Tables, Viewsand Indexes
Additional IBM Data Studio Tooling for Working With DB2 Objects 2 of 3
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 39/147
39 © 2013 IBM Cor oration
Additional IBM Data Studio Tooling for Working With DB2 Objects – 2 of 3
Table value statistics reporting
Additional IBM Data Studio Tooling for Working With DB2 Objects 3 of 3
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 40/147
40 © 2013 IBM Cor oration
Additional IBM Data Studio Tooling for Working With DB2 Objects – 3 of 3
DBA, SYSPROG and SQL coding options against the DB2 Subsystem
SQLProgrammingOptions
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 41/147
41 © 2013 IBM Cor oration
UNIT
Topics:
The RDz Workbench
The Data Perspective and connecting to DB2
Understanding your DB2 objects Editing and managing DB2 table data
Coding and testing SQL
The V9 Data Studio + RDz Features
Workshops and Appendices
Code Interactive SQL Statements SQL Script
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 42/147
42 © 2013 IBM Cor oration
Code Interactive SQL Statements – SQL Script
Similar to SPUFI – you use a SQL Script file to edit and test your SQL. A SQL Script is a text filethat contains interactive SQL statements – with or without host variables
These statements can be tested in the Data Perspective before embedding them in COBOL data
access functions. For complex SQL logic, this is recommended “best practice”.
To open and work with a SQL Script: From the Data Source Explorer
Right-click over the DB2 system icon shown and select: New SQL Script
Code Interactive SQL Statements SQL Script v9 w/Data Studio
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 43/147
43 © 2013 IBM Cor oration
Code Interactive SQL Statements – SQL Script – v9 – w/Data Studio
Run SQL
Access SQLfunctionality
Code SQL
SQL
Results
Data Studio provides richer functionality, and there are many additional Context Menu options(next slide)
1
2
3
4
5
Code Interactive SQL Statements SQL Script v9 w/Data Studio
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 44/147
44 © 2013 IBM Cor oration
Code Interactive SQL Statements – SQL Script – v9 – w/Data Studio
Coding,
Formatting,
Testing
Tuning options
Additional SQLcoding/testing/tuningoptions in Data StudioToolbar
Create and Run a SQL Script Statement
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 45/147
45 © 2013 IBM Cor oration
Create and Run a SQL Script Statement
You can code your SQL statements using Content Assist – to get the table names and SQL keywords(Ctrl/Spacebar)
After you're done coding, right-click (context Menu)
over the statement
Select Execute Current Text(or Execute All)
View the SQL Results
Note: For Content Assistto work, you mustqualify the DB2 table,view, synonym name:
Schema.Tablename
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 46/147
New SQL Script – Run SQL
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 47/147
47 © 2013 IBM Cor oration
New SQL Script – Run SQL
When you are finished coding1. Right-click over the script area
2. Select Run SQL
3. Verify your resultsNote that the Status will show details on your statement's execution
Working with Embedded SQL Statements (v8) - 1 of 3
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 48/147
48 © 2013 IBM Cor oration
Working with Embedded SQL Statements (v8) - 1 of 3
You can use a SQL Query to test your COBOL/SQL statements out prior to testing them at theCOBOL procedural logic level (note this saves both time and CPU resources)
Steps:
From RDz, click back over to the z/OS Perspective (but do NOT close the Data Perspective)
Open: cursravg.cbl
Find the 100-DECLARE-CURSOR-RTN paragraph shown below
Copy the SELECT… GROUP BY DEPT clauses as shown
- You will test only the interactive SQL portion of your COBOL cursor declaration
Select
andcopy
this
Working with Embedded SQL Statements (v8) - 2 of 3
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 49/147
49 © 2013 IBM Cor oration
Working with Embedded SQL Statements (v8) 2 of 3
From RDz, click back to the Data Perspective
If you still have your other SQL Script page open, select and delete the existingstatement, then Paste in the copied SQL cursor code
Right-click and Run the SQL Statement and view results
Note: As you did with the sample table contents, you
can Right-click over the result rows, and Export the result
data for data compare, reporting, etc.. This can be useful
during DB2 application testing/debugging.
Working with Embedded SQL Statements (v8)– 3 of 3 (Host Variable Values)
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 50/147
50 © 2013 IBM Cor oration
Most of the SQLstatements embedded inyour COBOL and PL/I
programs will have host-variables
In order to test suchstatements, you can:
"Stub the host variablesout" – replacing the SQLstatement operands withliterals
Use the Host VariableValues wizard (seedisclaimer for COBOL) –
Specifying the Host
Variable values asshown on the right
Working with Embedded SQL Statements (v8) 3 of 3 (Host Variable Values)
Disclaimer for COBOL Host Variable Values- Host Variables with a dash in their name are notsupported by the wizard.
Example: :PERF-RATING
Qualified Host Variables such as: :DCL.PERF are supported.
PL/I Variables (separated by under-scores) are also
supported
Working with Embedded SQL Statements (v9)
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 51/147
51 © 2013 IBM Cor oration
Working with Embedded SQL Statements (v9)
RDz v9 integrated with IBM Data Studio 4.1 provides many high-quality data management andespecially SQL statement development/test options.
The next section of this course provides detailed steps and guidelines for configuring and
using the options and functionality
Looking up SQLCODE Values
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 52/147
52 © 2013 IBM Cor oration
Looking up SQLCODE Values
RDz provides a view (called the “Lookup view” which allows you to learn more about SQLCODE values
Display the view from:
Window > Show View - type: l o o k Select Lookup, and click: OK
…this opens the Lookup view
Type a SQLCODE into the Search area and press Enter or click the Lookup button
Double-click the Results value
Review – "How do I" (Using RDz, be sure you know how to do the following…)
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 53/147
53 © 2013 IBM Cor oration
Review How do I (Using RDz, be sure you know how to do the following…)
Access the data tools in the RDz Workbench (how do you open the Data Perspective)?
Create a connection to a DB2 region?
Filter out Schemas you don't want to see in the Data Source Explorer?
View sample rows from a table, view or synonym?
Edit a DB2 table?
Save changes to my row/column edits?
List indexes for a DB2 table
Generate the table definition (DDL) for a DB2 table or view?
View the different values in a DB2 table column, and see the number of rows each value has in the table?
Understand the relationships among a set of DB2 tables – connected with Primary/Foreign key constraints?
i.e. Create an "Entity-Relationship Diagram"
List the primary or foreign key (constraints) for a DB2 table?
Understand how an index on a table is designed (to see if it will help make my SQL query faster)?
List the columns in a table or view?
Change the default maximum number of rows displayed or edited in a table?
Code a dynamic SQL statement?
Invoke (use) Content Assist to help you code a SQL statement (what two keys??)
Run a SQL statement?
Code and test (run) multiple SQL statements in one batch (like SPUFI)?
Perform (relative) SQL statement efficiency benchmarks?
Export rows from SQL results to a: web page, XML file, Excel spreadsheet?
"Explain" the plan DB2 will use to access the table?
Understand more about an SQLCODE
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 54/147
54 © 2013 IBM Cor oration
UNIT
Topics:
The RDz Workbench
The Data Perspective and connecting to DB2
Understanding your DB2 objects Editing and managing DB2 table data
Coding and testing SQL
The V9 Data Studio + RDz Features
Workshops and Appendices
RDz Version 9 DB2 Tools – With Data Studio 4.1
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 55/147
55 © 2013 IBM Cor oration
RDz Version 9 DB2 Tools With Data Studio 4.1
In Version 9 of RDz IBM provided a number of new SQL/DB2 feature/benefits. Including, but notlimited to:
Ability to select an EXEC SQL statement and Run the SQL
Ability to select an EXEC SQL statement and Tune the query
Populate a SQL Outline view - a feature of Data Studio - with the SQL statements from the COBOL orPLI program that the user is editing - and thus make available all the menu items to Run, Tune, VisualExplain etc. from the SQL Outline view
In order to access this extended SQL development functionality you mustinstall IBM Data Studio 4.1 so that it “shell shares” with RDz
Installation Pre-requisites
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 56/147
56 © 2013 IBM Cor oration
q
RDz v9 and IBM Data Studio 4.1 take advantage of “shell sharing” (essentiallymultiple-product integration by installing certain features into the same directory) toprovide much richer integration between the product capabilities and thus enhance
the overall developer productivity and experience. The first prerequisite to obtaining these features is to install RDz v9 and Data Studio
into the same “SDPSHARE” Package
Installation manager will show you what packages are installed together into the SDPSHAREdirectories
Here you can see that the following products are installed into a single package
CICS Explorer
Data Studio Client
DB2 Analytics
RDz v9
Setting up for Integrated DB2/SQL Functionality
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 57/147
57 © 2013 IBM Cor oration
g p g Q y
You will connect to DB2 from the Data Perspective – and Data Source Explorer the same way
However, you must specify a Default schema
Filtering Schemas and Tables – v9 + Data Studio
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 58/147
58 © 2013 IBM Cor oration
g
Using Data Studio you will be prompted for aPhysical data model
Click Next > without specifying anything
In V9 after un-checking Disable filter, specify your initialSchema filter from the Expression … Not Selection option
Configuring RDz v9 For Enhanced DB2/SQL Functionality With Data Studio - Steps
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 59/147
59 © 2013 IBM Cor oration
g g y
Once you have successfully Connected to DB2 you willreturn to the z/OS Projects Perspective andperform the following steps
1.Define an MVS Subproject**2.Add a COBOL or PL/I program with embedded SQL into the Subproject
3.Add Data Access Development Support to the Subproject
4.Work with the enhanced DB2/SQL tooling:
Run SQL statements directly from within source editing
Tune SQL statements from within edit
Open and work with an SQL Outline View – which provides you with Context
Menu access to: – Visual Explain
– Various table operations
– Filtering SQL statements**MVS Subprojects are covered in-depth in an upcoming course module. However they are introduced herein order to facilitate enhanced DB2/SQL work. And in order to define an MVS Subproject, you must have defineda connection to your mainframe and logged in through Remote Systems, and defined a default Property Group.These topics will also be covered in an upcoming course module.
Note that defining a connection and an MVS Subproject is a one-time-task. The steps on the nextpages will not need to be repeated each time you want to work with embedded DB2/SQL codes
Define a Connection to your Mainframe Through Remote Systems
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 60/147
60 © 2013 IBM Cor oration
From Remote Systems: Expand New Connection and select z/OS…
Enter the Host name for your LPAR (zserveros.demos.ibm.com is what you can use inclass if you are not using your own mainframe)
Specify a Connection name
Press Next >
For both z/OS Unix and MVS Files you will need to specify a Port number. This allows Remote Systemsto interact with your workstation.
The port for zserveros is: 4035.
This port must be available through your firewall
Login to Your Connection Through Remote Systems
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 61/147
61 © 2013 IBM Cor oration
From your named-new Connection:
Right-click and select Connect
Specify your TSO credentials:
User ID (TSO ID) and PasswordOptionally save the user ID and password so that
you don‟t have re-enter them and click: OK
If everything‟s working, you can expand My Data Sets to seethe files you have allocated to your TSO ID
Define a Default Property Group – 1 of 2
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 62/147
62 © 2013 IBM Cor oration
Once you are connected, from theProperty Group Manager view:
Right-click over your named connection
Select: New Property Group…
From SYSLIB: Specify the name(s) ofany copybook/DCLGEN libraries yourprograms reference.
Note that for this module, if you‟reusing the course
programs/copybooks you only need
to specify: <HLQ>.TEST.COPYLIB
Press Ctrl+S to save your work
Close the Property-Group editor
Property Group settings provide RDz with configuration information, such
as destination libraries/SYSLIB concatenation for finding copybooks
Define a Default Property Group – 2 of 21.
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 63/147
63 © 2013 IBM Cor oration
Finally – you associate your newProperty Group with the MVS Files youwill be accessing through RDz
From Remote Systems
Right-click over MVS Files
Select Property Group >
Associate Property Group…
Click OK
2.
3.4.
Define an MVS Subproject
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 64/147
64 © 2013 IBM Cor oration
From the z/OS Projects Perspective
Right-click inside the z/OS Projects view and select:
New > z/OS Project…
Name the z/OS Project
From MVS Subproject Name and Location
Select a Connection name
Name the MVS Subproject
Check the Property Group to associate
with the MVS Subproject
Click Finish
At the prompt to Add Resources tothe Subproject click Cancel
Add DB2 Programs to Your MVS Subproject
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 65/147
65 © 2013 IBM Cor oration
From Remote Systems:
Expand My Datasets
Scroll and or Page… down through alibrary that contains DB2 programs
Right-click over the program and addit to your MVS Subproject
Note that the program CURSRAVG is
a DB2/COBOL program.
If this program is not currently in a
.COBOL library drag and drop the
program from RDzClass >cobol to
a PDS in Remote Systems
Add Data Access Development to Your MVS Subproject – 1 of 2
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 66/147
66 © 2013 IBM Cor oration
Adding the Data Access development support results in the association ofan MVS Subproject and its source files with the database connection you
just created:
From z/OS Projects:Right-click over your MVS Subproject
Select Add Data Access Development Support
If Add Data Access DevelopmentSupport does not appear in the Context
Menu more than likely: You are not using RDz version 9
… or …
IBM Data Studio 4.1 is not installed… or …
IBM Data Studio 4.1 is not shell-sharing with RDz v9
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 67/147
Work with the Advanced DB2/SQL Tooling – Open your DB2 Program
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 68/147
68 © 2013 IBM Cor oration
From your MVS Subproject:
Double-click over your program to open it in the Editor
Note that you can use either:
System z LPEX Editor
COBOL Editor
… the DB2/SQL tooling is enabled in both editors
From here on, any COBOL or PLI source being edited in the RDz editors will have additionalmenu items enabled when an EXEC SQL statement is selected
Work with the Advanced DB2/SQL Tooling – Access Embedded SQL
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 69/147
69 © 2013 IBM Cor oration
From inside your source editing session:
Access your SQL – by:
Scrolling
Find commands
Filter view
Note that you don’t have to be in Filter view mode to accessthe tooling. But you might want to be.
Work with the Advanced DB2/SQL Tooling – Select and Run SQL
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 70/147
70 © 2013 IBM Cor oration
Select an SQL statement within an edit session for SQL access:
From EXEC SQL END-EXEC inclusive – see screen capture below
Right-click and you should see three new SQL options:1. Tune SQL – using OPTIM Query Tuner**
2. Run SQL – execute the SQL statement you‟ve selected
3. Refresh SQL in Outline View – open/refresh SQL tooling in a view specific to SQL
If you are not already logged in to your DB2 connection you will be prompted
** OPTIM Query Tuner does not install with IBM Data Studio client 4.1
It‟s a separately priced host/DB2 package
Select and Run SQL – SQL Results view
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 71/147
71 © 2013 IBM Cor oration
After running a statement, the SQL Results view will open, and you may goto the statement result and work with it:
Same techniques as when you code/test interactive SQL:
Export to different media
RE-Sort the rows
– And then export, etc.
Work with the Advanced DB2/SQL Tooling – Statements With :Host-Variables
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 72/147
72 © 2013 IBM Cor oration
You can modify and re-run your SQL statements directly in the editor:
You will be prompted for:
DB2 column data type: Only because you‟re editing the SQL (inline)
If your statements already contain
Host Variables the tooling will figure out
the type dynamically
Host variable value
Work with the Advanced DB2/SQL Tooling – Refresh SQL in Outline View
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 73/147
73 © 2013 IBM Cor oration
From the Context menu:
Select: Refresh SQL in Outline View
This opens a new View showing:
SCHEMA:Tables within the Schema
SQL referencing the tables
Source: An Outline View of all theSQL statements in your program
Work with the Advanced DB2/SQL Tooling – Schemas Tab Options
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 74/147
74 © 2013 IBM Cor oration
From the Schemas tab, you can: Locate the statement in your program
Run the SQL
Open the Interactive SQL Editor with thestatement copied into it
Provides access to the graphical SQL Editor
– Right-click inside of the Interactive SQL Editor
and select: Open with SQL Query Builder
Export the SQL statement to anexternal/local file on your workstation
Retrieve pre-existing EXPLAIN informationfrom the Plan Table(s)
Launch a Visual Explain on the statement
Launch OPTIM Query Tuner for thestatement
Requires separately priced host product
installation
Generate and Find pureQuery Code
Show the SQL in table format
Filter the SQL
Allows you to Filter on: – SQL statement types
– (a single) DB2 Object name
– Using Regular Expressions to search
Show the Explain or Query Tuner
performance information
http://en.wikipedia.org/wiki/IBM_PureQuery
Work with the Advanced DB2/SQL Tooling – Visual Explain – 1 of 2
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 75/147
75 © 2013 IBM Cor oration
From your SQL Outline View:
Right-click over the SQL statement youwant to Explain
Select Open Visual Explain Two Explain Data dialogs will pop-up allowing
you to specify Plan_Table configuration/over-rides.
Note that you must have DB2 EXPLAIN Authorization and may need CREATE Table Authorization to build the Plan Tables.
1.
2.
3.
Work with the Advanced DB2/SQL Tooling – Visual Explain – 2 of 2
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 76/147
76 © 2013 IBM Cor oration
WhenVisualExplainfinishes,you‟llprobablywant togo full-screen.
In orderto see…
Different Query stages in the
Visual Explain diagram
Pop-up DB2 Optimizerestimates/meta-data
The potential for (expensive)Stage 2 predicates in the Access
Path Plan (note that this joincondition is a Stage 1 predicate)
Cost estimates for the query and
individual query phases
Work with the Advanced DB2/SQL Tooling – Find (Table) in the Data Source Explorer
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 77/147
77 © 2013 IBM Cor oration
Given the sheer number of DB2 tables you have to work with, it can betime-consuming to navigate to the table you‟re looking for – for any numberof reasons:
Need to see Sample data for a :Host-Variable valueNeed to edit the table/modify a row, etc.
The SQL Outline view makes this extremely easy:
Right-click over the Table
And select: Find in Data Source Explorer
This opens the Data Source Explorer – with your Table selected
1.2.
Recommendation – Reposition the Data Source Explorer in z/OS Projects
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 78/147
78 © 2013 IBM Cor oration
Once you‟ve accessed the Data Source Explorer you might want to drag it tothe bottom-left hand corner, where you‟re used to seeing and using it
|
Work with the Advanced DB2/SQL Tooling – Working With Additional Programs
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 79/147
79 © 2013 IBM Cor oration
1. Add other COBOL/DB2 programsto the MVS Subproject.
2. Open another program in the Editor
3. Refresh SQL in the Outline view
4. Note the updated Schemas list – expanded to include tables andSQL from all combined programs
1.2.
3.
4.
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 80/147
Work with the Advanced DB2/SQL Tooling – Table and Statement Filters – 2 of 2
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 81/147
81 © 2013 IBM Cor oration
Note: The EMPL table is showing above becausethis SQL statement joins EMPL with PAY
Text Filters are written with JavaRegular Expression syntax
Tune SQL – Using Optim Query Workload Tuner – 1 of 8
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 82/147
82 © 2013 IBM Cor oration
If your shop has Optim Query Workload Tuner** installed, you can tune an SQL statement:
From the Context Menu within edit on the code
From the:
Outline View
Context menu on a statement
**For information on Optim Query Workload Tuner:
http://www-03.ibm.com/software/products/us/en/optiquerworktunefordb2forzos/
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 83/147
Tune SQL – Using Optim Query Workload Tuner – 3 of 8
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 84/147
84 © 2013 IBM Cor oration
The tuning can take around a minute or so depending on many factors.
When it comes back, you will be prompted for the various Access Path reports you‟dlike Optim to produce.
I usually select all three
And show in HTML format
T a b b e d s t e p s i n t h e Q
u e r y T u n i n g P r o c e s s a n d R
e s u l t s
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 85/147
Tune SQL – Using Optim Query Workload Tuner – 5 of 8
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 86/147
86 © 2013 IBM Cor oration
Optim will format your query – and describe various DB2 Access Path statistics
Tune SQL – Using Optim Query Workload Tuner – 6 of 8
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 87/147
87 © 2013 IBM Cor oration
Visual Explain is available – and access to the Explain Plan_Table data
Tune SQL – Using Optim Query Workload Tuner – 7 of 8
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 88/147
88 © 2013 IBM Cor oration
There are numerous cost estimating reports
These are specific to the environment in which the query workload was run:
I.E. – production DB2 subsystems are usually different from test, and thus cost estimates
will differ
Tune SQL – Using Optim Query Workload Tuner – 8 of 8
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 89/147
89 © 2013 IBM Cor oration
The Summary Report is a detailed list of recommended actions for indexing, query re-writing,and other tuning approaches. It is well worth a look – although the information is technical
Tune SQL – Using Optim Query Workload Tuner - Summary
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 90/147
90 © 2013 IBM Cor oration
If Optim Query Workload Tuner is installed on your mainframe, you should try tuninga query during class from the RDz v9/IBM Data Studio 4.1 tooling.
You may need authorization or assistance from your DBA to run the Tuning Report
And DBAs will make the best use of the tuning information – as the reports are deepand highly technical – as they should be for this sort of product functionality.
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 91/147
®
IBM Software Group
© 2013 IBM CorporationLast Update: November, 2013
RDz Workbench – Using the Data Source Explorer
Workshops
Data Perspective Workshop – Using Your Company's DB2
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 92/147
92 © 2013 IBM Cor oration
If you are connecting to DB2 on your own LPAR, with the help of your DBA and/orSystems Programming staff do the following:
1. Open the Data Perspective
2. Connect to a z/OS DB2 database3. Filter the Schema to your table Owner name
4. Use the Data Source Explorer:
1. View some of the tables and their relationships through the Overview
Diagram
2. Show a table‟s Sample Contents
3. Code a few simple SQL statements (or copy/paste from a COBOL program)
and run them in a SQL Query
4. Create a simple new SQL statement using the statement builder
5. Edit one of the DB2 tables you have update access to:
– Add a few new rows - Update some values - Delete one or two rows
– Save your changes – Ctrl/S
The slides that follow provide good examples to exercise the techniquesdemonstrated in this section. Of course you will have to use your owntables, views, etc.
Data Perspective Workshop – Using Your Company's DB2 – IBM Data Studio – RDz v9
If i RD 9 h ll h i ith IBM D t St di 4 1 t t lid
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 93/147
93 © 2013 IBM Cor oration
If you are using RDz v9 shell-sharing with IBM Data Studio 4.1 – return to slides58 94 in this slide deck and:
1. Create connections – to DB2 and through Remote Systems Explorer (RSE)
2. Create a Property Group for the RSE connection to pick up your copybooks andDCLGEN includes
3. Create an MVS Subproject – and copy a few DB2/COBOL programs into theSubproject
4. Add Data Access Development Support to the Subproject
5. Open a DB2/COBOL program – and start following the use cases shown on
slides: 72
84 in this slide deck, but using your own SQL statements/DB2tables and views, etc.
Note that you may need your DBA‟s assistance for doing things like creatingthe EXPLAIN/Plan Tables, etc.
6. If you have Optim Workload Query Tuner:
And start following the use cases shown on slides: 85
93 in this slide
deck, but using one of your own SQL statements
Note that you may need your DBA‟s assistance – especially for interpretingthe Query Tuning reports, graphs and explorer
You may already have setup connections for DB2 and to your mainframe through RSE – and
created an MVS Subproject.
Workshop – Connecting to DB2 on zServerOS
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 94/147
94 © 2013 IBM Cor oration
For z/OS-DB2 you will need to provide a few different pieces of information,in order to connect:
Select: DB2 for z/OS as the database managerLocation:
EOSDB205
Host:
zserveros.demos.ibm.com
Port: 5446User name/Password:
Your assigned UID/PWD
Example:
RTPOTnn
<password>
Click Next >
Workshop – Filtering Schemas and Tables
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 95/147
95 © 2013 IBM Cor oration
Recall:
In the DB2 world on z/OSdatabases could easily
contain: Tens of thousands of tables
Thousands of Schemas
To simplify working on yourprojects filter the availableDB2 objects
Un-check: □ Disable Filter
Enter: DDS0001
In: ◙ Expression name
Data Perspective Workshop – Data Source Explorer
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 96/147
96 © 2013 IBM Cor oration
When your connection create process finishes, you will be returned to the DataPerspective, where you now can:
Expand:
Schemas – Synonyms
– Tables
– Table elements
– Views
Explore and with the DB2 objects: Expand RESULTS
– Look at the various elements
Expand
Workshop – Data (Entity/Relationship) Analysis
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 97/147
97 © 2013 IBM Cor oration
Next try the "Overview Diagram"
Select one or more tables
Right click and select: Add to Overview Diagram
Click OK
This opens an Entity/Relationship analysis view
You can also work with a Table, View or Synonym's DDL: Try the following with the CUST table:
1. Extract table data to a comma delimited file on your workstation
2. Generate the DDL for your table
Be sure to:
Browse and select one of your chapter folders
Check the option to
Open the DDL file for editing
Workshop – View, Analyze, Export Data – v8.x
To view your DB2 table data and export reports from it:
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 98/147
98 © 2013 IBM Cor oration
To view your DB2 table data and export reports from it: Select the table or view you wish to edit. Right click and select: Data > Sample Contents
Sortyourresults
Export yourresults
Workshop – Read/Only View of a Table's Row Values – v9 From the Data Source Explorer Right click over CUST and
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 99/147
99 © 2013 IBM Cor oration
From the Data Source Explorer, Right-click over CUST and Browse the Data and Sample Contents
Try out: New “Select” Script
Press <F5> to run the Select script
Value Distributions > Multivariate
Repeat these steps with one or two other tables
Caution about the Browse Data and Sample Contents These options ignore thePreferences setting for maximum number of rows to return from DB2, and on a very large table will causeWorkbench performance problems
Workshop Edit Tables
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 100/147
100 © 2013 IBM Cor oration
To edit your DB2 table data: Select the table or view you wish to edit
Right click and select: Data > Edit
Note that you can open (edit) multiple tables. And project them out in multiple window views – so that you can analyze data, or copy/paste values from one table to another
If you wish to editsubsets of large tablesyou can use the Optim
Data Studio 3.1.1 – which
is a free RDz plug-in
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 101/147
Workshop – Testing Interactive SQL Statements
Cli k N SQL S i t
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 102/147
102 © 2013 IBM Cor oration
Click New SQL Script
Type in SQL statements
Right-click over the
Content Area andselect: Run SQL
In the Results, formultiple statements youcan expand and selectone at a time
The Result1 tab shows
statement resultsYou can Export results
Optional Copy and all of the commented
SQL statements in the SlideNotes
Try other Context Menuselections like Format SQL
Statement Run Console Data Results
Workshop – Testing Embedded SQL Statements v8 – 1 of 2
F th R t S t i
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 103/147
103 © 2013 IBM Cor oration
From the Remote Systems view:Open <HLQ>.TEST.COBOL(CURSRAVG)
Right-click and from the Context menu select: Filter view > Embedded SQL/CICS/DLI
Select and Copy the Interactive portion of the SQL SELECT statement in this paragraph – minus all of the embedded COBOL syntax (shown below in the screen capture)
Workshop – Testing Embedded SQL Statements v8 – 2 of 2
S b k t th i t dit d t th i d b dd d SQL i id
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 104/147
104 © 2013 IBM Cor oration
Swap back to the script editor and paste the copied embedded SQL insidethe SQL script editing area
Right-click and select Run SQL
Try adding an additional where clause predicate
What happens when you run the query?
Workshop – Testing Embedded SQL Statements v9
If you are using RDz v9 shell-sharing with IBM Data Studio 4 1 – return to slides
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 105/147
105 © 2013 IBM Cor oration
If you are using RDz v9 shell sharing with IBM Data Studio 4.1 return to slides57 93 in this slide deck and:1. Create connections – to DB2 and through Remote Systems Explorer (RSE)
2. Create a Property Group for the RSE connection to pick up your copybooks and DCLGENincludes
3. Create an MVS Subproject – and copy a few DB2/COBOL programs into the Subproject – from the COBOL programs you copied to the host from RDzClass:
CURSRAVG.cbl
TRTMNT.cbl
CADDDB2.cbl
4. Add Data Access Development Support to the Subproject5. Open a DB2/COBOL program – and start following the use cases shown on slides:
72 84 in this slide deck, but using your own SQL statements/DB2 tables and views, etc.
Note that you may need your DBA‟s assistance for doing things like creating theEXPLAIN/Plan Tables, etc.
6. You can use IBM‟s Optim Workload Query Tuner – which is installed on the zserveros:
And start following the use cases shown on slides: 85
93 in this slide deck Use the SQL statement
Workshop – Testing Embedded SQL Statements v9 with IBM Data Studio 4.1
Open to slide 57 in this PowerPoint
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 106/147
106 © 2013 IBM Cor oration
Open to slide 57 in this PowerPoint.
Follow the slide instructions/screen captures and do the following:1. Create connections – to DB2 and through Remote Systems Explorer (RSE)
2. Create a Property Group for the RSE connection to pick up your copybooks and DCLGENincludes
3. Create an MVS Subproject – and copy a few DB2/COBOL programs into the Subproject – from the COBOL programs you copied to the host from RDzClass:
CURSRAVG.cbl, TRTMNT.cbl, CADDDB2.cbl
4. Add Data Access Development Support to the Subproject
5. Open a DB2/COBOL program – and start following the use cases shown on slides:72 84 in this slide deck, but using your own SQL statements/DB2 tables and views, etc.
Note that you may need your DBA‟s assistance for doing things like creating theEXPLAIN/Plan Tables, etc.
6. If you are using the zserveros you can use IBM‟s Optim Workload Query Tuner:
Start following the use cases shown on slides: 85 93 in this slide deck
Tune the SQL statement From: CURSRAVG.cbl
Review – "How do I" (Using RDz, be sure you know how to do the following…)
Access the data tools in the RDz Workbench (how do you open the Data Perspective)?
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 107/147
107 © 2013 IBM Cor oration
Access the data tools in the RDz Workbench (how do you open the Data Perspective)?
Create a connection to a DB2 region?
Filter out Schemas you don't want to see in the Data Source Explorer?
View sample rows from a table, view or synonym?
Edit a DB2 table?
Save changes to my row/column edits?
List indexes for a DB2 table
Generate the table definition (DDL) for a DB2 table or view?
View the different values in a DB2 table column, and see the number of rows each value has in the table?
Understand the relationships among a set of DB2 tables – connected with Primary/Foreign key constraints?
i.e. Create an "Entity-Relationship Diagram"
List the primary or foreign key (constraints) for a DB2 table?
Understand how an index on a table is designed (to see if it will help make my SQL query faster)?
List the columns in a table or view?
Change the default maximum number of rows displayed or edited in a table?
Code a dynamic SQL statement?
Invoke (use) Content Assist to help you code a SQL statement (what two keys??)
Run a SQL statement? Code and test (run) multiple SQL statements in one batch (like SPUFI)?
Perform (relative) SQL statement efficiency benchmarks?
Export rows from SQL results to a: web page, XML file, Excel spreadsheet?
"Explain" the plan DB2 will use to access the table?
DCLGEN a table?
Now that you have completed this topic you should be able to:
Topic Summary
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 108/147
108 © 2013 IBM Cor oration
Now that you have completed this topic, you should be able to:
Launch the Data Perspective
Connect to a Data SourceUse the Data Source Explorer to:
View tables and relationships
View sample table rows and values
Edit (create, update, delete) row values
Test interactive SQL
Code/Build SQL statements
Generate Table DDL
Summary
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 109/147
DCLGEN – 1 of 4
DCLGEN Allows you to create copybooks from
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 110/147
110 © 2013 IBM Cor oration
DCLGEN – Allows you to create copybooks fromtable schemas for: COBOL, PL/I, C, and Java
Steps – from the Data Perspective:
Highlight the table you want
Right-click and select: DCLGEN
Using the DCLGEN wizard
Connect to the host System
1. Specify the name of your DB2 subsystem2. Customize the JCL JOB Card. Add //JOBLIB
DD card – referencing your shop's DB2 load library)
3. Click: Next >
You will need to connect:To your mainframe
To your database
DCLGEN – 2 of 4
Select:
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 111/147
111 © 2013 IBM Cor oration
Select:
Language
Browse to selectyour DCLGENoutput PDS
Rename the PDSmember
Click Next >
Customize the DCLGEN-specific options
Note that at minimum, you will have tochange the Member and Data structure name ifyour table name contains an underscore
Click Finish
See Slide Notes
DCLGEN – 3 of 4
The wizard will submit a job which you
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 112/147
112 © 2013 IBM Cor oration
The wizard will submit a job, which youcan track in the:
z/OS Projects Perspective
JES facility
DCLGEN – 4 of 4
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 113/147
113 © 2013 IBM Cor oration
From Remote
Systems exploreryou can also openthe PDS and look
at your DCLGEN'dsource
Optional Topic - Exploring Meta Data
By selecting meta-data elements and then selecting the Properties view you
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 114/147
114 © 2013 IBM Cor oration
By selecting meta-data elements and then selecting the Properties view youcan see
Examples:
The Properties/Details of an index design
The Properties/Details of a Foreign Key relationship between two tables
Optional Topic – Working with/Understanding DB2 Views
By selecting the DB2 View and then selecting the Properties view you get:
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 115/147
115 © 2013 IBM Cor oration
By selecting the DB2 View and then selecting the Properties view you get:
Dependencies:
You can see the SQL that was used to create the View (DDL)
And most of the Data featureswork with Views
Filtering/Re-Filtering The Data Source Explorer
You can filter Schemas when you create your
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 116/147
116 © 2013 IBM Cor oration
You can filter Schemas when you create yourconnection to DB2. But you can change or re-filteryour DB2 objects dynamically (at any time)
To re-filter your data objects:
Select the connection
Right-click and select Properties
From Properties you can re-filter:
Schema namesStored Procedures
Tables
Steps:
Select the filter Un-check Disable filter
Specify your new filter
Click OK
(Data Model) Overview Diagram – (Optional Context Menu Features)
If you are a database administrator (acting database administrator for your local copy of a database) or datamodeler/data analyst you might be interested in other context menu options:
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 117/147
117 © 2013 IBM Cor oration
modeler/data analyst you might be interested in other context menu options:
Enhance your data module with the Diagram Tool:
Right-click over the RESULTS entity
Select:
Add note
Type text into the edit area
When finished,
– Click the diagram again with your mouse
– You can delete the note by selecting it
– Right-click and select Delete
Other context menu options of interest:
Right click over the white space (not over an entity)
Zoom
– In or out to scale
File
– Save image
(Data Model) Overview Diagram (Properties View)
Another usefulOverview Diagram
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 118/147
118 © 2013 IBM Cor oration
Overview Diagramfeature is:
ShowProperties
View
– which displaysmeta data for :
Tables
Relationships(click the lines drawnbetween the entities)
Views
Optional - DBA and SQL Programmer/Analyst Feature – Analyze Impact
For tables with DB2-enabled "Referential Integrity"
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 119/147
119 © 2013 IBM Cor oration
For tables with DB2 enabled Referential Integrity
Select a table (either parent or child table)
Note that the table should have constraints
Right-click and select: Analyze Impact…
Select the type of impact analysis to perform
Only children objects
Only parent objects
Both children/parent objectsClick OK
Read the Model report produced
Dependent Object is the "child" table or view that will be impacted
"Impactor Object" is the parent table or view (of what has been analyzed)
DBA and SQL Programmer/Analyst Feature – DB2 Object Compare
Detailed comparison tool for analyzing
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 120/147
120 © 2013 IBM Cor oration
p y gdifferences between tables, views, etc.
Side-by-side graphical results – from DB2System Catalog
Can span multiple connections – I.E. Compare atable in Test with one in Production
Optional - SQL Results View
Additional options exist to Re-sort, save and reuse the results set:
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 121/147
121 © 2013 IBM Cor oration
p Re-sort the result rows from a query, Sample Data, etc.
Other result row options
Right-click over the rows in the SQL Results view (and/or press the Shiftkey and select multiple rows)
You can:
Copy rows and Paste specific results rows into Notepad file
Export results rows (next slide)
Save results rows Convert Hexadecimal
– Note that this options shows:
– ASCII hex characters for CHAR and VARCHAR data
– Actual binary value - for INT, SMALLINT data
Using Update-able Views to Edit Subsets of Large Tables – 1 of 2
One of the current limitations of the RDz table editor is that – for very large
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 122/147
122 © 2013 IBM Cor oration
y gtables (100's of columns, 100's of 1,000's of rows) you cannot filter table data
One solution for this is to create a view that renders the rows you want to
modify, and edit through the view (note that this is limited to version 8.0 and later)
Considerations:
You must have CREATE VIEW privileges
Or optionally, you can ask your DBA or the table "owner" to run a CREATE VIEW for
you, if you don't
You must create an update-able view.
An update-able view is a row-column subset of one table. The statement must not:
– Reference more than one table in the FROM clause, in a sub-select or UNION with other tables
– Contain GROUP BY or HAVING clause or DISTINCT in the selection list.
– Reference a non-updateable view
– Contain an SQL "expression" (functions, computations, etc.) Here's a sample Create View statement that creates a row/column subset of
the DDS0001.CUST table:
Create View Cust_View_CT as
Select ID, LNAME, ST From DDS0001.Cust Where ST = 'CT'
Using Update-able Views to Edit Subsets of Large Tables – 2 of 2
Steps – including screen captures:
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 123/147
123 © 2013 IBM Cor oration
1. Create an updatable view
2. Edit (through) the view:
3. Make changes
4. Save your edits
Ctrl+S
Unload (Extract) Rows from a Table
You also might wish to unload (extract) test data rows before modifying a table's DDL, either forback-up purposes or to share among team members or re-load later
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 124/147
124 © 2013 IBM Cor oration
back-up purposes or to share among team members or re-load later.
From the Data Source Explorer: Right-click over the table name
Select: Data >
Extract…
Specify data extract (unload) options:
Output file-spec
Column delimiter type
Char-string delimiter type
To reload select: Load…
and follow script in reverse
Combining SQL and Extract/Load to Edit Values in Large Tables – 1 of 3
If your DB2 table is too large to edit directly, you can use the following
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 125/147
125 © 2013 IBM Cor oration
y g y y gtechnique to modify row values:
Run a SQL Script
to create a Result setthat you wish to useas the basis for yourediting and new values
Export the Results: Plain Text (*.txt)
Comma Separated
Combining SQL and Extract/Load to Edit Values in Large Tables – 2 of 3
Edit the text file produced
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 126/147
126 © 2013 IBM Cor oration
p
Notepad works
Don't use any editor that adds special characters
Delete the column names header
Your new values will have to pass all of thestandard DB2 (relational) data integrity checks:
Data type
Length and max value (for numeric columns)Primary key uniqueness
Foreign key (referential integrity) checks
Save your work
From the Data Source Explorer
Select your table
Right-click and select:
Data > Load…
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 127/147
Support for "Current SQLID"
You can SET the CURRENT SQLID (just as you do on QMF/SPUFI) in order to runSQL t t t ith lifi d t bl / i
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 128/147
128 © 2013 IBM Cor oration
SQL statements with unqualified table/view names.
Writing SQL Against any DB2 Connection
Data Source Explorer also has the New SQL Script functionality as an icon on the toolbar
From the Data Source Explorer
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 129/147
129 © 2013 IBM Cor oration
From the Data Source Explorer
Click the New SQL Script icon
Choose a Database connection
Note that this is the difference from the prior slide – that you can choose a connection
Using Content Assist – create your statement one SQL element at a time
Some SQL syntax errors are flagged dynamically
SQL Statement GUI-Development
An alternative to SQL statementd l t i C t t A i t i t
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 130/147
130 © 2013 IBM Cor oration
development using Content Assist is touse a Data Development Project, whichenables you to do graphical SQL
developmentThis can be a useful feature if some of
your development staff are new to SQL
Steps:
From the Data Project Explorer
Right-click and select:
New > Data Development Project
Name the Project
Select a Connection
Click: Finish
SQL Statement GUI-Development – continued
From the Explorer:
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 131/147
131 © 2013 IBM Cor oration
Right-click over SQL Script and select:
New > SQL or XQuery script
Name the script Select the Statement type
This will open a new SQL editor
Select SQL Query Builder
Note – Other statement types include: Insert
Update
Delete
FULLSELECT (Union / Union All)
WITH (Statements built using temporarytables)
SQL Statement GUI-Development – continued
Using the editor you can follow the prompts andl t t t SQL t t t hi ll
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 132/147
132 © 2013 IBM Cor oration
layout to create SQL statements graphically
Add a new table
From the list of columns select one or more
columns to add
SQL Statement GUI-Development – continued
From the Conditions tab, add aWHERE l
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 133/147
133 © 2013 IBM Cor oration
WHERE clause
Note that you can:Select a column, Operator, Value,
AND/OR from a drop-down list box
Or you can type the statement
portions (and the graphical view will
synchronize)
Right-click over the statement
and select Run SQL to test
Note that you will definitely haveto understand SQL to use this tool
Graphical SQL Script Builder – Joining Tables
A terrific use of the GUI SQL-builder is in creating statements that join tables.By adding more than one table the tool will create the SELECT and FROM clauses
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 134/147
134 © 2013 IBM Cor oration
By adding more than one table, the tool will create the SELECT and FROM clauses.By selecting: Create Join… you can specify the Where clause aka: "Join Condition"
Note the graphicalrendering of the joinsas connections
between the tables
Graphical SQL Script Builder – Reverse Engineering SQL Statements to Graphics
Just as the SQL Script Builder will generate SQL out of your GUI buildingprocess for certain SELECT and INSERT statements it ill also sho
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 135/147
135 © 2013 IBM Cor oration
process, for certain SELECT and INSERT statements it will also showelements of your statements graphically, if you start with the SQL
Steps:
1. Create a new statement
2. Type in your statement
3. Click inside the GUI areas
Your statement is displayed graphically
RDz will show different GUIelements, as you type
This works best with:
SELECT
INSERT
Optional Topic – Using DB2 Explain
Provided that you haverights to access a
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 136/147
136 © 2013 IBM Cor oration
rights to access aPLAN_TABLE, you canuse the Data Tools toexecute traditional DB2Explain statements
Notes: Plan_Tables are DB2
version specific
There is a Visual Explainproduct from IBM thatplugs into Eclipse
Selecting Rows from the DB2 System Catalog (SYSIBM.SYSxxx) – 1 of 2
Provided you have DB2 catalog access privileges, the tables and views inthe DB2 System Catalog (SYSIBM SYSINDEXES SYSIBM SYSTABLES t ) can be
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 137/147
137 © 2013 IBM Cor oration
the DB2 System Catalog (SYSIBM.SYSINDEXES, SYSIBM.SYSTABLES, etc.) can bequeried
Links: http://www.ibm.com/developerworks/data/library/techarticle/dm-0411melnyk/
http://publib.boulder.ibm.com/infocenter/db2luw/v8/index.jsp?topic=/com.ibm.db2.udb.doc/admin/c0004932.htm
Selecting Rows from the DB2 System Catalog (SYSIBM.SYSxxx) – 2 of 2
(Again) Provided youhave DB2 catalog
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 138/147
138 © 2013 IBM Cor oration
access privileges, youcan also use the DataSource Explorer to
browse the catalogtables
Note that in order for theData Source Explorerto provide this meta-data you will need to
access the schema:SYSIBM in yourconnection
Preferences to Code SQL Statements Against the System Tables
From:
Wi d P f
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 139/147
139 © 2013 IBM Cor oration
Window > Preferences
Data Management
SQL DevelopmentSQL Editor
Code Assist
…You can customize your workspace
for easier SQL statement editingagainst the system tables
Optional Workshop 1 – Using the SQL Script Builder to Join Tables
For a review of this material see the slides in this deck with "SQL Statement – GUI Development"in the slide header
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 140/147
140 © 2013 IBM Cor oration
Workshop steps:
From the Data Project Explorer
Right-click and select: New > Data Development Project Name the Project
Select a Connection
Click: Finish
From the Explorer:
Right-click over SQL Script and select:
New > SQL or XQuery script
Name the script
Select the Statement type
This will open a new SQL editor
From the SQL query:
Add the following tables (all owned by: DDS0001): Entrants, Events, Results
Note – its' a good idea to use Table Aliases – especially in table join statements
Right-click over Entrants, and join Entrants to Results on the Entrant.Name = Results.Name Right-click over Events, and join Events to Results on the Event.Number = Results.Number
Modify the SELECT statement's SELECT clause to return specific columns
Run the statement – and review the output
Optionally:
Add an additional WHERE clause
Sort the results rows
Optional Workshop 2 – Using the Script Builder to Reverse Engineer a Statement
For a review of this material see the slides in this deck with "Reverse Engineering SQL Statementsto Graphics" in the slide header
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 141/147
141 © 2013 IBM Cor oration
p
From the Explorer:
Right-click over SQL Script and select:
New > SQL or XQuery script Name the script
Select the Statement type: SQL
This will open a new SQL editor
From the SQL query statement area
Code or paste the statement shown:
The code is in the slide notes
Check out the Reverse Engineering
Run the statement
Try coding any of your own SQL:
Joins
Complex single-table queries
The statement is in the Slide Notes
Query statement area
Optional Workshop – Accessing the System Catalog Tables
For a review of this material see the slides in this deck with"Selecting Rows from the DB2 System Catalog" in the slide header
Create a new connection to DB2:
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 142/147
142 © 2013 IBM Cor oration
Create a new connection to DB2:
Your DB2/zOS instance, or the IBM zserveros/DB2 instance
Specify the high-level Schema: SYSIBM
From the new connection, copy & paste the following statements or code SQL scripts(using content assist) to discover:
What views exist that were created by my team:
Select * from SYSIBM.SYSVIEWS where creator like 'DDS%'
What plans exist that DDS0001 can execute:
Select * from SYSIBM.SYSPLANAUTH Where GRANTEE = 'DDS0001'
The proper join condition (Primary/Foreign Key) of two DB2 tables: SELECT B.REFTBNAME AS PARENTTABLE,COLNAME FROM SYSIBM.SYSFOREIGNKEYS A, SYSIBM.SYSRELS
B WHERE A.RELNAME = B.RELNAME AND B.TBNAME = 'HOSP_BED' AND B.REFTBCREATOR = 'DDS0001'AND B.REFTBCREATOR = A.CREATOR;
What indexes exist for tables that participate in a DB2 Join:
SELECT I.NAME, I.TBNAME, K.COLNAME, K.ORDERING FROM SYSIBM.SYSINDEXES I, SYSIBM.SYSKEYS KWHERE I.TBNAME IN('WARD_DATA','HOSP_BED') AND I.NAME = K.IXNAME;
The primary key of several DB2 tables:
SELECT NAME FROMSYSIBM.SYSCOLUMNSWHERE TBNAME = 'WARD_DATA'AND TBCREATOR ='DDS0001'AND KEYSEQ > 0 ORDER BY KEYSEQ ASC
The column names and data types from two tables: WARD_DATA and EMP_DATA:
SELECT NAMEFROMSYSIBM.SYSCOLUMNSWHERE TBNAME = 'WARD_DATA'AND TBCREATOR = 'DDS0001'
Scroll down into the System tables using the Explorer – research any/all tables that look
interesting – note how easy it is to use the graphical tools for browsing the Catalog andanswering questions
Advanced Workshop – SPUFI Emulation – 1 of 5
Use the LPEX Filter feature - combined with a file of type sql to effectively test your SQLstatements from within the z/OS Projects Perspective – like you currently do with SPUFI
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 143/147
143 © 2013 IBM Cor oration
j p y y
Map your SPUFI file to a type of sqlz/OS File System Map a PDS where you have SQL statements you've used
with SPUFI to a PC file type of sql
See the slide deck titled: RDz Workbench – Using Remote Systems Explorer for
help with this
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 144/147
Advanced Workshop – SPUFI Emulation – 3 of 5
Testing embedded SQL from within the z/OS Projects Perspective
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 145/147
145 © 2013 IBM Cor oration
Advanced Workshop – SPUFI Emulation – 4 of 5
An optional exercise to use the graphical SQL development features:
Select the entire query from the sql file
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 146/147
146 © 2013 IBM Cor oration
Select the entire query from the sql file.
Right-click and select:
Edit in SQL Query Builder
Advanced Workshop – SPUFI Emulation – 5 of 5 – Dealing with Line Numbers
If you want to use aSPUFI file from themainframe and
8/10/2019 RDz Workbench Module 8 - The Data Tools – SQL Code, Test and DB2 Table Access.pdf
http://slidepdf.com/reader/full/rdz-workbench-module-8-the-data-tools-sql-code-test-and-db2-table-accesspdf 147/147
mainframe, andCOBOL Numberswere created by
TSO's file statistics,you can delete thenumbers asfollows:
1. Open the file using the LPEX Editor 2. Type NUM ON …and then: unnum on the ISPFcommand line
3. Close and saveyour changes