Tim Bunce wrote: > The RaiseError/PrintError/HandleError mechanism only applies at the > point where the DBI is abount to return control to the application. > It isn't triggered by a "nested" calls (where select*_* calls prepare()) > > I was planning to implement HandleWarn the same way but > I've realised that "undef error before most method calls" mechanism > would often clear the warning state before higher level method returns. > Consider: > > sub do { > my($dbh, $statement, $attr, @params) = @_; > my $sth = $dbh->prepare($statement, $attr) or return undef; > $sth->execute(@params) or return undef; > my $rows = $sth->rows; > ($rows == 0) ? "0E0" : $rows; > } > > a warning from prepare would be lost by calling execute.
That's not only a problem for higher level methods, e.g.: sub execute { ... $sth->set_err( 0, ... ) if ...; ... $sth->set_err( 0, ... ) if ...; } All but the last warning would be lost. It would be nice if these warnings accumulate in an array (DBI version 2?). BTW: Even an ADO method may return more than on error/warning (in an Errors collection). Thus I have always the problem to flatten this collection into scalars. Steffen