SUMMARY: dbaccess output width
Posted in 1999
Topics: Server Administration, Migration, Import/Export & Data Conversion, Platform-Specific Issues
Thanks to all of you who responded to my post. Here's a summary of what I've
learnt:
Problem: Is it possible to set the line width of dbaccess output?
I'm running dbaccess in batch mode redirecting the output into a file.
I've tried all environment variables (i.e. Unix environment variables; I
didn't find any relevant Informix environment variables in the IDS and
DBACCESS documentation) I could think of, dbaccess seems to ignore them all.
If the added length of all selected columns is greater than 80 it won't put
them all in one line (which is what I would need) but instead lists them
underneath each other.
Environment: Informix Online Server 7.13 on Solaris 2.5.1
Solution: First of all, the Informix gurus agree that there is no way in
dbaccess to do this. Two workarounds were suggested:
1.) SQLCMD from the IIUG archives at http://www.iiug.org; it always emits
all its data on a single line (unless the data is a character string
containing newlines). It also has a fixed-width output mode (though, IIRC,
it still puts out delimiters between the fields). It also has something
resembling a CSV (comma-separated values) output format.
2.) Try using an unload statement to get the output into a file. For
example:
unload to 'my_file.out' select abc, def, ..., xyz from table1;It will come out as a pipe (|) delimited file instead of fixed-width, but
each row will be on one logical line. You should then be able to use and/or
format this data in any application that can read a delimited file.
Cheers
E.
There are a couple of other possibilities in the IIUG repository that
you may want to investigate. Both provide output formatting, and both
use awk, I believe. "reform_sql" reads dbaccess/isql output. It tries
to figure out the best format or allows you to specify one manually.
"beautify_unl" attempts to clean up and columnate unload output.
If you get into doing your own awk scripting, you may also want to look
at "rpt_awk". This file contains a set of awk functions designed to
emulate the pagination controls found in ACE and Informix-4GL.
Good luck,
Walt.
--
Walt Hultgren
Manager, Information Technology
Yerkes Research Center of Emory University
Mailto:walt@rmy.emory.edu -- 404-727-0648