This was first reported to us by a customer using Perl, but it is not Perl-related. It seems to be SQL Server 7 specific. If you call SQLDescribeParam
after preparing a parameterised insert with invalid SQL, Microsoft's SQL Server ODBC driver does not appear to return from the SQLDescribeParam
call. For example:
INSERT INTO table VALUES (column1, column2) (?,?)
is incorrect as VALUES
should come after the column names.
The sequence of ODBC calls is:
SQLPrepare("insert into table values (column1, column2) (?,?)") SQLNumParams() returns 2 correctly SQLDescribeParam(1) hangs never returning
It seems that the SQL Server ODBC driver rearranges the SQL. The driver executes a SELECT
statement on the table for the specified columns so it can find out column information to be returned as parameter information. If the SQL is invalid, this process fails and the INSERT
hangs.