Unix Technical Forum

firehose cursor, SQLPrepare, SQL_ATTR_ROW_ARRAY_SIZE > 1

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) ...


Go Back   Unix Technical Forum > Database Server Software > Microsoft SQL Server > MS SQL ODBC

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-27-2008, 09:20 PM
=?Utf-8?B?QW5kcmV3?=
 
Posts: n/a
Default firehose cursor, SQLPrepare, SQL_ATTR_ROW_ARRAY_SIZE > 1

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?

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 02:40 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com