Previous Topic

Next Topic

Declare Statement

Valid in: ESQL

Declare statement lists one or more names that are used in a program to identify prepared SQL statements.

The declaration of prepared statement names is not required; declare statement is a comment statement, used for documentation in an embedded SQL program. No syntactic elements can be represented by host language variables.

The embedded SQL preprocessor does not generate any code for declare statement. Therefore, in a language that does not allow empty control blocks (for example, COBOL, which does not allow empty IF blocks), this statement must not be the only statement in the block.

Previous Topic

Next Topic

Syntax

The Declare statement has the following format:

EXEC SQL DECLARE statement_name {, statement_name) STATEMENT

Previous Topic

Next Topic

Related Statements

Prepare

Previous Topic

Next Topic

Example: Declare

The following example declares one statement name for a dynamic statement that is executed 10 times:

  exec sql declare ten_times statement;

  loop while more input
       print
        'Type in statement to be executed 10 times?';
       read statement_buffer;

  exec sql prepare ten_times
       from :statement_buffer;
  loop 10 times
       exec sql execute ten_times;
  end loop;
end loop;


© 2007 Ingres Corporation. All rights reserved.