Page 1 of 1

Cursor position before and after the Fetch statement

PostPosted: Sun Jul 20, 2014 2:22 am
by kapilarora4
Hi,

In embedded SQL, What is the position of the cursor before the first FETCH statement is fired.

I read two different concepts don't know which one is true.

1. When Fetch statement is fired, first the cursor is brought to the position to next record. Then the record is moved to Host variables. And the cursor point to this record only before the next fetch statment is fired.

2. When the fetch statement is fired, the cursor fetches the current record to host variables and moves to point to next record.

I am not sure which one is true and tried searching it on the IBM official site which validates the first statement above. But will this hurt at all, knowing how actually the cursor is behaving? Both ways we will get the same record to host variables. Any suggestion will be really helpful in clearing my idea of Cursor ind COBOL DB2 programs.

Many Thanks,
Kapil

** Sorry if the topic is already discussed, I tried but could not find it here, so had to post a new one. Please point me to the same, just in case.

Re: Cursor position before and after the Fetch statement

PostPosted: Sun Jul 20, 2014 6:36 pm
by enrico-sorichetti
a bit of logic should have hinted that option 1 is the right answer.

if the cursor had moved to point to the next row
how would You issue a delete where current of

Re: Cursor position before and after the Fetch statement

PostPosted: Mon Jul 21, 2014 6:00 pm
by NicC
'fired'? No such thing - statements are executed.