Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Fetch the data from the table and write it to flat file

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Fetch the data from the table and write it to flat file
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: 171
Location: Bangalore

PostPosted: Wed Apr 09, 2008 2:56 pm    Post subject: Reply to: Table handling
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    Post subject: Reply to: Fetch the data from the table and write it to flat
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    Post subject:
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    Post subject:
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    Post subject: Reply to: Fetch the data from the table and write it to flat
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: 215
Location: India

PostPosted: Wed Apr 16, 2008 12:29 pm    Post subject: Re: Reply to: Fetch the data from the table and write it to
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: 276
Location: Bang,iflex

PostPosted: Wed Apr 16, 2008 12:31 pm    Post subject: Re: Reply to: Fetch the data from the table and write it to
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

Site Director


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

PostPosted: Wed Apr 16, 2008 7:20 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts How to write Rexx program to size and... sreejeshcs CLIST & REXX 14 Thu Oct 12, 2017 7:26 am
No new posts Update table without cursor Ron Klop DB2 3 Wed Oct 11, 2017 1:06 pm
No new posts Copy 4 byte of data from the last rec... arunsoods DFSORT/ICETOOL 9 Fri Oct 06, 2017 12:15 pm
No new posts Table(Unicode(Graphic) table) loading... muralikrishnan_new DB2 0 Thu Oct 05, 2017 5:10 pm
No new posts opening a dataset after reading it fr... arunsoods DFSORT/ICETOOL 5 Wed Oct 04, 2017 3:54 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us