Go BackDB2: The Programming Environment

Synopsis
DB2: The Programming Environment introduces the programming considerations related to embedding SQL statements in a COBOL program.

Audience
This course is designed for COBOL programmers who want to use SQL in their programs to access data in DB2 tables.

Time
2 - 4 hours

Product Code: DB2112
After completing this course, the student should be able to:
 
Describe when and why SQL is embedded in a COBOL program
Identify the tools available and the tasks to perform in your environment
Explain how SQL reads data into and writes from Working Storage
Describe the communication that occurs between COBOL and SQL
Explain the purpose of stored procedures and how they operate

Overview
Shows how easy it is to embed SQL in a COBOL program and introduces all the programming considerations that are treated in depth in later sections.
 
Embedding SQL in a Program

Advantages to embedding SQL in a COBOL program.  Some things SQL can't do.  Key points about embedding SQL in a COBOL program.
 
SQL in the Programming Environment

SQL in batch and on-line COBOL programs.  DB2 and non-DB2 data.  DB2I capabilities.
 
Course Tables

Data found in the tables used in the course Embedding SQL in a Program
Shows how SQL reads data into and writes from Working Storage.  Covers in detail rules for communicating between COBOL and SQL, together with error checking.
 
Overview of Embedded SQL

SQL and COBOL communication through host variables.  Error and result codes available in the SQLCA.  The SQL WHENEVER statement to check error and result codes.  Testing SQLCA fields via code in your program.
 
The Procedure Division

Opening and closing files versus DB2 tables.  The SQL SELECT INTO statement.  Host variables in the SELECT statement and WHERE clause.  Use and coding of host variables.  Referential constraint considerations.
 
The Data Division

File definition considerations for DB2 tables.  The SQL DECLARE TABLE statement.  DCLGEN and the SQL INCLUDE statement to bring declarations into your program.  Declaring host variables in the Working Storage Section.  Host structures and the SQLCA in Working Storage.  
 
Error Handling

The SQLCODE and SQLSTATE fields to test for errors.  Additional fields in the SQLCA with error-related information.  Coding and use of the WHENEVER statement for error checking.  Procedural checking of the SQLCA fields.
 
Stored Procedures

Definition of a stored procedure.  The role stored procedures play in client/server computing. The impact stored procedures have on applications and data. How stored procedures interact with their calling programs.

 

Go Back