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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sql print statement

Status
Not open for further replies.

desertmaster

Programmer
Oct 24, 2002
2
US
How do I direct output to the local printer with an informix sql statement? Neither the Sql Tutorial nor the
Reference Book give any hint.
 
Hi,

Informix supports an extended ANSI syntax as follows for SELECT:

1. OUTPUT TO filename [WITHOUT HEADINGS] SELECT <statement>
2. OUTPUT TO PIPE <program> [WITHOUT HEADINGS] SELECT <statement>

The first syntax can be used for dumping mode; and the second for the offline/online printing mode.

Here is a Unix script file which can be used for this purpose.Please make sure that is file has a executable permission. To do this issue: chmod 755 lprn

example:

OUTPUT TO PIPE lprn SELECT * FROM customer;

listing of lprn

#!/bin/sh

#script to print file to the local printer port

echo &quot;&quot;
#you may use cat, more, pr, lp etc.
pr $*
echo &quot;&quot;

Regards
Shriyan
 
This helped me tremendously for something I am doing. One additional question.
When I use this to suppress column labels, I get 2 blank lines in the beginning of my file. How do I suppress blank lines?

Thanks!
 
MizzGail,

You may use the following syntax of UNLOAD for your purpose:

UNLOAD TO &quot;cust.unl&quot; DELIMITER &quot;|&quot; SELECT * FROM customer;

The dump file will be a data file; does not contain the field labels and the fileds delimited by pipe symbols contains no blank spaces in between.

Regards,
Shriyan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top