View previous topic :: View next topic
|
Author |
Message |
l.nethaji
New User
Joined: 16 Mar 2008 Posts: 90 Location: tamil nadu
|
|
|
|
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 |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
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 |
|
|
sushanth bobby
Senior Member
Joined: 29 Jul 2008 Posts: 1020 Location: India
|
|
|
|
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 |
|
|
Keanehelp
New User
Joined: 27 May 2008 Posts: 71 Location: USA, CA.
|
|
|
|
Fetch will fetch the data into the variables |
|
Back to top |
|
|
|