Unix Technical Forum

Strange Cursor Close Problem

This is a discussion on Strange Cursor Close Problem within the MS SQL ODBC forums, part of the Microsoft SQL Server category; --> I used the below code to fill the table using BulkOperations (abbrev.) After finishing it, the table is filled ...


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
M. Eckstein
 
Posts: n/a
Default Strange Cursor Close Problem


I used the below code to fill the table using BulkOperations (abbrev.)
After finishing it, the table is filled with all values, BUT the cursor
still
hangs (as seen in the Enterprise manager) and blocks the next created
cursor, so the deadlock arises and the program freezes.

What am I doing wrong?
Thanks for your answers in advance, Michael

#define MAX_STRUCT 1

struct InsCard {
unsigned long ID_IMPORTU;
long i1;
};

InsCard* ICStruct;
ICStruct = (InsCard*)malloc(MAX_STRUCT*sizeof(InsCard));

SQLAllocStmt( hdbc, &hstmt);
SQLSetStmtAttr(hstmt, SQL_ATTR_ROW_ARRAY_SIZE, (void*)MAX_STRUCT, 0);
SQLSetStmtAttr(hstmt, SQL_ATTR_CONCURRENCY,(void*)SQL_CONCUR_VALUES,0);
SQLSetStmtAttr(hstmt, SQL_ATTR_CURSOR_TYPE,
(void*)SQL_CURSOR_KEYSET_DRIVEN, 0);
SQLSetStmtAttr(hstmt, SQL_ATTR_ROW_BIND_TYPE, (void*)sizeof(InsCard), 0);

SQLBindCol(stmtSel, 1, SQL_C_ULONG, &ICStruct[0].ID_IMPORTU, 0,
&ICStruct[0].i1);
ICStruct[0].i2=0;
SQLExecDirect(stmtSel, (UCHAR*)sql, SQL_NTS);

ICStruct[0].ID_IMPORTU =1;
ICStruct[0].i1 =0;
int currentrow=1;

SQLSetStmtAttr(hstmt, SQL_ATTR_ROW_ARRAY_SIZE, (void*)currentrow, 0);
SQLBulkOperations(hstmt, SQL_ADD);

free(ICStruct);
SQLCloseCursor(hstmt);
SQLCancel(hstmt);
SQLFreeStmt(hstmt, SQL_DROP);


P.S.
The presence or absence of SQLCloseCursor(hstmt) and/or SQLCancel(hstmt)
is
not affecting the deadlock by any way.


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 10:21 AM.


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