This is a discussion on firehose cursor, SQLPrepare, SQL_ATTR_ROW_ARRAY_SIZE > 1 within the MS SQL ODBC forums, part of the Microsoft SQL Server category; --> Does anyone know if it's possible to combine: a. A SQL Server firehose (default) cursor b. Prepared execution (SQLPrepare) ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Does anyone know if it's possible to combine: a. A SQL Server firehose (default) cursor b. Prepared execution (SQLPrepare) c. Rowset > 1 e.g. (pseudo code) 1. Create & allocate ODBC statement handle 2. Set fetch rows > 1 (SQLSetStmtAttr, SQL_ATTR_ROW_ARRAY_SIZE) 3. Prepare statement (SQLPrepare) 4. While (some condition) 5. Execute statement (SQLExecute) 6. Fetch Rows (SQLFetchScroll) 7. Close Cursor 8. end while When I try this, the first iteration of step 5 changes the cursor to a dynamic server side cursor. This is a huge performance hit for my app as it only fecthes small numbers of rows (<500). So I changed to: 1. Create & allocate ODBC statement handle 2. Prepare statement (SQLPrepare) 3. While (some condition) 4. Execute statement (SQLExecute) 5. Set fetch rows > 1 (SQLSetStmtAttr, SQL_ATTR_ROW_ARRAY_SIZE) 6. Fetch Rows (SQLFetchScroll) 7. Close Cursor 8. end while Now the second iteration of step 4 changes the cursor type. Same problem as before. So I tried: 1. Create & allocate ODBC statement handle 2. Prepare statement (SQLPrepare) 3. While (some condition) 4. Set fetch rows to 1 (SQLSetStmtAttr, SQL_ATTR_ROW_ARRAY_SIZE) 5. Execute statement (SQLExecute) 6. Set fetch rows > 1 (SQLSetStmtAttr, SQL_ATTR_ROW_ARRAY_SIZE) 7. Fetch Rows (SQLFetchScroll) 8. Close Cursor 9. end while Now every call to SQLExecute() unprepares, prepares & executes the SQL statement! (I can see this happening in the SQL Server Profiler). Another performance hit! Is there a way to use the default cursor type with prepared execution AND a rowset > 1? |