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

inserting a row after reading from CURSOR


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

New User


Joined: 10 Mar 2005
Posts: 81

PostPosted: Wed Jun 22, 2005 3:46 pm
Reply with quote

I have a cursor.say TEST_CUR, to select some rows from a table.
Let's say the cursor returns me 3 rows.
Now, after i FETCH from it the first time ,i am inserting the same row into another table.
After this, on FETCHing the 2nd time from TEST_CUR, the query is executed again and i get the same set of rows with the pointer set to 1st row.

Does that mean INSERT operation is causing some problem to the CURSOR.
Back to top
View user's profile Send private message
Pushpak

New User


Joined: 06 May 2005
Posts: 18

PostPosted: Wed Jun 22, 2005 5:27 pm
Reply with quote

Hi,

INSERT will never cause your CURSOR activities. This is very common approach, fetch a record & do the updations on the basis of fetched results.

In your case, are you closing a cursor after reading first record, inserting into the different table and before reading a next record.

Pushpak.
Back to top
View user's profile Send private message
kalukakkad

New User


Joined: 10 Mar 2005
Posts: 81

PostPosted: Thu Jun 23, 2005 8:58 am
Reply with quote

Thanks for the reply.
But the current situation is :

I have a cursor.say TEST_CUR, to select some rows from a table.
Let's say the cursor returns me 3 rows.
Now, after i FETCH from it the first time: i do 2 things

1)update some columns of the row fetched
2)and insert the same row into another table.

The cursor is FETCH ONLY as it has joins so can't use FOR UPDATE.

After this, on FETCHing the 2nd time from TEST_CUR, the query is executed again and i get the same set of rows with the pointer set to 1st row.

Is updating the row causing the problem....problem with locs?
Back to top
View user's profile Send private message
EnjoyMF

New User


Joined: 27 May 2005
Posts: 88

PostPosted: Fri Jun 24, 2005 12:35 pm
Reply with quote

hi friend

use static cursor...
Back to top
View user's profile Send private message
j_prameela2000

New User


Joined: 01 Jun 2005
Posts: 28
Location: Chennai

PostPosted: Fri Jun 24, 2005 6:02 pm
Reply with quote

Hi,

I hope the cursor should be declared with Update option and in the Update statement we must mention where current of. If I am wrong, please correct me.
Back to top
View user's profile Send private message
khamarutheen

Active Member


Joined: 23 Aug 2005
Posts: 677
Location: NJ

PostPosted: Thu Nov 03, 2005 2:32 pm
Reply with quote

hi frnd,
use this
EXEC SQL
DECLARE C1 CURSOR FOR
SELECT...
FOR UPDATE ....
END-EXEC

hope this works
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 Reading dataset in Python - New Line ... All Other Mainframe Topics 22
No new posts Find the size of a PS file before rea... COBOL Programming 13
No new posts Inserting variable length into output... JCL & VSAM 2
No new posts Inserting records in a file on a valu... DFSORT/ICETOOL 18
No new posts Rexx program reading a DSN then write... CLIST & REXX 4
Search our Forums:

Back to Top