Progress
Programming
Handbook


Importing and Exporting Data

Sometimes you send data to a file knowing that it will be used later by a Progress procedure. If so, then you also know that the data file must be in standard format with character fields surrounded by quotes. Therefore, instead of just redirecting the output to the file and using the DISPLAY statement to send output to that file, you might use the EXPORT statement.

NOTE: Do not confuse the EXPORT statement with the EXPORT method of the SESSION handle. The EXPORT statement converts data from one format to another while redirecting it. The EXPORT method of the SESSION handle adds procedure names to the export list (list of procedures a requesting procedure can access) of a Progress AppServer. For more information on Progress AppServers, see Building Distributed Applications Using the Progress AppServer .

Using the EXPORT Statement

The EXPORT statement sends data to a specified output destination, formatting it in a way that can be easily used by another Progress procedure. For example, p-export.p writes customer information to a file:

p-export.p
OUTPUT TO p-datfl6.d. 
FOR EACH customer: 
EXPORT cust-num name sales-rep;. 
END. 
OUTPUT CLOSE. 

The output from p-export.p is written to p-datfl6.d:

p-datf16.d
1 "Lift Line Skiing" "HXM" 
2 "Urpon Frisbee" "DKP" 
3 "Hoops Croquet Comp" "HXM" 
4 "Go Fishing Ltd" "SLS" 
5 "Match Point Tennis" "JAL" 
       . 
       . 
       . 

Now this file is ready to be used as an input source by another Progress procedure. There is no need to process it through QUOTER.

By default, the EXPORT statement uses the space character as a delimiter between fields. You can use the DELIMITER option of the EXPORT statement to specify a different delimiter.

For example, p-exprt2.p writes to a file in which field values are separated by commas:

p-exprt2.p
OUTPUT TO p-datfl7.d. 
FOR EACH customer: 
   EXPORT DELIMITER "," cust-num name sales-rep. 
END. 
OUTPUT CLOSE. 

The output from p-exprt2.p is written to p-datfl7.d:

p-datf17.d
1,"Lift Line Skiing","HXM" 
2,"Urpon Frisbee","DKP" 
3,"Hoops Croquet Comp","HXM" 
4,"Go Fishing Ltd","SLS" 
5,"Match Point Tennis","JAL" 
       . 
       . 
       . 

You can read this file by using the DELIMITER option of the IMPORT statement. More likely, you would prepare a file like this to be read by another application.

For more information on the EXPORT statement, see the Progress Language Reference .


Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095