[EMAIL PROTECTED] wrote:

#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;

Good good :)

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");
}

Hmm, perhaps the oracle specific stuff needs it but why are you evaling that?

my $dbh = DBI->connect(@DBI_CONNECT_ARGS) or outprint('end', $DBI::errstr); # assumign its die()ing or exit()ing


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

Also very convoluted, all of that can be done with:

my $results = $dbh->selectall_arrayref($sql); # if you only want to process a certain amount just LIMIT in your $sql...

my $count = @{ $results };

$dbh->disconnect;

if($count < 1000) { # or whatever you wanted teh count for...
    for my $record(@{ $results }) {
        # now use the data:
        # $record->[0]
        # $record->[1]
    }
}

Reply via email to