Cursor position before and after the Fetch statement

IBM's flagship relational database management system
kapilarora4
Posts: 1
Joined: Sun Jul 20, 2014 2:10 am
Skillset: Mainframe,Cobol,DB2,JCL
Referer: Internet

Cursor position before and after the Fetch statement

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

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.

enrico-sorichetti
Global moderator
Posts: 3006
Joined: Fri Apr 18, 2008 11:25 pm
Skillset: tso,rexx,assembler,pl/i,storage,mvs,os/390,z/os,
Referer: www.ibmmainframes.com

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
cheers
enrico
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

NicC
Global moderator
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Skillset: JCL, PL/1, Rexx, Utilities and to a lesser extent (i.e. I have programmed using them) COBOL,DB2,IMS
Referer: Google
Location: Pushing up the daisies (almost)

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.
Regards
Nic


  • Similar Topics
    Replies
    Views
    Last post