Informix Dynamic SQL Format 2 returning -201: A syntax error has occurred

Symptom

After successfully connecting to an Informix 11.7 database using the I10 driver, a SQL statement in the dynamic SQL format 2 is executed and returns the following error:

sql error -201: A syntax error has occurred

The embedded SQL uses an argument and it appears that the argument value is not replacing the placeholder ('?') in the SQL.

Environment

PowerBuilder, Informix

Reproducing the Issue

1.  In PowerBuilder, use an existing application that connects to an I10 Informix database.

2.  Use the following embedded SQL script:

                   int wait_var = 5
  PREPARE SQLSA
  FROM "SET LOCK MODE to WAIT ?" ;
  EXECUTE SQLSQ using :wait_var;
  if sqlca.sqlcode <> 0 then
              messagebox("SQL Error", sqlca.sqlerrtext)
  end if

3. The script will return a SQL error of: -201 - A syntax error has occurred

Cause

Engineering found that Informix is unable to accept bind variables (arguments with '?' place holder) in certain complex places.

Solution

Use the dbparm of DisableBind=1. DisableBind is dynamic so you can set it to 1 for certain transactions and then set it to 0 afterwards.