ALLBASE/SQL Pascal Application Programming Guide MPE/iX 5.0 Documentation
ALLBASE/SQL Pascal Application Programming Guide
Table of Contents
ALLBASE/SQL Pascal Application Programming Guide
ALLBASE/SQL Pascal Application Programming Guide : COPYRIGHT NOTICE
Ch 1. Getting Started with ALLBASE/SQL Pascal Programming
ALLBASE/SQL Pascal Programs
Program Structure
DBEnvironment Access
Authorization
File Referencing
Native Language Support
The ALLBASE/SQL Pascal Preprocessor
Effect of Preprocessing on Source Code
Effect of Preprocessing on DBEnvironments
The Stored Section
Purpose of Sections
Section Validity
Compiling and Linking the Program
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
Ch 2. Using the ALLBASE/SQL Pascal Preprocessor
The Preprocessor and Program Development
Preprocessor Modes
Preprocessor Input and Output
Source File
Output File Attributes
Preprocessor Modified Source File
Preprocessor Input and Output (continued)
Preprocessor-Generated Include Files
ALLBASE/SQL Message File
Installable Module File
Stored Sections
Invoking the Pascal Preprocessor
Syntax Checking Mode
Full Preprocessing Mode
Using the Preprocessor UDCs
Running the Preprocessor in Job Mode
Preprocessing Errors
Preprocessor or DBEnvironment Termination
Preprocessor Invocation Errors
SQLIN Errors
DBEnvironment Errors
Ch 3. Embedding SQL Commands
General Rules for Embedding SQL
Location of SQL Commands
Prefix and Suffix
Punctuation
Pascal Comments
ALLBASE/SQL Comments
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
Ch 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
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
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 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]
SQLCA.SQLWARN[0]
SQLCA.SQLWARN[1]
SQLCA.SQLWARN[2]
SQLCA.SQLWARN[3]
SQLCA.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 Qualfies
Detecting Log Full Condition
Handling Out of Space Conditions
Checking for Authorizations
Ch 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
Ch 7. Simple Data Manipulation
SQL Commands
The SELECT Command
The INSERT Command
The UPDATE Command
The DELETE Command
Transaction Management for Simple Operations
Program Using Simple DML Operations
Procedure Select
Procedure Update
Procedure Delete
Procedure Insert
Ch 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
Procedure FetchUpdate
Procedure DisplayUpdate
Ch 9. Bulk Table Processing
Variables Used in BULK Processing
SQL Bulk Commands
BULK SELECT
BULK FETCH
BULK INSERT
Transaction Management for BULK Operations
Program Using BULK INSERT
Ch 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 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 Dynamic Commands That May or May Not Be Queries
Programs Using Dynamic Command Operations
Sample Program Using Dynamic Commands of Unknown Format
Programs Using Dynamic Command Operations (continued)
Sample Program Using Dynamic Queries of Known Format
Ch 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
Ch 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
Parsing LONG Column Descriptors
Using LONG Columns with a 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 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
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
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