View previous topic :: View next topic
|
Author |
Message |
sultan_noor89
New User
Joined: 27 May 2006 Posts: 10 Location: At my Desk
|
|
|
|
How to fetch the data from the table and write it to flat file using COBOL program |
|
Back to top |
|
|
shrivatsa Warnings : 1 Active User
Joined: 17 Mar 2006 Posts: 174 Location: Bangalore
|
|
|
|
Which table you are talking about?
Is that OCCURS clause or DB2 Table or something else...? |
|
Back to top |
|
|
sultan_noor89
New User
Joined: 27 May 2006 Posts: 10 Location: At my Desk
|
|
|
|
from DB2 table, I need to fecth the data and write it to Flat file using COBOL |
|
Back to top |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
Here is the very basic flow.
Code: |
open output file
OPEN cursor
FETCH a row
perform until sqlcode not = 0
write a record
fetch a row
end-perform.
close cursor
close output file. |
[/code] |
|
Back to top |
|
|
stodolas
Active Member
Joined: 13 Jun 2007 Posts: 632 Location: Wisconsin
|
|
|
|
Seems like overkill to write a program to put a table to a file, unless of course you are doing processing on the data before writing the data to the file.
DFSORT and SYNCSORT can both do this. However, I believe the DB2 unload utility is far more efficient than any of these. |
|
Back to top |
|
|
sultan_noor89
New User
Joined: 27 May 2006 Posts: 10 Location: At my Desk
|
|
|
|
could you tell me how to fetch data from DB2 table using OCCURS clause |
|
Back to top |
|
|
sri_mf
Active User
Joined: 31 Aug 2006 Posts: 218 Location: India
|
|
|
|
sultan_noor89 wrote: |
could you tell me how to fetch data from DB2 table using OCCURS clause |
U have to fetch the each record and load it in to the internal table i mean ur array or write in to the file as per ur requirement. |
|
Back to top |
|
|
vasanthkumarhb
Active User
Joined: 06 Sep 2007 Posts: 275 Location: Bang,iflex
|
|
|
|
Hi,
sultan_noor89 wrote: |
could you tell me how to fetch data from DB2 table using OCCURS clause |
I guess there is no need of OCCURS class to write a VSAM file, Because you are using FETCH cursor stament of DB2, Which reads DB2 record sequentially and write one by one in to the flat file.
What made you to think to use OCCURS class?
Tell us the scenario. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
could you tell me how to fetch data from DB2 table using OCCURS clause |
You cannot use an OCCURS to fetch data form a database.
If you explain what you "have" and what you want to do, someone here will be able to help. Show input data and desired "output" even if the output is internal to a program. |
|
Back to top |
|
|
|