Re: dbaccess - select * display
Posted in 1996
Topics: SQL Development & Query Writing, Stored Procedures & SPL, Server Administration, Migration, Import/Export & Data Conversion
>
> You can write an awk script which will put all the pieces back
> together again once you hit the blank line which appears between each
> row. I did this some time ago and it worked well for me. I might
> try and dig up the script and post it here some day - the only fiddly
> bit was how to work out the length of each column.
>
> On 19 Apr 1996 14:23:17 -0400, clema@informix.com (Clem Akins) wrote:
>
> >al_dev@candle.com writes:
> >> : Is it possible to display multi-column rows (as in sybase isql) in dbaccess?
> >> : [...]
> >>
> >> 1. Bugger Informix on this one.
> >> 2. Look into the unload command. That might help you.
> >> NB! It's a dbaccess command, not an sql-statement executed by the engine, so
> >> you can't use it in a stored procedure and some other places.
> >
> >You can display multi-column rows if the columns don't extend past the end
> >of the screen. If you are really only interested in a subset of the
> >columns then choose only those. I've been able to fit all the interesting
> >data on-screen by eliminating columns from the display, i.e.
> > SELECT fname, lname FROM cust WHERE city = "Menlo Park"> >doesn't display the city (which I know), thus saving one column.
> >
> >That's pretty weak, I know, but it sometimes beats "OUTPUT TO filename".
> >
> > _______________________________________________________________
> > | Clem "RTFM" Akins clema@informix.com |
> > | International Support formerly |
> > | Informix Software, Inc cwakins@leia.alloys.rmc.com |
> > | Menlo Park, California, USA Standard Disclaimers Apply |
> > |_____________________________________________________________|
>
> (c) 1996, All rights reserved.
> __________________________________________________________
> | o o |
> | Gavin Nour: nourg@acslink.net.au |
> | Director: Select Software Solutions Pty Ltd. |
> | Secretary: Informix User Group NSW, Australia. |
> | Committee member: International Informix User Group. |
> | Mobile: +(61) 0419 803 113 |
> | o o |
> |__________________________________________________________|
>
Here's something I cooked up with perl. You have to decide on the format
of the output.
Example of use is as follows :
./one_line.pl multi.dat "%-10s %-10s %-12s %-35s %-35s %-35s %-35s" > /tmp/x1
#! /usr/local/bin/perl
#
# Filename: one_line.perl
# Desc : Joins multi line output from isql into one line
# Version : 1.00
# Author : Ti Lian Hwang
# Date : 19 Apr 95
#
# Usage : $0 format_string [datafile]
#
# Env Var :
#
# Amended :
# Initials Amend date Version Description of amendment
# tilh 19 Apr 95 1.00 initial release
#
$format = join ("","$ARGV[0]","\\n");
shift;
$cnt = 0;
$lin = 0;
$blank = 1;
while ($line = <>) {
chop ($line);
@word = split(/ +/,$line);
$wordcount = @word;
if ($wordcount gt 0) {
if ( $blank eq 1 ) {
$lin++;
}
$blank = 0;
}
else { $blank = 1; }
if (length($word[0])) {
$data[$cnt] = "@word[1..$wordcount-1]";
$cnt++;
} else {
if (length($word[1])) {
$data[$cnt - 1] = join ("",$data[$cnt - 1],
"@word[1..$wordcount]")
}
}
if ( $lin gt 0 && $blank eq 1 ) {
printf (qq/$format/,@data);
$cnt = 0;
@data = ();
}
}
printf (qq/$format/,@data);