Implementing Practical DB2 Applications

Similar documents
Web Development with Java

Practical Usage of TSO REXX

Inside Relational Databases with Examples in Access

Stereo Scene Flow for 3D Motion Analysis

Graphics Programming in c++

DB2 UDB: Application Programming

Db2 Query Management Facility Version 12 Release 2. Installing and Managing Db2 QMF for TSO and CICS IBM GC

COMP 3400 Mainframe Administration 1

Foundations of 3D Graphics Programming

In This Issue. The Enhanced Editor in QMF 11.2: Highlights. 1st Quarter 2016 Edition

Enterprise Networks and Telephony

SymbolicC++: An Introduction to Computer Algebra using Object-Oriented Programming

Essential Series. Springer-Verlag London Ltd.

Fundamentals of Operating Systems. Fifth Edition

IBM Tivoli Decision Support for z/os Version Administration Guide and Reference IBM SH

Mainframe Developer NO.2/29, South Dhandapani St, Burkit road, T.nagar, Chennai-17. Telephone: Website:

Foreword Preface Db2 Family And Db2 For Z/Os Environment Product Overview DB2 and the On-Demand Business DB2 Universal Database DB2 Middleware and

Logic Programming with Prolog

The SQL Guide to Pervasive PSQL. Rick F. van der Lans

Db2 Query Management Facility Version 12 Release 1. Db2 QMF Reference IBM SC

DB2 UDB: App Programming - Advanced

z/os and DB2 Basics for DB2 for z/os DBA Beginners

2010/04/19 11:38. Describing a unique product that shows the mainframe in a completely different way.

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

Tivoli Decision Support for z/os. Administration. Version 1.7 SH

Chapter 1 GETTING STARTED. SYS-ED/ Computer Education Techniques, Inc.

Session: E05 DB2 Attachment Facilities. John Maenpaa Health Care Service Corporation. October 7, :00 a.m. 12:00 p.m. Platform: DB2 for z/os

APPENDIX 4 Migrating from QMF to SAS/ ASSIST Software. Each of these steps can be executed independently.

Object-Oriented Programming and Java

MASTERING COBOL PROGRAMMING

Software Development for SAP R/3

Second Generation Wavelets and Applications

Lesson 3 Transcript: Part 1 of 2 - Tools & Scripting

Contents I Introduction 1 Introduction to PL/SQL iii

Guide to the Reporting Dialog

The Internet of Things

Security Mechanisms I. Key Slide. Key Slide. Security Mechanisms III. Security Mechanisms II

Appendix A PRIMARY COMMANDS. SYS-ED/ Computer Education Techniques, Inc.

IBM. DFSMS Using the Interactive Storage Management Facility. z/os. Version 2 Release 3 SC

APPENDIX 2 Customizing SAS/ASSIST Software

Using the SQL Editor. Overview CHAPTER 11

Fundamentals of Operating Systems

About these Release Notes. Documentation Accessibility. New Features in Pro*COBOL

Chapter 13 Introduction to SQL Programming Techniques

Mainframe Developer & Admin Training in Chennai

About the Authors. Preface

The QMF Family Newsletter 1 st Quarter 2012 Edition

Installing and Administering a Satellite Environment

Debug Tool: Introduction. Performance Objectives

Distributed Data Processing (DDP-PPC) OSI Interface C Language

IBM. TSO/E User's Guide. z/os. Version 2 Release 3 SA

Compute (Bridgend) Ltd

IBM. TSO/E Primer OS/390 GC

PL/SQL Block structure

JCL JOB CONTROL LANGUAGE

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe

Introduction to Computer Science and Business

Querying Microsoft SQL Server (461)

CONTENTS. INTRODUCTION xvii

User sguidefortheviewer

About these Release Notes. This document contains important information about Pro*COBOL 12c Release 2 (12.2).

Understanding the Concepts and Features of Macro Programming 1

Tivoli Decision Support for OS/390 Administration Guide. Version SH

Contents. Acknowledgments Introduction

SAS/ACCESS Interface to R/3

Symbol Spotting in Digital Libraries

How Oracle Does It. No Read Locks

IBM. TSO/E Primer. z/os. Version 2 Release 3 SA

Production Methods: Behind the Scenes of Virtual Inhabited 3D Worlds

The Art of Lisp Programming

1 of 75 12/1/2009 5:46 PM

Db2 Query Management Facility Version 12 Release 2. Using Db2 QMF IBM SC

CA Plan Analyzer for DB2 for z/os

z/os Version 2 Release 3 TSO/E User's Guide IBM SA

Introduction to SQL/PLSQL Accelerated Ed 2

SQL Queries. for. Mere Mortals. Third Edition. A Hands-On Guide to Data Manipulation in SQL. John L. Viescas Michael J. Hernandez

Introduction. Chapter 1: Objectives

Concurrent, Real-Time and Distributed Programming in Java

Oracle Financial Analyzer Oracle General Ledger

SAS File Management. Improving Performance CHAPTER 37

Oracle Database: Introduction to SQL/PLSQL Accelerated

z/os Learning Center: Introduction to ISPF Unit 1: The Basics of ISPF and Data Sets Module 2: The ISPF PDF Primary Options Menu

ITCS Implementation. Jing Yang 2010 Fall. Class 14: Introduction to SQL Programming Techniques (Ch13) Outline

Inside Symbian SQL. Lead Authors Ivan Litovski with Richard Maynard. Head of Technical Communications, Symbian Foundation Jo Stichbury

DB2 SQL Tuning Tips for z/os Developers

Sql Server Check If Global Temporary Table Exists

Uni Hamburg Mainframe Summit z/os The Mainframe Operating. Part 2 TSO, ISPF und Unix Shell. Introduction to the new mainframe

Contents. Using. Dynamic SQL 44. Bag of Tricks 56. Complex SQL Guidelines 90. Working with Nulls 115. Aggregate Functions 135

Mastering Transact-SQL An Overview of SQL Server 2000 p. 3 SQL Server's Networked Architecture p. 4 SQL Server's Basic Components p.

UNIT - 5 EDITORS AND DEBUGGING SYSTEMS

The Test Workbench in the SAP System (BC-CAT-PLN)

0 Mastering Microsoft Office

Develop a batch DB2 for z/os COBOL application using Rational Developer for System z

VISION:Builder VISION:Two

ADVANTAGES. Via PL/SQL, all sorts of calculations can be done quickly and efficiently without use of Oracle engine.

Multi-Core Programming

COMP 3400 Mainframe Administration 1

Cincom AD/Advantage. MANTIS Oracle Programming Android /Windows /Linux /UNIX P MANTIS

Introduction. LOCK Statement. CHAPTER 11 The LOCK Statement and the LOCK Command

Relational Database Index Design and the Optimizers

Transcription:

Anthony S. Rudd Implementing Practical DB2 Applications With 69 Figures, Springer

Antho ny S. Rudd. MS(Hons) OateveG Paumgartnerstrasse 6-14 0-90426 Nuremberg. GERMANY ISBN-I3: 978-3-540-19953-3 Dar: 10. 1007/978-1-4471-1035-4 e-isbn-i3: 978-1-4471-1035-4 British Library Cataloguing in Publication Data Rudd, Anthony S. Implementing practical OB2 applications. - 2nd ed. 1.0B2 (Computer program) 2.0atabase management - Computer progralt\$ I.Title 005.1'56'5 ISBN-I3: 918-3-540-19953-3 Library of Congrus Cataloging-in-Publ ieat ion Data A catalog record for this book is available from th e Library of Congress Apart from any fair dealing fo r the purposes of research or private study, or criticism or review, as pe rmitted under th e Copyright, Designs and Pate nts Act 1988, this publication may only be reproduced, stored o r transmiued, in any fo rm or by any means, with Ihe prior pe rmiuion in writing of the publishers, or in the cue of reprographic reproduction in accordance wilh the terlt\$ of licences iuued by th e Copyright lice nsing Agency. Enquiries co nce rning reproduction outside those te r lt\$ should be sent to th e pub/is hers. e Springer-Verlag london l imited 1996 The use ofregisthed names, Irademarb etc. in th is publication does not imply, even in th e abunce of a specific statement, that such names I re exempt from Ihe releyant la ws and regulations Ind therefore free for general use. The publisher makes no representation, txpreu or implied, with regard 10 the accu racy oftht information contained in this book and Clnnot accept any legal responsibility or liability fo r any erron or omiuions that may be made. Typeuning: camna ready by author 3413830-5432 10 Printed on acid free paper

Preface The title of this book "IMPLEMENTING DB2 APPLICATIONS' reveals the purpose I had in writing it: a concise, complete, source of information necessary for the development and implication of applications using IBM'S DB2 relational database package in the MVS environmenl. When I started wriling DB2 applications I was quite literally overwhelmed by the physical amount of literature available. And usually all of this literature was necessary as reference for the writing of an application, because the required infonnatian was distributed amongst the manuals. With this book I have tried to separate out that information necessary to put an application together. This book is hopefully more than a mere reference; it contains tips and notes I and my colleagues found out the hard way. I have tried to present this practical information in such a form that it is easy to find and use. I hope this will enable readers to spend more productive time developing applications, rather than trying to find out why something works in a particular way. Good though the IBM manuals are, they suffer from two drawbacks: they have now attained a s ize (and weight) that they are unwieldy to use; reference manuals offer limited scope to explain background information or critique, where it might be required. And who should read this book? Both beginners and expens. Beginners are lead through the steps required to put DB2 applications together; complete worked examples, large enough to be practical but devoid of superfluous

vi PREFACE detail, enable the DB2 novice to see what is necessary to implement a simple application. Experts have a compact reference for those features necessary to write a DB2 application. In particular, the mechanics of preparing and testing a DB2 application program. What this book is not? This is not a book about SQL; there have been enough books published already on this subject. This book does not go into the details of writing SQL statements, although it is sufficiently detailed to serve as a basic reference, rather it describes how the various components fit together. Similarly, it does not treat the subjects of distributed applications and optimisation. Also, it does not discuss the internal processing and optimisation aspects of DB2 systems. These are all specialised topics, a discussion of which would conflict with the aim of having a compact book. At this point I would like to thank Elke Berger for her help and suggestions for improvements.

Table of Contents Preface......... v I. Introduction 1.1 DATABASE2 (OB2) environment... I I.2 DBl data objects......... 2 I. 3 Access to DB2 tables.......... 3 1.4 UseofSQL...... 3 1.5 Use of SQL from applications...... 4 2. Applicalion Design 2.1 Application design......,.,........ 6 2.2 Application considerations... 7 2.2. 1 Dialogue or batch?.... 7 2.2.2 Command procedure... 8 2.2.3 Static or dynamic SQL?... 8 2.2.4 Changes to the database... to 2.2.5 Authorisation considerations...... 10 2.3 Which product to use... 11 3. QMF Facilities 3. 1 Introduction......... t 2 3.2 QMF objects........ 12 3.2.1 QMFquery......... 13 3.2.2 QMF data........ 13 3.2.3 QMF form........... 13 3.2.4 QMF report........... 13 3.2.5 QMF procedure.............. 14

viii TABLE OF CONTENTS 3.2.6 3.2.7 3.3 3.4 3.4.1 3.4.2 3.4.3 3.5 3.5.1 3.5.2 3.6 3.6.1 3.6.2 3.6.3 3.6.4 3.7 3.7.1 3.7.2 QMF profile... 14 QMF chart... 14 QMF invocation... 14 QMF command facilities... 15 Transfer of QMF items to/from host system... 15 Administration of QMF objects... 15 Invoke host system component... 15 Invocation of QMF... 16 QMF files... 17 Sample CLIST for invocation of QMF... 18 QMF callable interface... 18 The DSQCOMM communications area... 18 Callable interface invocation syntax... 20 START command... 21 Examples... 22 QMF command interface... 30 QMF status... 30 Passing parameters to a QMF command... 31 4. QMF Commands 4.1 Introduction... 33 4.2 Commands... 33 4.2.1 DISPLAY - Display an object..... 34 4.2.2 END - End current operation... 35 4.2.3 ERASE - Remove object from database... 35 4.2.4 EX IT - Terminate QMF session... 36 4.2.5 EXPORT - Transfer object to external dataset... 36 4.2.6 HELP - Display help information... 38 4.2.7 IMPORT - Impon object into the QMF environment..... 38 4.2.8 INTERACT - Provide interactive suppon... 39 4.2.9 ISPF - Invoke ISPF/PDF panel....40 4.2.10 LIST - Display list of QMF objects... 40 4.2.11 MESSAGE - Display message...41 4.2.12 PRINT - Print content of object...42 4.2.13 QMF - Execute explicit QMF command...45 4.2.14 RESET - Clear object.... 45 4.2.15 RESET QUERY - Clear query object...46 4.2.16 RESET GLOBAL - Clear global variable... 46 4.2.17 RUN - Execute object... 46 4.2.18 SAVE - Save contents of work area...47 4.2.19 SAVE DATA - Save contents of data area....48 4.2.20 SAVE PROF I LE - Save profile...49 4.2.21 SET (PROFILE) - Set profile...49 4.2.22 SET GLOBAL - Set global variable... 51 4.2.23 STATE - Return QMF status... 51 4.2.24 TSO - Invoke TSO command... 51 4.3 Example... 52 4.4 External QMF data... 54 4.5 QMF external data format... 57 4.6 IXF data... 58

TABLE OF CONTENTS ix 4.7 4.8 4.9 QMF external data....... QMF data format.. QMF repon data.......... 62... 64...... 66 5. Program Environment 5.1 Introduction................ 71 5.2 lcl procedures...... 73 5.2.1 PU I preprocessor... 75 5.2.2 OB2 precompiler...... 76 5.2.3 Compile....... 79 5.2.4 Pre linkedit......... 79 5.2.5 Linkedit...............79 5.2.6 Bind....... 79 5.3 Example............ 80 5.4 OB21 (OB2 Interactive)............... 80 6. DB2 program Invocation 6.1 Introduction...... 81 6.2 Commands penaining to OB2.......... 82 6.2.1 DSN - Invoke OBI session............. 82 6.2.2 OS NH - Prepare program in foreground...... 82 6.3 OB2 subcommands...... 83 6.3. 1 BIND PACKAGE - Build application package.... 83 6.3.2 BIND PLAN' Build application plan... 86 6.3.3 OCLGEN -Table declaration generator...... 88 6.3.4 END - Terminate OB2 session...... 90 6.3.5 FREE - Free application plan.............. 91 6.3.6 REBUO - Rebind application plan... 91 6.3.7 RUN - Invoke OB2 program....... 93 6.3.8 spun -SQL Processor Using File Input.............. 94 6.4 DB2! (OATABAS E2 Interactive).... 94 6.4. 1 Invoke SPUfl... 95 6.4.2 Invoke OCLGEN....................... 97 6.4.3 Perform OB2 Program Preparation........... 97 6.4.4 Perform OB2 Precompile............ 99 6.4.5 Perform OB2 Bind function.......... 100 6.4.6 Run an SQL program... 101 6.4.7 Set OB21 global default parameters......... 103 6.5 Invoke program independent of OBI (CAF interface)... 104 6.5.1 CLOSE function... 105 6.5.2 CONNECT function...... 106 6.5.3 DISCONNECT function... 107 6.5.4 OPEN function.............. 108 6.5.5 TRANSLATE function..... 109 6.5.6 CAF interface program... 109 7. Issuing SQL statements from within a program 7. 1 Introduction................ 116 7.2 SQL status... 117 7.2.1 DSNTIAR subroutine....... 118

x TABLE OF CONTENTS 7.3 7.3.1 7.3.2 7.3.3 7.3.4 7.4 7.5 7.5.1 7.5.2 7.5.3 7.5.4 Program host variables........ 119 PU I hosl variables... 119 COBOL host variables... 120 Assembler hosi variables.... 122 CI370 host variables............. 124 Indicator variables...... 125 Use of SQL from programs..... 125 Static SQL................... 125 Static SQL select with a fixed number of columns... 127 Dynamic SQL... 130 Dynamic SQL wilh a variable number of columns... 132 8. Embedded SQL Statements 8.1 8.2 Introduction... 137 Statements...... 137 8.2.1 BEGIN DECLARE - Start declaration of hosl variables..... 138 8.2.2 8.2.3 8.2.4 8.2.5 8.2.6 8.2.7 8.2.8 8.2.9 8.2.10 8.2. 11 CLOSE - Close cursor...... 139 COM/'IIT - Make outstanding database changes permanent... 139 DECLARE CURSOR - Define cursor...... 140 DECLARE STATEMENT - Define SQL statement name... 141 DECLARE TABLE - Define table structure...... 141 DELETE - Delete rows... 142 DESCRIBE - Obtain information aoom a prepared statement... 143 END DECLARE - Terminate declarations... 144 EXECUTE - Execute a prepared statement... 144 EXECUTE IMMEDIATE - Prepare and execute an executable 8.2.12 8.2.13 8.2.14 8.2.1 5 8.2.16 8.2.17 8.2.18 8.2.19 8.2.20 8.2.21 8.2.22 SQL statement......... 145 E)(PLA t N -Obtain processing statistics... 146 FETCH - Position cursor to next row... 150 INCLUDE - Include definitions....... 151 INSERT - Insert rows... 151 LOCK TABLE - Set lock... 152 OPEN - Create results table for select..... 153 PREPARE - Prepare SQL statement... 154 ROLLBACK - Revoke outstanding database changes... 155 SelECT INTO - Produce single-row results table...... 155 UPDATE - Update database rows... 156 WHENEVER - Define exception processing... 157 9. Transaction Processing 9.1 Introduction... 159 9.2 SQL transaction concepts... 159 9.3 Consistency... 160 9.4 Concurrency... 160 10. Testing 10.1 10.2 10.3 10.3. 1 Introduction... 164 DB2 testing tools... 165 Testing of programs using DB2 (SQL) facilities....... 165 Testing using the CAF interface.......... 165

TABLE OF CONTENTS xi 10.3.2 1O.J.3 10.4 10.5 Testing by creating the DB2 environment... 168 Testing using ISPFfPDF Dialog Test.............. 169 CommitfRollback in the testing environment... 170 Summary..................... 170 11. Worked Example 11. I Introduction... 171 Il.l Problem specification............. 171 11.3 QMF solution......... 175 11.4 Program solution... 179 11.5 Summary................. 183 Appendix A. Syntax Notation... 184 Appendix B. SQL Control Areas............ 187 Appendix C. Glossary............... 196 Index......................... 203