in reply to Re^2: DBI SUM function
in thread DBI SUM function
... Next morning ...
A thousand pardons dear Monks.
In my application I have batches of data that can be added from time to time. When I run my code I don't know for sure if a batch currently exists. Because of this my SQL statement (including a lot of WHERE stuff) will be expected to return a NULL from time to time. Thus I used a simple "foolproof" way of testing for a null return. ... Yes, you guessed it, my "foolproof" code was actually "foolish" code. Let's just label it an "Intro to Computing 101, week #1 error" and let it fade away.
BUT, that leaves me with my current "foolproof code".
my $found_something = 0;
while (@val = $sth -> fetchrow_array())
{
      # useful database code goes here
      $found_something = 1;
}
if ($found_something == 0)
{
      # "graceful" found nothing code goes here
}
This should work, but it has a bit of a "bailing wire and chewing gum" look to it. Is there a cleaner way to do it?
Thanks for the help and sorry for error on my part.
Bruce