ALLBASE/SQL C Application Programming Guide MPE/iX 5.0 Documentation
ALLBASE/SQL C Application Programming Guide
Table of Contents
ALLBASE/SQL C Application Programming Guide
ALLBASE/SQL C Application Programming Guide : COPYRIGHT NOTICE
Ch 1. Getting Started with ALLBASE/SQL Programming in C
Understanding ALLBASE/SQL Operations
Using DML to Manipulate Data
Using DDL to Define Database Objects
Using DCL to Manage Security
Handling Transactions
Handling Errors
Dynamic and Non-Dynamic Operations
Understanding the Program Life Cycle
Developing ALLBASE/SQL Applications
Creating Source Files
Using Embedded SQL
General Rules for Embedding SQL
Declaring Special Data Structures
Declaring Host Variables
Skeleton Program
Rules of Syntax for Embedded SQL Statements
Preprocessing the Source File
Creating the Modified Source File
Creating Stored Sections
Stored Form of the SQL Command
Optimized Access Instructions
Validity Flag
Runtime Revalidation of Sections
Generating the Message File
Compiling and Linking the Program
Running the Program
Authorizations
Debugging and Testing
Moving into the Production Phase
Installing Program Modules
Granting Module Owner Authorizations
Granting Program User Authorization
Maintaining ALLBASE/SQL Applications
Tuning Performance
Managing Source Code
Updating Application Programs
Changing Program-Related Authorization
Dropping Obsolete Modules
Programming Under the MPE XL Operating System
Security Considerations
File Naming Conventions
Native Language Support
Looking at an Embedded SQL Source Program
Ch 2. Using the Preprocessor
Invoking the C Preprocessor
Full Preprocessing Mode
Preprocessor Syntax I
Parameters
Description
Authorization
Example
Syntax Checking Mode
Preprocessor Syntax II
Description
Authorization
Example
DBEnvironment Access
Compiling and Linking
Using the Preprocessor UDCs
Using the Preprocessor in Job Mode
Running the Program
Accessing Multiple DBEnvironments
Identifying Preprocessor Input
Source File
ALLBASE/SQL Message Catalog
Identifying Preprocessor Output
Modified Source File
Include Files
ALLBASE/SQL Message File
Stored Module Containing Sections
Installable Module File
Handling Preprocessor Errors
Preprocessor or DBEnvironment Termination
Preprocessor Invocation Errors
Source File Errors
DBEnvironment Errors
Sample Modified Source File
Sample Preprocessor Generated Include Files
Ch 3. Host Variables
Using Host Variables
Host Variable Names
Input and Output Host Variables
Indicator Variables
Bulk Processing Variables
Declaring Host Variables
Creating Declaration Sections
Declaring Variables for Data Types
CHAR Data
VARCHAR Data
SMALLINT Data
INTEGER Data
FLOAT Data
Floating Point Data Compatibility
BINARY Data
Binary Data Compatibility
Using the LONG Phrase with Binary Data Types
Declaring Host Variables for BINARY Data
Declaring Host Variables for VARBINARY Data
Inserting and Updating VARBINARY Data
Selecting and Fetching VARBINARY Data
DECIMAL Data
DATE, TIME, DATETIME, and INTERVAL Data
Using Default Data Values
Coding Considerations
When the DEFAULT Clause Cannot be Used
Declaring Variables for Compatibility
String Data Conversion
String Data Truncation
Numeric Data Conversion
Declaring Variables for Program Elements
sqlca Array
Dynamic Processing Arrays
Bulk Processing Arrays
Indicator Variables
Dynamic Commands
Savepoint Numbers
Messages from the Message Catalog
DBEnvironment Name
Ch 4. 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[2]
sqlwarn[0]
sqlwarn[1]
sqlwarn[2]
sqlwarn[3]
sqlwarn[6]
Approaches to Status Checking
Implicit Status Checking Techniques
Program Illustrating Implicit and Explicit Status Checking
Explicit Status Checking Techniques
Handling Deadlock and Shared Memory Problems
Determining Number of Rows Processed
INSERT, UPDATE, and DELETE Operations
BULK Operations
Detecting End of Scan
Determining When More Than One Row Qualifies
Detecting Log Full Condition
Handling Out of Space Conditions
Checking for Authorizations
Ch 5. Simple Data Manipulation
SQL Commands
SELECT
INSERT
UPDATE
DELETE
Transaction Management for Simple Operations
Sample Program Using Simple DML Commands
Ch 6. 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
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
Sample Program Using Cursor Operations
Ch 7. 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
Ch 8. 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 of Dynamic Non-Queries
Using EXECUTE IMMEDIATE
Using PREPARE and EXECUTE
Preprocessing of Dynamic Queries
Dynamically Updating and Deleting Data
Setting Up the SQLDA
Setting Up the Format Array
Setting Up the Data Buffer
Setting up a Buffer for Query Results of Unknown Format
Setting up a Buffer for Query Results of Known Format
Using the Dynamic Query Data Structures
Parsing the Data Buffer
Preprocessing of Commands That May or May Not Be Queries
Sample Programs Using Dynamic Query Operations
cex10a: Program for Dynamic Commands of Unknown Format
cex10b: Program Using Dynamic Commands of Known Format
Ch 9. 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
Ch 10. 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 [BULK] INSERT Command
Insert Using Host Variables for LONG Column I/O Strings
Bulk Insert Using Host Variables for LONG Column I/O Strings
Example
Example Data File
Retrieving LONG Column Data with a [BULK] SELECT, FETCH, or REFETCH Command
Using the LONG Column Descriptor
Example LONG Column Descriptor Declaration
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
File versus Random Heap Space
File Naming Conventions
Considering Multiple Users
Deciding How Much Space to Allocate and Where
Ch 11. Programming with ALLBASE/SQL Functions
Where Date/Time Functions Can Be Used
Defining and Using Host Variables with Date/Time Functions
Using Date/Time Input Functions
Examples of TO_DATETIME, TO_DATE, TO_TIME, and TO_INTERVAL Functions
Example Using the INSERT Command
Example Using the UPDATE Command
Example Using the SELECT Command
Example Using the DELETE Command
Using Date/Time Output Functions
Example TO_CHAR Function
Example TO_INTEGER Function
Using the Date/Time ADD_MONTHS Function
Example ADD_MONTHS Function
Coding Considerations
Program Example for Date/Time Data
Example Program cex9a
Programming with TID Data Access
Understanding TID Function Input and Output
Using the TID Function in a Select List
Using the TID Function in a WHERE Clause
Declaring TID Host Variables
Understanding the SQLTID Data Format
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
Index
MPE/iX 5.0 Documentation