in reply to FreeTDS (Linux) vs. SQLSRV32.dll (Windows) via ODBC

At the very least this is a bug in freeTDS since the error message is wrong. IF there were more rows to fetch on the first statement handle then the error should be something like cannot use multiple active statements. Also the erroneous invalid cursor state is on the execute of the second statement which also makes no sense.

DBD::ODBC will close the cursor when finish is called or when a fetch returns SQL_NO_DATA or when the statement handle goes out of scope. Your example does not fetch after the first row so it does not know to call SQLCloseCursor, you do not call finish and the statement handle does not go out of scope.

The SQL Server ODBC driver knows the result-set is finished, presumably, because it received a TDS done packet.

Other than freeTDS I do not know of any ODBC driver which would not work with your example.

  • Comment on Re: FreeTDS (Linux) vs. SQLSRV32.dll (Windows) via ODBC