(Contents)(Previous)(Next)

Dynamic SQL Statements

ADABAS statements cannot only be written statically into an application program, but also be dynamically generated or read in and executed during a program run. The SQL statements to be performed dynamically may contain SQL variables as input and output parameters.

Dynamic statements can also be executed in an ORACLE-compatible way. To do so, the corresponding SQLMODE must be specified for precompilation. The syntax of the statements was therefore extended. The statements described in the Reference manuals for the SQLMODE ORACLE must be (see there).

Dynamic statements are processed in two steps or, when a descriptor is used, in three steps.

- The SQL statement specified as a parameter is prepared and named for its execution by means of the PREPARE statement. Any host variables which exist within the SQL statement to be prepared must be designated by question marks or are described via the descriptor.

- If the PREPARE statement stipulates that the host variables are to be described via a descriptor, the DESCRIBE statement must be called afterwards. This statement generates an SQLDA (SQL Descriptor Area) or uses the descriptor defined by the user and provides it with information which is needed for the identification of parameters. By means of this information, the user can associate appropriate program variable values with parameters.

- Once the PREPARE or DESCRIBE statement is successfully executed, the prepared SQL statement can be performed. This is done by the SQL statement EXECUTE which requires

- the name qualified in the PREPARE statement for the SQL statement to be executed,

- the parameters to be included in place of the question marks. The usage of the descriptor must be indicated ( ...USING DESCRIPTOR ).

EXECUTE IMMEDIATE offers another possibility of dynamically executing SQL statements. The statement to be performed do not need to be prepared with PREPARE and must not contain host variables.

See also:

EXEC SQL [<n>] PREPARE

EXEC SQL [<n>] DESCRIBE

EXEC SQL [<n>] EXECUTE

EXEC SQL [<n>] EXECUTE IMMEDIATE


(Contents)(Previous)(Next)