By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,678 Members | 2,439 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,678 IT Pros & Developers. It's quick & easy.

increase the size of UNIX window to see the entire output of a selectdb2 query

P: n/a
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

Apr 9 '08 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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
Apr 9 '08 #2

P: n/a
On Apr 9, 10:15 am, karanbik...@gmail.com wrote:
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
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
Apr 9 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.