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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • karanbikash@gmail.com

    #1

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

    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.

    #2
    Re: increase the size of UNIX window to see the entire output of aselect db2 query

    karanbik...@gma il.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:D B2: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_hashr ef()) {
    $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;bar t
    2;INTEGER;2
    2;BIRTHDAY;2008-04-09 12:08:40.606969
    2;FIRSTNAME;lis a
    3;INTEGER;3
    3;BIRTHDAY;2008-04-09 12:08:40.606969
    3;FIRSTNAME;hom er

    Comment

    • Lennart

      #3
      Re: increase the size of UNIX window to see the entire output of aselect db2 query

      On Apr 9, 10:15 am, karanbik...@gma il.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

      Comment

      Working...