ALLBASE/SQL Reference Manual (36216-90216)

Chapter 2 93
Using ALLBASE/SQL
Application Programming
Application Programming
To use SQL statements in an application program, you embed the statements in source
code, then use the ALLBASE/SQL preprocessor that supports the source language.
Preprocessor
The ALLBASE/SQL preprocessor performs the following tasks:
Checks the syntax of SQL statements embedded in an application program.
Translates embedded SQL statements into compilable C, FORTRAN, COBOL, or Pascal
constructs that call ALLBASE/SQL external procedures at run time.
Stores a module in the DBEnvironment.
A module contains a group of sections. A section consists of ALLBASE/SQL instructions
for executing an SQL statement at run time. ALLBASE/SQL ensures that any objects
referenced in the section exist and that current authorization criteria are satisfied. The
optimal data access path is determined at preprocessing time rather than at run time
which enhances runtime performance.
When an application program becomes obsolete, you can use the DROP MODULE statement
to delete its module from the DBEnvironment and thus ensure the program can no longer
operate on the databases in the DBEnvironment. For example:
DROP MODULE MyProgram
ALLBASE/SQL has the following statements that create modules when the information
for an SQL statement cannot be completely defined in advance. These dynamic
preprocessing statements are used in both programmatic and interactive environments:
PREPARE
EXECUTE
EXECUTE IMMEDIATE
In addition to the above statements, ALLBASE/SQL includes the following statements
which
cannot
be used interactively:
BEGIN DECLARE SECTION CLOSE CURSOR DECLARE CURSOR
DELETE WHERE CURRENT DESCRIBE END DECLARE SECTION
FETCH INCLUDE OPEN
REFETCH SQLEXPLAIN UPDATE WHERE CURRENT
WHENEVER
Preprocessed programs receive messages from ALLBASE/SQL through the SQL
Communication Area, called the SQLCA. Information is sent to ALLBASE/SQL through
the SQL Description Area, called the SQLDA. These structures and the above
statements are explained in detail along with examples in the ALLBASE/SQL application
programming guides.