This script demonstrates the problem:
When you run this statement in ISQL:
You get a dialog box entitled "Interactive SQL" saying: The following error occured while fetching results: Wrong number of parameters to function 'Needs2Parameters' SQLCODE=-154, ODBC 3 State="42000".
Fair enough, except that you also get a result set looking like this:
note that the first line is missing. With an ODBC client it's even odder, you don't get an error, and the first line consists of random data from a buffer (it's often recognisable as something you selected recently), then you get the remainder of the result set seen in ISQL.
If the function is a built in one, eg
Then you get a different dialog box, enttled "ISQL Error", Could not execute statement. Wrong number of parameters ...... In this case you get no result set.
The same behaviour is seen in v9.0.2
asked 18 Aug '10, 13:22
For a 10.0 server, a warning (SQL_SUCCESS_WITH_INFO) occurs in SQLFetch:
  [SAP][ODBC Driver][SQL Anywhere]Wrong number of parameters to function 'Needs2Parameters', result rows=8, error in row=1
In my test ODBC app I use a row status array, something like this...
You see the following results (status, column values).
Looks like the 10.0 server produces all rows of the rowset, with no values set for the first row, and valid column values for somestuff and SQL_NULL_DATA for Needs2Parameters(13) in the remaining rows. SQL_ROW_ERROR indicates that the columns values in the first row should be ignored (nothing was written to memory).
For an 11.0 server, an error (SQL_ERROR) occurs in SQLFetch and no fetching is done.
For a 16.0 server, an error (SQL_ERROR) results in SQLExecDirect and no fetching is done.
answered 06 Jan '15, 10:58