DECLARE STATEMENT

The DECLARE STATEMENT command (embedded SQL only) identifies prepared SQL statements for later use in application programs.

Invocation

DECLARE STATEMENT is not an executable statement. It can only be embedded in an application language.

Authorization

None required.

Syntax

DECLARE statement-name[,...] STATEMENT

Parameters:

statement-name Names one or more prepared SQL statements to be used in an application program.

Description

This nonexecutable statement is used in application programs to identify statement-name variables that can later be substituted for various kinds of SQL statements.

Example:

The C language example below first declares an SQL statement variable named mystatement. Next the contents of the host variable hostvar (typically the text of an SQL statement assembled in the host application) are placed into mystatement using the PREPARE command:

EXEC SQL 
    DECLARE mystatement STATEMENT
;
...

EXEC SQL 
    PREPARE mystatement FROM :hostvar
;
...