If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > DB2 + C; embedded SQL

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-03-06, 09:29
wjgrafton wjgrafton is offline
Registered User
 
Join Date: Jul 2006
Posts: 1
Question DB2 + C; embedded SQL

I have a rather simple question I need answered...I hope.

When declaring and using a cursor in embedded SQL in C code, being used against DB2:

The proper sequence of events for Cursor...Select...For Update:

Should these be:

1) Declare the cursor with the select for update.
2) Open the cursor
3) Fetch cursor into variable
4) Update the record...Where Current Of cursor
5) DB Commit
6) Close the cursor

The concern I have are the last 2. If a close cuirsor happens before the commit, or vice versa:

1) will either way work?
2) will one or the other result in record locks being left hanging on the table?

We are running into a problem where 2 separate applications are accessing the same table, the same record, on occasion, creating -911 reponse.

Thanking you for your input in advance.

Jeff
Reply With Quote
  #2 (permalink)  
Old 07-03-06, 10:43
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
When a commit is issued, the cursor is automatically closed, unless you declare the cursor the cursor using the WITH HOLD option.

Locks are not released until a commit (or rollback) is issued.

In your situtation where you are getting 911's, I would declare the cursor using the WITH HOLD option, and commit after each update, and then close the cursor at the very end.
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On