Cursor position before and after the Fetch statement

IBM's flagship relational database management system

Cursor position before and after the Fetch statement

Postby kapilarora4 » Sun Jul 20, 2014 2:22 am


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,

** 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.
Posts: 1
Joined: Sun Jul 20, 2014 2:10 am
Has thanked: 0 time
Been thanked: 0 time

Re: Cursor position before and after the Fetch statement

Postby enrico-sorichetti » Sun Jul 20, 2014 6:36 pm

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
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
Global moderator
Posts: 2999
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 164 times

Re: Cursor position before and after the Fetch statement

Postby NicC » Mon Jul 21, 2014 6:00 pm

'fired'? No such thing - statements are executed.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Global moderator
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

Return to DB2


  • Related topics
    Last post