hi ,
I am running a " select " query on my DB2 Table ....which has around
45 columns ..from UNIX prompt .
The query output is quiet staggered . Cant we set the window size to
accomodate all the DB2 columns .
Is their any way out to do that .
just the way we do in SQL prompt in Oracle .
Please guide me .
Best Regards
Bikash Karan
Serman D. - 09 Apr 2008 11:21 GMT
karanbik...@gmail.com wrote:
> I am running a " select " query on my DB2 Table ....which has around
> 45 columns ..from UNIX prompt . The query output is quiet staggered .
I'd write a small script in my favorite scripting language (such as
Perl) to add a little control over the formatting:
use strict;
use warnings;
use Data::Dumper;
use DBI;
my ($rownum, $dbh, $sth) = (0, undef, undef);
my $query = q{select id integer, firstname, birthday from person};
$dbh = DBI->connect('DBI:DB2:viper', 'db2inst1', '*******') or
die(q{ouch});
$sth = $dbh->prepare($query) or die(q{ouch});
$sth->execute() or die(q{ouch});
while (my $hashref = $sth->fetchrow_hashref()) {
$rownum++;
print qq{$rownum;$_;} . $hashref->{$_} for (keys %{$hashref});
}
$sth->finish() or die(q{ouch});
__END__
$ /usr/bin/perl -wl row_number.pl
1;INTEGER;1
1;BIRTHDAY;2008-04-09 12:08:40.606969
1;FIRSTNAME;bart
2;INTEGER;2
2;BIRTHDAY;2008-04-09 12:08:40.606969
2;FIRSTNAME;lisa
3;INTEGER;3
3;BIRTHDAY;2008-04-09 12:08:40.606969
3;FIRSTNAME;homer
Lennart - 09 Apr 2008 14:23 GMT
On Apr 9, 10:15 am, karanbik...@gmail.com wrote:
> hi ,
>
[quoted text clipped - 10 lines]
> Best Regards
> Bikash Karan
Here is what I do (dont know your platform so it might not work for
you)
db2 "select ....." | less -S
now you can scroll sideways with the arrowkey's
/Lennart