in reply to Re^3: DB2 checking for an error on select
in thread DB2 checking for an error on select

lets assume that the fetch is the first time I hare back from the server. How can I test for a fetch error? Keep in mind I am ok with 0 records returned, but no data found due to the table being off line is a problem
  • Comment on Re^4: DB2 checking for an error on select

Replies are listed 'Best First'.
Re^5: DB2 checking for an error on select
by morgon (Priest) on May 15, 2009 at 12:04 UTC
    fetch returns undef if either there are no more rows or when en error occurs.

    You can distinguish these cases by checking $sth-err.

    So in code you can do something like this:

    while( defined $sth->fetch) { # do something with fetched data } if($sth->err) { # handle error } else { # no more data }
      Thanks that did the trick