FIX: SQLPrepare() Returns Incorrect Error on FOR UPDATE

Last reviewed: May 1, 1997
Article ID: Q135839

The information in this article applies to:
  • Microsoft SQL Server, version 6.0
  • Microsoft Open Data Base Connectivity, version 2.5
BUG#: 11019 (6.00)

SYMPTOMS

When you use the ODBC SQL Server driver in conjunction with Microsoft SQL Server version 6.0 server-side cursors to attempt the creation of an updateable rowset via SQLPrepare(), the FOR UPDATE portion of the SELECT statement returns an incorrect error message.

WORKAROUND

If you do not need to use SQLPrepare() to create your updateable rowset, then you should use SQLExecDirect() to achieve this functionality.

Otherwise, the same functionality can be accomplished by excluding the FOR UPDATE portion of the SELECT statement from the string passed to SQLPrepare(). When this query has been prepared, the rowset may still be operated on with modification operations using SQLExtendedFetch() and SQLSetPos().

STATUS

Microsoft has confirmed this to be a problem in the ODBC SQL Server Driver version 2.50.0121. This problem has been corrected in the ODBC SQL Server Driver version 2.65.0201. For more information, contact your primary support provider.

MORE INFORMATION

For example, with the SQLSetStmtOption() settings made to invoke server side cursor usage (as defined in SQL Books Online under the ODBC SQL Server Driver section headings "Using ODBC Cursors" and "Creating Cursors") the statement:

   Select * from <table_name> for update

returns the following incorrect error message:

   Return Code = SQL_ERROR = -1
   szSqlState = "37000"
   *pfNativeError = 1003
   *pcbErrorMsg = 105
   szErrorMsg="[Microsoft][ODBC SQL Server Driver][SQL Server]Line 1:
   FOR UPDATE clause allowed only for DECLARE CURSOR."


Additional query words: sql6
Keywords : kbbug2.50.0121 kbbug6.00 kbprg SSrvProg kbprg
Version : 2.5.0121 6.0
Platform : WINDOWS


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: May 1, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.