Re: A solution to SQL reformatting problem
Posted in 1992
In article <1992Jul20.190339.13147@twg.com> cauhape@twg.com (Jeff Cauhape x7147) writes:
>
> I've found a solution for UNIX systems.
>
> It appears that sql looks at the width of the output device as defined
>by the "columns" variable in the stty data structure when it makes a decision
>to change format or not. To fool sql into not changing the format, reset the
>value of columns variable in your current session to be wide enough that
>sql thinks there's enough room.
>
[omissions]
>
>I then reset the columns width to 1000 characters.
>
> apache% stty columns 1000
>
>If I run the stty command again, I can see that the columns have changed.
>
> apache% stty -a
>
> speed 38400 baud, 24 rows, 1000 columns ...
>
>From here I run my sql script and it writes one record per line. Remember to
>reset your tty device back when your done.
>
This sounds like it should work. If it does you ought to be able to wrap
all this functionality into a shell script which can reset teh columns value
and then run the sql command you wish to run (or ace or whatever). Something
like this should work:
############################################################################
#
# This is a test shell, sqltest.sh, which resets stty column and runs
# and INFORMIX command that produces very wide output.
if [ $# -eq 1 ]
then
COLUMNS=1000 # set default COLUMNS if no arg is given
else
COLUMNS=$1 # to make this better chec kthat $1 is digits only
fi
stty $COLUMNS
isql <<-!
select blah blah blah...
!
stty 80 # this is not really needed, since shell can not
# reset stty values for parent shell
########################### END OF FILE ####################################
Make this shell executable:
$ chmod 755 sqltest.sh
You can invoke it in these ways:
$ sqltest.sh 2345
or
$ sqltest.sh
--Steve Price UNIX: pacbell!pbhyf!rsprice PHONE: (510)823-1951
Progress is an illusion.