Notes
Placement restrictions: The DECLARE VARIABLE statement
can be specified anywhere in an application program that SQL statements are
valid with the following exceptions:
- If the host language is COBOL or RPG, the DECLARE VARIABLE statement must
occur before an SQL statement that refers to a host variable specified in
the DECLARE VARIABLE statement.
- If DATE, TIME, or TIMESTAMP is specified for a NUL-terminated character
string in C, the length of the C declaration will be reduced by one.
Precompiler rules: The following situations result
in an error message during precompile:
- A reference is made to a variable that does not exist.
- A reference is made to a numeric variable.
- A reference is made to a variable that has been referred to already.
- A reference is made to a variable that is not unique.
- The DECLARE VARIABLE statement occurs after an SQL statement where the
SQL statement and the DECLARE VARIABLE statement refer to the same variable.
- The FOR BIT DATA, FOR SBCS DATA, or FOR MIXED DATA clause is specified
for a graphic host variable.
- A SBCS or mixed CCSID is specified for a graphic host variable.
- A DBCS, UTF-16, or UCS-2 CCSID is specified for a character host variable.
- DATE, TIME, or TIMESTAMP is specified for a host variable that is not
character.
- The length of a host variable used for DATE, TIME, or TIMESTAMP is not
long enough for the minimum date, time, or timestamp value.
(C) Copyright IBM Corporation 1992, 2006. All Rights Reserved.