PRB: Update or Delete Record Gives Error: Query is too complexLast reviewed: July 31, 1997Article ID: Q125651 |
1.50 1.51 1.52 | 2.00 2.10 4.00 4.10
WINDOWS | WINDOWS NTkbprg kbprb The information in this article applies to:
SYMPTOMSWhen trying to update or delete a record of a CRecordset object, the following message occurs:
CAUSEThe error occurs when the cursor library is loaded and the recordset retrieved by the CRecordset is opened as a snapshot object that contains more than 40 bound columns. By default, the cursor library is loaded when a CRecordset is opened. MFC snapshots perform positioned updates and deletes by using the ODBC SQL WHERE CURRENT OF syntax. The cursor library changes the WHERE CURRENT OF clause to a full WHERE clause using all the columns in the recordset. For example, the MFC Database classes might create the following SQL statement when updating a record:
Update table1 SET column1=? WHERE CURRENT OF XXXXXThe cursor library knows which record the application is currently positioned at and converts the WHERE CURRENT OF clause into a WHERE clause that will update the current record only. For example, assume the recordset has three columns. The cursor library changes the SQL statement to:
Update table1 SET column1=? WHERE column1=<current value> AND column2=<current value> AND column3 =<current value>Here <current value> represents the value of that column before the update is performed. You can see that more than 40 columns in a CRecordset will cause more than 40 AND predicates in the WHERE clause. The helpfile for the ODBC desktop drivers (ODBCJET.HLP) states in the SQL limitations section that no more than 40 AND predicates are supported. Thus, the SQL statement is too complex. NOTE: Long binary columns (those using RFX_LongBinary) are not bound and do not count against the 40-column limit. However, an MFC ODBC application that references the RFX_LongBinary function may encounter this error when the recordset is opened. This is because the cursor library precedes calls to SQLGetData with the execution of a SELECT statement with a WHERE clause as described above.
RESOLUTIONTo work around this behavior, do one of the following:
STATUSThis behavior is by design.
REFERENCESAppendix G of the ODBC 2.0 Programmer's Reference contains information about the cursor library. The ODBC Programmer's Reference is available in the onine books for Visual C++ version 2.0 or greater. MFC TechNote #45 contains additional information about MFC support for long binary data and the use of RFX_LongBinary.
|
Additional reference words: 1.50 2.00 2.10 2.50 2.51 2.52 3.00 3.10 4.00
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |