IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Regarding cursor status.


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
stly
Warnings : 1

New User


Joined: 25 Jul 2005
Posts: 93

PostPosted: Thu May 22, 2008 11:13 am
Reply with quote

I have a read onlycursor.
After fetching the record i have to update another table.After updating the record i do not have any commit statement.Di it will effect the cursor.I mean the cursor will be closed or will be in normal state.
I mean do i need to declare cursor with hold option.
Back to top
View user's profile Send private message
the_gautam

Active User


Joined: 05 Jun 2005
Posts: 165
Location: Bangalore

PostPosted: Thu May 22, 2008 11:19 am
Reply with quote

If you are not committing the Cursor1 and you are updating a table which is not related to Cursor1 then, i dont see any need of declaring the Cursor1 with HOLD option.
Back to top
View user's profile Send private message
stly
Warnings : 1

New User


Joined: 25 Jul 2005
Posts: 93

PostPosted: Thu May 22, 2008 11:45 am
Reply with quote

the_gautam wrote:
If you are not committing the Cursor1 and you are updating a table which is not related to Cursor1 then, i dont see any need of declaring the Cursor1 with HOLD option.


U mean that After Update if do not give commit then No need to declare teh cursor with hold option.

Suppose in taht case if any abend occured during the cursor process u mena that all the updated records are rolled back..
Back to top
View user's profile Send private message
the_gautam

Active User


Joined: 05 Jun 2005
Posts: 165
Location: Bangalore

PostPosted: Thu May 22, 2008 12:10 pm
Reply with quote

After reading your post, i thought you are talking about 2 different tables. Table1 is updated and the cursor is declared for Table2. thats why i said that the cursor for table2 has nothing to do with table1.
Back to top
View user's profile Send private message
vasanthkumarhb

Active User


Joined: 06 Sep 2007
Posts: 275
Location: Bang,iflex

PostPosted: Thu May 22, 2008 12:32 pm
Reply with quote

Hi,

Adding to Gautam post,

you are post is little bit confusing, see you are fetching read only table and move to the respective host variables and updating the another table.

Cursor can be declared for one table not for multiple tables at a time, you can update another table with out any worry, if you want to use with hold option you can use, it just keeps cursor to be opened after close cursor command.

But after close cursor command all the change made to table is committed.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu May 22, 2008 1:38 pm
Reply with quote

So as not to flame anyone directly:

CURSORs can be based on one table, two,3 or many. The same limit of number of tables referenced in a select statement is also applied to a cursor. You can not define an UPDATE cursor with and explicit or implicit JOIN.

A COMMIT affects every table in your Unit-of-Work.

If you issue COMMITs while using a CURSOR (and one should if the cursor will be large - more than several thousand rows), you need to use the WITH HOLD option, to prevent the cursor from closing at COMMIT.

ONLY a COMMIT can make changes permanent. CLOSEing a CURSOR only releases the result table, has no affect on db2's decision to make changes permenant or not.
Back to top
View user's profile Send private message
stly
Warnings : 1

New User


Joined: 25 Jul 2005
Posts: 93

PostPosted: Thu May 22, 2008 4:06 pm
Reply with quote

Actually my doubt is when the records will be committed if i do not specify anf commit.
ie after the update statement or after closing the cursor.
Back to top
View user's profile Send private message
stly
Warnings : 1

New User


Joined: 25 Jul 2005
Posts: 93

PostPosted: Thu May 22, 2008 6:40 pm
Reply with quote

Can any one throw some lite on this..
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu May 22, 2008 6:44 pm
Reply with quote

stly,

first of all, records have nothing to do with DB2 - rows.

and it is light not lite.


second, if you do not have an explicit COMMIT in your run-unit, then MVS will cause db2 to be called at successful eoj and db2 will issue a commit.
Back to top
View user's profile Send private message
stly
Warnings : 1

New User


Joined: 25 Jul 2005
Posts: 93

PostPosted: Fri May 23, 2008 1:50 pm
Reply with quote

dbzTHEdinosauer wrote:
stly,

first of all, records have nothing to do with DB2 - rows.

and it is light not lite.


second, if you do not have an explicit COMMIT in your run-unit, then MVS will cause db2 to be called at successful eoj and db2 will issue a commit.


Thanks Dick.... thanks for correction also icon_biggrin.gif
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Job completes in JES, but the status ... IBM Tools 1
No new posts File Status 04 COBOL Programming 3
No new posts RABBIT HOLE NEEDED - "Live"... All Other Mainframe Topics 0
No new posts DL/I status code AK for GU call using... IMS DB/DC 1
No new posts File Status Error code 39 when Proces... COBOL Programming 2
Search our Forums:

Back to Top