Hello Everyone,

Recently I did some database connection to Oracle via DBD::Oracle.

I manage to conncec to server, the follow statement does not
work:

-- ## Begin Perl Code ## --
        
        my $sqlcmd = "select * from street";

        my $tbh = $dbh->prepare($sqlcmd);       

        $tbh->execute;

        if( $tbh->rows == 0 ){ 
                # Nothing return from table street...
                print "No data return\n";
                $tbh->finish;
                $dbh->disconnect;
                exit;
        }

        my $i = 0;

        while( $i < $tbh->rows ){
                my @dbres = $tbh->fetchrow_array;
                
                my $strbuf = join ' -- ', @dbres;

                print $strbuf;
        
                $i++;
        }

        $tbh->finish;
        $dbh->disconnect;

-- ## End Perl Code ## --

The program executed and return $tbh->rows as '0' when there
more than 10000 records in the table 'street'.

However, when I did the following:

-- ## Begin Perl Code ## --
        
        my $sqlcmd = "select * from street";

        my $tbh = $dbh->prepare($sqlcmd);       

        $tbh->execute;

        while( 1 ){

                my @dbres = $tbh->fetchrow_array;

                if( !defined(@dbres) ) {
                        print "END OF RECORDS\n";
                        last;
                }
                
                my $strbuf = join ' -- ', @dbres;

                print $strbuf;
        
                $i++;
        }

        $tbh->finish;
        $dbh->disconnect;

-- ## End Perl Code ## --

The program return all the entries in the table. 

Very strange...?? Anyone has any idea what coz'
my perl script to have such problem. Or... this
is actually the 'correct' way to get the table
records from Oracle??

Any perl guru/expert can help me on this? If I want to 
find out how many rows return, how should I go 
about and do it??

Thanks in advance,

Regards,
Sei Heng

-- 
Cybersource Pte Ltd
745 Toa Payoh Lorong 5 #03-02
HBM Building Singapore 319455
Tel: (65) 3580575

>> I rather be free in Hell then a slave in Heaven <<

Reply via email to