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

CURSOR with FOR READ ONLY


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

Active User


Joined: 17 Nov 2009
Posts: 129
Location: India

PostPosted: Thu Nov 29, 2012 3:50 pm
Reply with quote

Hi

I have a query.
If a DB2 cursor is declared with "FOR read only" and commit is performed in between the process, will it close the cursor.


Thanks
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Thu Nov 29, 2012 4:34 pm
Reply with quote

Is this a Interview question and what happen when you tried?
Back to top
View user's profile Send private message
sushanth bobby

Senior Member


Joined: 29 Jul 2008
Posts: 1020
Location: India

PostPosted: Thu Nov 29, 2012 5:04 pm
Reply with quote

Susanta,

Yes.

If the cursor is declared using WITH HOLD, it will not be closed during commit.

Thanks,
sushanth
Back to top
View user's profile Send private message
Susanta

Active User


Joined: 17 Nov 2009
Posts: 129
Location: India

PostPosted: Thu Nov 29, 2012 5:57 pm
Reply with quote

HI all,


I have seen a program already running fine in production , Which uses "FOR read only" in the cursor declaration. It also performs COMMIT each time it finishes processing 10,000 rows . But cursor not getting closed by the COMMIT.

I used to know for declare cursors we need to mention "WITH HOLD" if we want to perform COMMIT in between . thats why i got above doubt.

icon_sad.gif

Thanks
Back to top
View user's profile Send private message
Susanta

Active User


Joined: 17 Nov 2009
Posts: 129
Location: India

PostPosted: Fri Nov 30, 2012 1:12 pm
Reply with quote

Apologies ..........

I dint observed earlier .. the declaration has "WITH HOLD" mentioned at the top.

Code:
EXEC SQL
   DECLARE MyCursor CURSOR WITH HOLD FOR
   SELECT......
   ..........
   ..........
   ..........
   FOR READ ONLY
END-EXEC
Back to top
View user's profile Send private message
View previous topic : : View next topic  
Post new topic   Reply to topic All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Trouble using REXX SDSF interface to ... CLIST & REXX 3
No new posts Rexx to read current Panvalet editor/... CLIST & REXX 0
No new posts Inserting into table while open selec... DB2 1
No new posts Error to read log with rexx CLIST & REXX 11
No new posts Random read in ESDS file by using RBA JCL & VSAM 6
Search our Forums:


Back to Top