joec_ has asked for the wisdom of the Perl Monks concerning the following question:

Hi

I am returning rows from a cursor in Oracle and printing out the column values. I want to be able to check if rows have been returned. Could any one provide an example of how to do this checking?

For example

while ($row = $cursor->fetchrow_arrayref){ print $row->[0],",",$row->[1]; ### If no rows are returned, print EMPTY ### I tried using if (!defined($row->[0])) but that didnt work }
Thanks- i know it should be simple

Joe

-----

Eschew obfuscation, espouse elucidation!

Replies are listed 'Best First'.
Re: Check if no rows are returned from Oracle
by ikegami (Patriarch) on May 21, 2009 at 17:02 UTC
    my $empty = 1; while (my $row = $cursor->fetchrow_arrayref) { $empty = 0; print "$row->[0], $row->[1]\n"; } if ($empty) { print "EMPTY\n"; }