Skip to main content

Problem:

  I am getting the following error message when using the CHAR function against a DB2 UDB 8.0 database when a host variable is used using ODBC interface.

The error message I am getting is

SQLCODE = -418

SQLERRM = The statement contains the use of parameter marker that is not valid

Given below is a code snippet and compiler directives.

EXEC SQL                                                  

   SELECT CHAR(DATE(:wsdate1),ISO)                   

   INTO :wsdate2                           

   FROM table1                                  

END-EXEC   

Compiler Directives:

SQL(DBMAN=ODBC) SQL(DB2)

Resolution:

This appears to be a DB2 limitation, same error is produced with a simple select on a character field select :field1 into :field2 from table. Appears that DB2 does not allow the use of host variables in a select list .

SQL Server does not have the same problem-

following worked fine

        EXEC SQL

               SELECT convert(char(26),:wsdate1,101)

               INTO :wsdate2

               FROM table1

        END-EXEC

Old KB# 3837