DSNH312I E csect-name LINE line-number COL column-number UNDEFINED OR UNUSABLE HOST VARIABLE variable-name

Explanation

A problem occurred with the specified variable in an SQL statement. Either no declaration was found in the application program before the statement, or the attributes of the variable are improper for the intended use.

csect-name
The name of the control section that issued the message.
line-number
The line number in the source code of the application program.
column-number
The numeric representation of the column. The first column is identified as column 1, the second as column 2, and so on.
variable-name
The name of the variable that caused the error.

This message is issued only at reference time.

System action

If the SQL statement that contains the variable is a declaration, it is discarded.

If the SQL statement that contains the variable is executable, it is replaced by host language statements that, if executed, set an error code in the SQLCA.

User response

Check the declaration and the attributes of the named host variable. If you intended the name to refer to a column, the colon (:) must not be present. If you intended a literal, enclose the value in string delimiters (apostrophes or quotation marks).

If you intended to use a host variable, only a subset of the possible variable declarations are valid for use as a Db2 host variable. See the information about rules for host variables in an SQL statement.

To determine the source of the problem, use the cross-reference listing and the source listing to determine whether any of the following situations apply:

  • If you use the STDSQL(YES) SQL processing option, make sure that all of the host variable declarations are declared within the BEGIN DECLARE SECTION and the END DECLARE SECTION.
  • If the cross-reference listing does not contain the host variable name, the declaration is missing. If the source for a declaration is present, a missing terminator from a comment or from a string might cause this type of error. The margin settings might also cause this type of error.
  • If the name is present, but the data type is not listed, the host variable is not usable; it does not follow the rules for valid host variable definitions.
  • If several definitions exist for the name, the first reference might occur before the definition. In this situation, the TWOPASS SQL processing option helps by processing DECLARE statements before the other types of statements. However, host variable declarations and cursor declarations are processed in the same pass. The host variables that are referenced in cursor declarations must be defined before the cursor is defined in the application program. This rule applies regardless of whether the ONEPASS or TWOPASS SQL processing option is used.
  • A parameter marker is expected rather than a host variable in an EXECUTE IMMEDIATE statement.
  • The data type of a host variable that is passed in a CALL statement is not CHAR or VARCHAR.
  • The length attribute of a CHAR or VARCHAR host variable that is passed in a CALL statement exceeds 255 characters.
  • If you are using the precompiler for COBOL, check whether the named host variable is declared in a structure that contains FILLER elements. The FILLER elements might invalidate the variables in the structure.

Severity

8 (error)