Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
Database Servers
DB2InformixIngresMS SQLOraclePervasive.SQLPostgreSQLProgressSybase
Desktop Databases
FileMakerFoxProMS AccessParadox
General
General DB TopicsDatabase Theory
Related Topics
Java Development.NET DevelopmentVB DevelopmentMore Topics ...

Database Forum / DB2 Topics / April 2008

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
karanbikash@gmail.com - 09 Apr 2008 09:15 GMT
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
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.