By submitting your email address, you agree to receive emails regarding relevant topic offers from TechTarget and its partners. You can withdraw your consent at any time. Contact TechTarget at 275 Grove Street, Newton, MA.
Outfiles are status quo on the iSeries, but did you know that SQL can produce them intrinsically? To have the results of a Select statement written to a database file (i.e., an outfile), specify the Select statement as part of an Insert statement. For example, to output the rows resulting from the following Select statement:
Select name, addr1, addr2, city, state, zip from cust_mast where state = 'IL' order by zip
to an output file, use the following INSERT statement:
Insert into library/outfile select name, addr1, addr2, city, state, zip from cust_mast where state = 'IL' order by zip
The library and outfile names you specify must already exist, and the file must have exactly six fields in the order specified on the select statement. However, the fields in the outfile do not have to have the same name as the ones on the SELECT statement, but they must have compatible attributes.
To create a file suitable for receiving the output from the above example, the following CREATE TABLE statement can be used:
Create Table UCG/Cust_Out