Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to spool query output to flat text file 1

Status
Not open for further replies.

DeepDiverMom

Programmer
Jul 28, 2003
122
US
I know it's a rookie question, but what command do I use to spool SELECT output to a flat file? What command do I use to stop spooling? Can I append to the previously spooled file?

Thanks,

Becca
 
Also, if the flat file that I spool contains all SQL commands (that my query composed), what is the command I use to execute the flat file that is now a SQL script?

Becca
 
Becca,

to simply run a script through db2 the format is as follows, using the db2 clp.

db2 -f becca.ddl

where becca.ddl is the name of your file containing SQL commands.

There are a number of options for the clp, which you can query using

db2 list command options

There are two options you might be interested in the -r and -z.

-r saves the command output to a report file.

-z saves all output to an output file.

Haven't done enough experimenting to really be able to point out the major differences.

Alternative way of redirecting/logging output is along the lines of

db2 -f becca.ddl > becca.out

or to append

db2 -f becca.ddl >> becca.out

Should you choose not to redirect, output should be displayed on your standard output.

If you wish for comments in your becca.ddl file they need to begin with -- and the clp will effectively ignore them.

Cheers
Greg

 
Greg,

Thanks for your posting. It gave me the answers I needed to take care of business. Have a Christmas Star!

Becca
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top