HPlogo ALLBASE/SQL C Application Programming Guide: HP 3000 MPE/iX Computer Systems > Chapter 8 Using Dynamic Operations

Review of Preprocessing Events

» 

Technical documentation

Complete book in PDF
» Feedback

 » Table of Contents

 » Index

All embedded SQL statements must be preprocessed before they can be executed. Preprocessing may be done by running the C preprocessor during application development, or it may be done for dynamic commands when the program is run. Preprocessing does the following:

  • Checks syntax: The syntax of SQL commands and host variable declarations must be correct.

  • Verifies the existence of objects: Any object named in an SQL command must exist.

  • Optimizes data access: If the statement accesses data, the fastest way to access the data must be determined.

  • Checks authorizations: Both the program owner and the executor must have the required authorities.

  • Creates sections: ALLBASE/SQL creates sections for SQL commands when this is appropriate. At run time, the section is executed.

These preprocessing events take place for all non-dynamic SQL commands when you run the ALLBASE/SQL preprocessor. Non-dynamic commands are fully defined in the source code and are preprocessed before run time. So far, most of the examples in this manual have shown non-dynamic preprocessing.

ALLBASE/SQL completes the preprocessing of dynamic commands at run time, in an event known as dynamic preprocessing. Any SQL command except the following, which do not require sections for execution, can be preprocessed at run time:

   BEGIN DECLARE SECTION           FETCH

   CLOSE CURSOR                    INCLUDE

   DECLARE CURSOR                  OPEN CURSOR

   DELETE WHERE CURRENT            PREPARE

   DESCRIBE                        SQLEXPLAIN

   END DECLARE SECTION             UPDATE WHERE CURRENT

   EXECUTE                         WHENEVER

   EXECUTE IMMEDIATE

Dynamic commands that are not queries can be preprocessed at run time using the PREPARE and EXECUTE statements or the EXECUTE IMMEDIATE statement. Dynamic queries are preprocessed using the PREPARE and DESCRIBE commands in conjunction with the SQLDA or SQL Description Area and other data structures. These statements and data structures, used with a cursor, are described further in a later section.

Feedback to webmaster