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

Inserting into table while open select cursor still active


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

New User


Joined: 18 Mar 2024
Posts: 6
Location: United States

PostPosted: Fri May 17, 2024 11:37 pm
Reply with quote

(Not sure how relevant this is, but this question is about embedded DB2 in a COBOL program)

I've been told by a senior member that you cannot insert a row into a table where you currently have an open select cursor to. I'm not inclined to doubt them, however I couldn't find any information supporting this.

Is it true you cannot insert into a table when you already have a cursor opened reading the table? Or is it bad practice? Or is it totally fine?

Additionally, assuming it is fine, could the newly inserted row be retrieved using the cursor? Would a commit be required beforehand?
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3075
Location: NYC,USA

PostPosted: Sun May 19, 2024 1:29 am
Reply with quote

Welcome !

The best way to know is to test with different scenarios but ..
you should not be having issues inserting into the the table and also you will see updated row if that qualifies the criteria in the fetch.

If you don’t need inserted row to be part of the fetch or need to have optimized procedures then load the cursor data into temp table or an array and then have another loop just for insert from that.. that will ensure you are not getting into infinite loop situation.
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 MF professionals open positions Mainframe Jobs 0
No new posts Unload and Load ISPF Table TSO/ISPF 4
No new posts ISPF Table to add a new column TSO/ISPF 1
No new posts Load new table with Old unload - DB2 DB2 6
No new posts Pulling a fixed number of records fro... DB2 2
Search our Forums:

Back to Top