问题
The problem
During a very simple insert query, using PDO with an ODBC driver for a DB2 database, the driver returns the following error:
SQLSTATE[HY010]: Function sequence error: 0 [Microsoft][Driver Manager ODBC] [italian message translation] (SQLExecute[0] at ext\pdo_odbc\odbc_stmt.c:254)
The query itself is a prepared statement insert, with strings and dates. [italian message translation] just says "Function sequence error" in italian.
The research
This SO question reports the same problem, but occurred during a SELECT query, which is not my case This PHP bug report reports the same problem, but I've determined that's not my case either.
The question
Why does a simple insert cause a function sequence error with SQLSTATE[HY010]?
回答1:
Reading from the PHP bug report, users have reported that the issue is related to the format of the date being inserted, because (in that particular case) it was missing some digits from the months number.
That made me think: maybe the length of some input data was incompatible with the table column. In fact, I was writing 80 characters where only 60 could fit.
The solution
Check your input values: length, format and type. One of these may be incompatible with the column you're writing into. I'd expect a different message from the driver to be honest (data truncated in my case), because the problem isn't too hard to solve if you have better information.
As soon as I reduced the input length below the maximum value allowed, the query executed successfully
来源:https://stackoverflow.com/questions/27268959/sqlstatehy010-function-sequence-error-0-during-insert