HPlogo

ALLBASE/SQL COBOL Application Programming Guide: HP 9000 Computer Systems

» 

Technical documentation

Complete book in PDF
» Feedback

 » Table of Contents

 » Index

HP Part Number: 36217-90161

Edition: Third Edition

Published: Printed in U.S.A. 1992


Table of Contents

Preface
1 Getting Started with ALLBASE/SQL Programming in COBOL
ALLBASE/SQL COBOL Programs
Program Structure
DBEnvironment Access
Authorization
File Referencing
Use of Shared Memory
Choosing an Interprocess Communication Option
The ALLBASE/SQL COBOL Preprocessor
Effect of Preprocessing on Source Code
Effect of Preprocessing on DBEnvironments
The Stored Section
Purpose of Sections
Section Validity
The Compiler and the Runtime System
ALLBASE/SQL Program Execution
Installing the Program Module
Granting Required Owner Authorization
Granting Program User Authorization
Running the Program
Maintaining ALLBASE/SQL Programs
Updating Application Programs
Changing Program-Related Authorization
Obsoleting Programs
2 Using the ALLBASE/SQL COBOL Preprocessor
The Preprocessor and Application Development
Preprocessor Modes
Preprocessor Input and Output
Source File
Output File Attributes
Modified Source File
Preprocessor-Generated Copy Files
COPY Statement Support
ALLBASE/SQL Message File
Installable Module File
Stored Sections
Invoking the COBOL Preprocessor
Syntax Checking Mode
Full Preprocessing Mode
Preprocessing Errors
Preprocessor or DBEnvironment Termination
Preprocessor Invocation Errors
Source File Errors
DBEnvironment Errors
3 Embedding SQL Commands
General Rules for Embedding SQL
Location of SQL Commands
Prefix and Suffix
Punctuation
COBOL Comments
ALLBASE/SQL Comments
Continuation Lines
Declaring the SQLCA
Declaring Host Variables
Starting a DBE Session
Defining Transactions
Implicit Status Checking
Terminating a DBE Session
Defining and Manipulating Data
Data Definition
Data Manipulation
Explicit Status Checking
Obtaining ALLBASE/SQL Messages
4 Host Variables
Using Host Variables
Host Variable Names
Input and Output Host Variables
Indicator Variables
Bulk Processing Variables
Declaring Host Variables
Creating Declaration Sections
Using Default Data Values
Declaring Variables for Compatibility
Declaring Variables for Program Elements
Messages from the Message Catalog
Declaring Host Variables Passed Between Subprograms
5 Runtime Status Checking and the SQLCA
Purposes of Status Checking
Handling Runtime Errors and Warnings
Maintaining Data Consistency
Checking the Most Recently Executed Command
Using the SQLCA
SQLCODE
SQLERRD(3)
SQLWARN0
SQLWARN1
SQLWARN2
SQLWARN6
Approaches to Status Checking
Implicit Status Checking Techniques
Explicit Status Checking Techniques
6 Overview Of Data Manipulation
The Query
The SELECT Command
Selecting from Multiple Tables
Selecting Using Views
Simple Data Manipulation
Introducing The Cursor
Sequential Table Processing
BULK Table Processing
Dynamic Operations
7 Simple Data Manipulation
SQL Commands
SELECT
INSERT
UPDATE
DELETE
Transaction Management
Program Using Simple DML Commands
8 Processing with Cursors
SQL Cursor Commands
DECLARE CURSOR
OPEN
FETCH
UPDATE WHERE CURRENT
DELETE WHERE CURRENT
CLOSE
Transaction Management for Cursor Operations
Using KEEP CURSOR
KEEP CURSOR and Isolation Levels
KEEP CURSOR and Declaring for Update
OPEN Command Without KEEP CURSOR
OPEN Command Using KEEP CURSOR WITH LOCKS and CS Isolation Level
OPEN Command Using KEEP CURSOR WITH NOLOCKS
KEEP CURSOR and BEGIN WORK
KEEP CURSOR and COMMIT WORK
KEEP CURSOR and ROLLBACK WORK
KEEP CURSOR and Aborted Transactions
Writing Keep Cursor Applications
Examples
Common StatusCheck Procedure
Single Cursor WITH LOCKS
Multiple Cursors and Cursor Stability
Avoiding Locks on Terminal Reads
Program Using UPDATE WHERE CURRENT
9 Bulk Table Processing
Variables Used in BULK Processing
SQL Bulk Commands
BULK SELECT
BULK FETCH
BULK INSERT
Transaction Management for BULK Operations
Sample Program Using BULK Processing
10 Using Dynamic Operations
Review of Preprocessing Events
Differences between Dynamic and Non-Dynamic Preprocessing
Permanently Stored vs. Temporary Sections
Examples of Non-Dynamic and Dynamic SQL Statements
Why Use Dynamic Preprocessing?
Passing Dynamic Commands to ALLBASE/SQL
Understanding the Types of Dynamic Operations
Preprocessing Dynamic Queries with a C Routine
COBOL Call Example
C Subprogram Example
Assigning a Call Number to a Non-COBOL Subprogram
How To Preprocess, Compile, Link, and Run the Example Programs
Preprocessing of Dynamic Non-Queries
Using PREPARE and EXECUTE
Defining SQL Commands at Run Time
Sample Program Using EXECUTE IMMEDIATE
Using PREPARE and EXECUTE
11 Programming With Constraints
Comparing Statement Level and Row Level Integrity
Using Unique and Referential Integrity Constraints
Designing an Application Using Statement Level Integrity Checks
Insert a Member in the Recreation Database
Update an Event in the Recreation Database
Delete a Club in the Recreation Database
Delete an Event in the Recreation Database
12 Programming with LONG Columns
General Concepts
Restrictions
Defining LONG Columns with a CREATE TABLE or ALTER TABLE Command
Defining Input and Output with the LONG Column I/O String
Putting Data into a LONG Column with a INSERT Command
Insert Using Host Variables for LONG Column I/O Strings
Retrieving LONG Column Data with a SELECT, FETCH, or REFETCH Command
Using the LONG Column Descriptor
Using LONG Columns with a BULK SELECT Command
Using LONG Columns with a Dynamic FETCH Command
Changing a LONG Column with an UPDATE [WHERE CURRENT] Command
Removing LONG Column Data with a DELETE [WHERE CURRENT] Command
Coding Considerations
13 Programming with ALLBASE/SQL Functions
Programming with Date/Time Functions
Where Date/Time Functions Can Be Used
Defining and Using Host Variables with Date/Time Functions
Using Date/Time Input Functions
Using Date/Time Output Functions
Using the Date/Time ADD_MONTHS Function
Program Examples for Date/Time Data
Example Program Using Date/Time Functions
Example Program Converting a Column from CHAR to DATE Data Type
Programming with TID Data Access
Understanding TID Function Input and Output
Transaction Management with TID Access
Comparing TID Access to Other Types of Data Access
Verifying Data that is Accessed by TID
Considering Interactive User Applications
Coding Strategies
Reducing Commit Overhead for Multiple Updates with TID Access
Index

List of Figures

1-1 Creating an ALLBASE/SQL COBOL Application Program
1-2 Use of DBCore Shared Memory in a DBEnvironment
1-3 Preprocess Time Events
1-4 Compiling and Executing a COBOL Application Program with Static Linking of Runtime Routines
1-5 Compiling and Executing a COBOL Application Program with Dynamic Linking of Runtime Routines
1-6 Runtime Events
2-1 Developing a COBOL ALLBASE/SQL Program with Subprograms
2-2 COBOL Preprocessor Input and Output
2-3 Compiling Preprocessor Output and the System Copy File
2-4 Runtime Dialog of Program COBEX2
2-5 Sample Source File
2-6 Sample Modified Source File
2-7 Sample Constant Copy File
2-8 Sample Variable Copy File
2-9 Sample System Copy File
2-10 Sample sqlmsg Showing Error
2-11 Sample sqlmsg Showing Warnings
2-12 Information in SYSTEM.SECTION on Stored Sections
3-1 Sample Program COBEX2
4-1 Host Variable Declarations in the DATA DIVISION
4-2 Data Declarations Generated for Boundary Alignment
4-3 Declaring Host Variables for Single-Row Query Results
4-4 Declaring Host Variables for Multiple-Row Query Results
4-5 Declaring Host Variables for Dynamic Commands
4-6 Declaring Host Variables for Savepoint Numbers
4-7 Declaring Host Variables for Message Catalog Messages
4-8 Declaring Host Variables for DBEnvironment Names
4-9 Declaring Host Variables Passed Between Subprograms
5-1 Implicitly Invoking Status-Checking Paragraphs
5-2 Explicitly Invoking Status-Checking Paragraphs
5-3 Using SQLERRD(3) After a BULK SELECT Operation
6-1 Sample Query Joining Multiple Tables
6-2 Effect of SQL Commands on Cursor and Active Sets
7-1 Flow Chart of Program COBEX7
7-2 Runtime Dialog of program COBEX7
7-3 Program COBEX7: Simple Data Manipulation
8-1 Cursor Operation without the KEEP CURSOR Feature
8-2 Cursor Operation Using KEEP CURSOR WITH LOCKS
8-3 Cursor Operation Using KEEP CURSOR WITH NOLOCKS
8-4 Flow Chart of Program COBEX8
8-5 Runtime Dialog of Program COBEX8
8-6 Program COBEX8: Using Update WHERE CURRENT
9-1 Flow Chart of Program COBEX9
9-2 Runtime Dialog of Program COBEX9
9-3 Program COBEX9: Using Bulk Insert
10-1 Creation and Use of a Program that has a Stored Module
10-2 Creation and Use of a Program that has No Stored Module
10-3 Runtime Dialog of Program COBEX10A
10-4 Program COBEX10A: Using EXECUTE IMMEDIATE
10-5 Runtime Dialog of Program COBEX10B
10-6 Program COBEX10B: Using PREPARE and EXECUTE
11-1 Constraints Enforced on the Recreation Database
12-1 Flow of LONG Column Data and Related Information to the Database
12-2 Flow of LONG Column Data and Related Information from the Database
13-1 Using Date/Time Functions
13-2 Converting Date from CHAR to Default Type
13-3 Using RC and RR Transactions with BULK SELECT, SELECT, and UPDATE
13-4 Using TID Access to Reduce Commit Overhead
Feedback to webmaster