SQLCODE -206 returned on the BIND of a statement in a COBOL program.
SQLCODE -206 returned on the BIND of a statement in a COBOL program. The statement executes okay from SPUFI. All columns names referenced in the SQL statement exist in the table. The tablespace the table is in is not in any PENDING status.
This indicates a problem with the delimiters within SQL statements defined -- the delimiter for a character string literal versus the escape character used to delimit a column name.
Check whether the QUOTESQL or APOSTSQL precompiler options were specified, and the setting for SQLDELI in your DSNHDECP.
Here is an example of an SQL statement in the COBOL application program:
SET STATUSCD = 'C'
WHERE STATUSCD = 'W'
Here is the error message from the BIND output:
DSNX105I -DB2P BIND SQL WARNING
USING CON01 AUTHORITY
Note: The message token is W. DB2 thinks what you have in single quotes is a column name. You did not specify either the QUOTESQL or the APOSTSQL precompiler option. When those are not provided, SQLDELI from your DSNHDECP is used. If SQLDELI is DEFAULT or QUOTE, then the double quote is used as the delimiter for character strings within SQL statements, and the single quote is used as the escape character for column names, as in this example.
As to why the SPUFI behavior is different from the COBOL behavior, the SQL Reference says:
In a non-COBOL program, the string delimiter is the apostrophe, and the escape character is the quotation mark.
The APOST/QUOTE precompiler options and the DELIM setting in the DECP are used only to determine the character string delimiter for host language statements (not for embedded SQL statements in a host program). The options that are important for the example above are the APOSTSQL/QUOTESQL precompiler options and the SQLDELI setting in DSNHDECP, since the statement is an SQL statement.
In an COBOL program, for example:
01 X1 PIC X(10) DISPLAY VALUE "ABC". <-- APOST/QUOTE/DELIM control which character is used to delimit this character string in a host language statement. In this example, the double quote is the delimiter for character strings WITHIN HOST LANGUAGE STATEMENTS.
EXEC SQL INSERT INTO T1 ('HOURS') VALUES ("ABC") END-EXEC. <-- APOSTSQL/QUOTESQL/SQLDELI control which character is used to delimit character strings in an SQL statement, and the other character is used as the escape character (so you can use reserved words as identifiers). In this example, the single quote is the escape character, and the double quote is the delimiter for character strings WITHIN SQL STATEMENTS.