in reply to PERL DBI Oracle

It looks like a flip-flop ... (update: in Perl you can also use a variable as it's own flag provided there are no empty or zero values for it permitted in the actual data)
# ... $sth->bind_columns( undef,\$alias); my $key = 0; while($sth->fetchrow_array()) { if ( $key ) { print "$key, $alias\n"; $key = 0; } else{ $key = $alias; } }
or if you later realise you need to store the pairs anyway... ;)
$sth->bind_columns( undef,\$alias); my %hash; my $key = 0; while($sth->fetchrow_array()) { if ( $key ) { $hash{ $key } = $alias; # print "$key, $alias\n"; $key = 0; } else{ $key = $alias; } }
(updated to get rid of an unnecessary step)
__________________________________________________________________________________

^M Free your mind!

Replies are listed 'Best First'.
Re^2: PERL DBI Oracle
by farhan (Novice) on May 16, 2007 at 01:04 UTC
    Thanks a lot Moron, it worked

    Farhan
Re^2: PERL DBI Oracle
by farhan (Novice) on May 16, 2007 at 02:44 UTC
    Hello Moron,

    You code worked but if sql queries returns more than 2 rows , it still shows 2 entries. Is there wany way to change it.

    For example your code returns

    F:\perl\bin>perl C:\eHealth\custom\Script\nodata_l.pl
    BP-ALL-SITES, BP_COCO

    But actual result of query has 3 rows

    BP-ALL-SITES
    BP_COCO
    CMS-Monitoring


    Farhan
      Aha, I was interpreting an even number of rows from the OP. I think I would need to know what "works" means to you for an odd number of rows in that case. Update: Or is the three rows an unhandled error condition you are talking about?Also, if there are four rows, how do we know whether they are two pairs or not?
      __________________________________________________________________________________

      ^M Free your mind!