Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

DB2 cursor

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
l.nethaji

New User


Joined: 16 Mar 2008
Posts: 90
Location: tamil nadu

PostPosted: Fri Jan 08, 2010 5:17 pm    Post subject: DB2 cursor
Reply with quote

Hi,

We declare cursor in Cobol -db2 program . we open fetch and close the cursor

At which process the data is fetched from the table .

for ex: select a,b from Table t where c >10

Whether the value is fetched from table T while declaring or while opening or while fetching it .
Please help

Thanks,
L.nethaji
Back to top
View user's profile Send private message

dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6968
Location: porcelain throne

PostPosted: Fri Jan 08, 2010 5:55 pm    Post subject:
Reply with quote

if you look at the pre-compiler listing, you will notice that a declare:
  • sets up the variables used by db2
  • inserts cobol code between your PROCEDURE DIVISION USING statement and the first line of your code which establishes addressability with db2 and your program. This code (unless you internally modify the 'flag') is only executed once - at the start of execution of your program - unless you issue a cancel for your program from a CALLing module.


FETCH is a db2 term used to define the process of populating your host variables (defined in the DECLARE CURSOR) with values obtained from the result table, which is built as a result of the OPEN Cursor sql statement. The result table contains values from rows/colums selected from Table T during the OPEN processing.

The Applications programming and SQL guide, as well as the DB2 for z/OS Application Programming Topics outline this and other topics.
Back to top
View user's profile Send private message
sushanth bobby

Senior Member


Joined: 29 Jul 2008
Posts: 1013
Location: India

PostPosted: Fri Jan 08, 2010 6:00 pm    Post subject:
Reply with quote

Nethaji,

Quote:
The rows of the result table can be derived during the execution of the OPEN statement and a temporary copy of a result table can be created to hold those rows. They can be derived during the execution of later FETCH statements. In either case, the cursor is placed in the open state and positioned before the first row of its result table. If the table is empty, the position of the cursor is effectively “after the last row.” The DB2 system does not indicate an empty table when the OPEN statement is
executed.


I got the above information from DB2 SQL reference --> Chapter 5. OPEN statement.

Thank You,
Sushanth
Back to top
View user's profile Send private message
Keanehelp

New User


Joined: 27 May 2008
Posts: 70
Location: USA, CA.

PostPosted: Sat Jan 09, 2010 2:23 am    Post subject:
Reply with quote

Fetch will fetch the data into the variables
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Testing rerad cursor for status with ... John F Dutcher DB2 8 Fri May 19, 2017 9:35 pm
No new posts Getting -504 Cursor Name GTT-ARTS-CUR... Robin Sulsona DB2 2 Fri Mar 17, 2017 1:43 am
No new posts Release of Adabas Cursor mohitsethi All Other Mainframe Topics 1 Mon Feb 06, 2017 8:36 pm
No new posts Updating Cursor row withour using FOR... chandan.inst DB2 15 Tue Nov 08, 2016 11:17 am
No new posts Variable for cursor names ravikumar15 DB2 5 Sun Jul 17, 2016 7:08 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us