Hi

On refactoring some code from normal statement to using parameters
SQLSetNextParameter, SQLPrepare, SQLExecute

I start getting the error "HY010 (-99999)--[IBM][CLI Driver] CLI0125E Function sequence error. SQLSTATE=HY010 Connection handle = 91, Statement handle = 96, Source = DB2_DRV.ESQL.SetupStatementInfo"
The frustrating thing is that this is about 1 in 20 times only.

I wonder if this is linked to this DB2 documentation:
SQL_ATTR_ASYNC_ENABLEA 32-bit integer value that specifies whether a function called with the specified statement is executed asynchronously:
  • SQL_ASYNC_ENABLE_OFF = Off (the default)
  • SQL_ASYNC_ENABLE_ON = On

After a function has been called asynchronously, only the original function, SQLAllocHandle(), SQLCancel(), SQLSetStmtAttr(), SQLGetDiagField(), SQLGetDiagRec(), or SQLGetFunctions() can be called on the statement handle, until the original function returns a code other than SQL_STILL_EXECUTING. Any other function called on any other statement handle under the same connection returns SQL_ERROR with an SQLSTATE of HY010 (Function sequence error).Because CLI supports statement level asynchronous-execution, the statement attribute SQL_ATTR_ASYNC_ENABLE can be set. Its initial value is the same as the value of the connection level attribute with the same name at the time the statement handle was allocated.
https://www.ibm.com/support/knowledg.../r0006814.html

Does the driver tests/sets this?

Kind regards
Marco