Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What is a cursor?

Status
Not open for further replies.

MikeMcKeown

Programmer
Apr 1, 2003
69
GB
Hello, I'm trying to write a Cobol II program with DB2 to read a few tables, select values from them (i.e. the max / min / most recent) and store them for later use in variables.

Apart from the most recent, I've got a fairly good handle on what SQL is required but in all the other Cobol II programs with DB2 I've seen a cursor has been used, but I can't figure out the purpose of a cursor. Do I need to use cursors for this type of program? If so could someone give me a quick overview please?

Many thanks in advance,

Mike McKeown

 
Mike,
You use a cursor if you are expecting back more than one row, otherwise you use a singleton select.

You'll need to add logic to OPEN the cursor for processing, loop round obtaining (FETCH) each row, and finally on hitting the end of the data, CLOSE the cursor behind you.

Hope this helps.
Marc
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top