Go BackSQL/DS: Row and Table Manipulation

Synopsis
SQL/DS: Row and Table Manipulation covers how to select one or many rows from a table as well as all aspects of updating tables.

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

Time
3 - 6 hours

Product Code: SDS103
After completing this course, the student should be able to:
 
Select a single row into a host structure
Select multiple rows
Updates tables -- directly and with a cursor
Selecting a Single Row
Covers selection of a single row from a table.  All variations of the SELECT INTO statement are covered, with separate lessons devoted to NULL and VARCHAR columns.
 
Course Tables
Data found in the tables used in the course.
SELECT INTO
Purpose and format of the SELECT INTO statement.  Selecting into host variables.  Compatibility of SQL/DS columns and COBOL fields.
Variable Length Columns
SYSTEM.SYSCOLUMNS to check column lengths.  Use of a length indicator for variable length columns.  49-level fields in a host variable.
Nulls
SQL/DS's indicator value for null columns.  Coding an indicator variable in the SELECT statement.


Selecting Multiple Rows
Shows how SQL, which can select many rows at once, and COBOL, which can process only one row at a time, are able to reconcile their differences.
 
Introduction
SQL's active set and cursor to handle multiple rows that meet the selection criteria.
Selecting Data With a Cursor
Purpose and format of the DECLARE CURSOR statement.  Use of ORDER BY as part of the DECLARE CURSOR statement.  Purpose and format of the OPEN CURSOR statement.
Fetching Rows
Purpose and format of the FETCH statement.  Use of the host list for data from the cursor.  Closing and re-opening the cursor.
Workshop

Coding SQL statements in a COBOL program to access SQL/DS data.

Updating Tables
Covers all aspects of updating tables from application programs.  Special attention is given to using the cursor to apply changes to many records one at a time.
 
Direct Updates
Possible values for updates and inserts.  Updating or deleting a row without first reading it.  Updates and deletes affecting many rows.  Checking SQLERRD or SQLCODE after updates, deletes or inserts.  Using blocking to minimize I/O.
Indirect Updates
Reasons to read a row before updating it.  Updates with a cursor.  Use of the FOR UPDATE OF clause.  Deleting the current row of the active set.
Nulls
Updating a column with nulls via COBOL versus SQL.  Coding an indicator variable in the SET statement.
Variable Length Columns
Providing a length value in an UPDATE or INSERT statement.  SQL/DS's use of the length provided.

Go Back