Previous Topic: Delimited, Continued, and Commented StatementsNext Topic: Defining Host Variables


Placing an SQL Statement

Where You Can Put Statements

These are the rules for placing an SQL statement in a CA ADS program:

Order of Compilation

Dialog modules are compiled in this order:

  1. Declaration module
  2. Premap process module
  3. Response process modules

The order of compilation of response process modules is not guaranteed. Therefore, if a WHENEVER condition or the availability of a cursor must span modules, you should place the WHENEVER statement or cursor declaration in a declaration module.

Declaration Module

CA ADS uses a declaration module, if it exists, when you compile the dialog.

The declaration module can contain WHENEVER directives and DECLARE CURSOR statements.

WHENEVER and DECLARE CURSOR are not executable statements, and a declaration module is not executable. The scope of a WHENEVER or DECLARE CURSOR is the entire dialog.

A WHENEVER directive or DECLARE CURSOR statement is valid in a premap or response process, but the scope of the statement is not global.

Scope of WHENEVER

The scope of a WHENEVER condition in a premap or response is the rest of that premap or response or until another WHENEVER statement that changes the condition is encountered within the process.

A WHENEVER declaration in a premap or response overrides (for the duration of its scope) the global declaration in the declaration module.

Scope of DECLARE CURSOR

The scope of a DECLARE CURSOR statement is from the moment that the declaration is encountered in dialog compilation to the end of that compilation.