OVERVIEW
This course provides training for skills needed to code DB2 embedded SQL inCOBOL application programs. Topics include how to prepare DB2 programs, access DB2 databases using SQL, retrieve multiple rows of output using cursors and handle commit processing through COBOL programs.
DURATION - 2-3 Days
OBJECTIVES
- Retrieve from and update DB2 tables using SQL data manipulation verbs.
- Identify the differences between a standard COBOL program and one that accesses DB2 tables.
- Embed SQL code in COBOL programs as well as code the related application structures needed for accessing DB2 tables from an application program.
- Prepare, execute and test batch programs that access and update DB2 data efficiently and maintain integrity.
- Employ CURSOR processing in application programs.
- Describe and use commit-point processing and identify when and how to use commit points effectively.
INTENDED AUDIENCE
This course is designed for people who will be coding and/or maintaining application programs using DB2, primarily application developers who code COBOL programs.
PREREQUISITES
Experience with or training in Relational Database (Introduction to Relational Database course) and SQL Programming (SQL Fundamentals course) is needed for this class. Some experience with COBOL is also preferred.
FORMAT/MATERIALS
This course includes a combination of lecture, discussion and numerous computer labs. Students will receive an extensive reference manual, which will be helpful on the job as well as in class. There is an optional textbook available for future reference
CONTENT
I. Overview of Embedded SQL
- Syntax
- Checking SQLCODE
- Program Preparation
II. Application Programming - Single Row Processing
A. Application Processing/Structure
- Features and Processing Modes
- COBOL Program Structure
- Embedding SQL
- SQLCA
- DECLARE TABLE
- DCLGEN
- Using Host Variables
- Using Host Structures
- Working with Nulls and Indicator Variables
- Sample Program Review
B. Program Preparation and Execution
- Review Concepts/Facilities Involved
- DB2I Utilities or JCL
- Precompile
- DBRM
- Bind
- Application Packages and Plans
- Program Execution
C. Locking/Integrity Issues
- Lock Sizes and Modes
- Types of Locks - Exclusive vs. Shared
- Bind Parameters and Locking - Repeatable Read vs. Cursor Stability
- Programming Workshop
III. Application Programming - Multiple Row Processing
A. Cursor Processing
- Concepts/Usage Steps
- DECLARE CURSOR
- OPEN CURSOR
- FETCH CURSOR
- Updating Within a Cursor
- CLOSE CURSOR
B. Commit Processing
- Data Integrity
- COMMIT
- Unit of Recovery
- Committing with Cursors
C. Cursor Efficiency
- FOR UPDATE Clause
- OPTIMIZE FOR Clause
- Sample Program Review
- DB2 Application Program Checklist
- Restart Capabilities and Design
IV. Stored Procedures
A. Concepts
B. Called Procedure
C. Calling Program
D. DB2 Catalog
V. Appendix
- SQL Language Statement Summary
- SQLCODE Summary