Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^4: Counting number of rows while working with Oracle

by denzil_cactus (Sexton)
on Mar 18, 2008 at 11:02 UTC ( [id://674763]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Counting number of rows while working with Oracle
in thread Counting number of rows while working with Oracle

Thanks for the replies I have tried the following code
my $rows = $sthBoo->fetchall_arrayref(); my $num_rows = @$rows;
it worked I could see the number of rows but now if I use
while (my $row = $sth->fetchrow_hashref) {
after the above code its giving the warning
DBD::Oracle::st fetchrow_hashref failed: no statement executing (perha +ps you need to call execute first) [for Statement "
Is there any problem withthe code? Thanks

Replies are listed 'Best First'.
Re^5: Counting number of rows while working with Oracle
by ikegami (Patriarch) on Mar 18, 2008 at 12:52 UTC
    That's why I followed those two lines with foreach my $row (@$rows) instead of while (my $row = $sth->fetchrow_hashref).
Re^5: Counting number of rows while working with Oracle
by andreas1234567 (Vicar) on Mar 18, 2008 at 11:42 UTC
    You did not post a complete, working code sample, so we can't say.

    Inspect your $sth vs. $sthBoo though.

    --
    Andreas
      Here my code
      my $req = <STDIN>; my $sth = $dbh->prepare( qq{ SELECT tr_code,j_trs from t_ghos } ) or die "Can't prepare statement: $DBI::errstr"; $sth->execute or die "Can't execute statement: $DBI::errstr"; my $rows = $sth->fetchall_arrayref(); my $num_rows = @$rows; if($num_rows > 0) { process($sth,$req); } sub process { my $sth = shift; my $type = shift; while (my $row = $sth->fetchrow_hashref) { next unless defined($row); } }

      Now please tell me any solution to count the number of rows

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://674763]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2024-04-19 00:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found