|
|
| Author |
Message |
sultan_noor89
New User
Joined: 27 May 2006 Posts: 9 Location: At my Desk
|
|
|
|
| How to fetch the data from the table and write it to flat file using COBOL program |
|
| Back to top |
|
 |
References
|
Posted: Wed Apr 09, 2008 2:52 pm Post subject: Re: Fetch the data from the table and write it to flat file |
 |
|
|
 |
shrivatsa
Active User
Joined: 17 Mar 2006 Posts: 157 Location: Pune
|
|
|
|
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: 9 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: 970 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
Senior Member
Joined: 13 Jun 2007 Posts: 646 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: 9 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: 169 Location: At my Desk
|
|
|
|
| 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: 298 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
Global Moderator
Joined: 23 Nov 2006 Posts: 7517 Location: 221 B Baker St
|
|
|
|
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 |
|
 |
|
|