anyway to determine # rows before fetch loop ends and without seperate count(*)
- From: listmail@xxxxxxxxxxxx
- Date: Wed, 16 Nov 2005 16:27:12 -0500
#Here's an example which shows what I am trying to accomplish. If I
can determine the number of rows before pushing the data, this can
simply things for #me when processing the data throught my scripts.
#
use warnings;
use strict;
use DBI;
use DBD::Oracle;
my $sql=q{ select name, location
from mytable
};
my $dbh;
eval {
$dbh = DBI->connect("dbi:Oracle:MYDB",
'dbuser', 'dbpass',
{
RaiseError => 1,
AutoCommit => 0,
ora_session_mode => 0
}
);
};
if ( $@ ) {
outprint('end',"$DBI::errstr\n");
}
my $sth=$dbh->prepare($sql) or die "Couldn't prepare statement: " . DBI-
>errstr;
$sth->execute or die "Couldn't execute statement: " . DBI->errstr;
my $ary;
while ($ary = $sth->fetchrow_array()) {
#I need to determine number of rows as this will affect
whether a matrix is used or not
#a boolean variable $matrix could be returned or a ref
check done so that the data
#processing code can act accordingly
#$sth->rows only shows total rows after the while loop
is processed
#Can I accomplish this without a seperate count(*)
statement?
#
#push @newary,[ @{$ary} ]; # if more than one row
#or
#push @newary, @{$ary} ; # single row
}
$sth->finish;
$dbh->disconnect;
#
#ActivePerl 5.8.7 813
#ppm
#-DBD-Oracle 1.16
#-DBI 1.48
.
- Follow-Ups:
- Re: anyway to determine # rows before fetch loop ends and without seperate count(*)
- From: JupiterHost.Net
- Re: anyway to determine # rows before fetch loop ends and without seperate count(*)
- Prev by Date: DBD::Oracle
- Next by Date: RE: anyway to determine # rows before fetch loop ends and without seperate count(*)
- Previous by thread: DBD::Oracle
- Next by thread: Re: anyway to determine # rows before fetch loop ends and without seperate count(*)
- Index(es):
Relevant Pages
|