IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Fetch the data from the table and write it to flat file


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
sultan_noor89

New User


Joined: 27 May 2006
Posts: 10
Location: At my Desk

PostPosted: Wed Apr 09, 2008 2:52 pm
Reply with quote

How to fetch the data from the table and write it to flat file using COBOL program
Back to top
View user's profile Send private message
shrivatsa
Warnings : 1

Active User


Joined: 17 Mar 2006
Posts: 174
Location: Bangalore

PostPosted: Wed Apr 09, 2008 2:56 pm
Reply with quote

Which table you are talking about?
Is that OCCURS clause or DB2 Table or something else...?
Back to top
View user's profile Send private message
sultan_noor89

New User


Joined: 27 May 2006
Posts: 10
Location: At my Desk

PostPosted: Wed Apr 09, 2008 6:40 pm
Reply with quote

from DB2 table, I need to fecth the data and write it to Flat file using COBOL
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Wed Apr 09, 2008 6:48 pm
Reply with quote

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
View user's profile Send private message
stodolas

Active Member


Joined: 13 Jun 2007
Posts: 632
Location: Wisconsin

PostPosted: Wed Apr 09, 2008 6:54 pm
Reply with quote

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
View user's profile Send private message
sultan_noor89

New User


Joined: 27 May 2006
Posts: 10
Location: At my Desk

PostPosted: Wed Apr 16, 2008 12:13 pm
Reply with quote

could you tell me how to fetch data from DB2 table using OCCURS clause
Back to top
View user's profile Send private message
sri_mf

Active User


Joined: 31 Aug 2006
Posts: 218
Location: India

PostPosted: Wed Apr 16, 2008 12:29 pm
Reply with quote

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
View user's profile Send private message
vasanthkumarhb

Active User


Joined: 06 Sep 2007
Posts: 275
Location: Bang,iflex

PostPosted: Wed Apr 16, 2008 12:31 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Wed Apr 16, 2008 7:20 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Store the data for fixed length COBOL Programming 1
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
Search our Forums:

Back to Top