On Fri, Jan 16, 2004 at 10:26:07AM +0100, Steffen Goeldner wrote: > > 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?).
I'll modify set_err so if there's a non-empty errstr already it'll append a newline and then the new errstr. > 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. join "\n", ... Very old (pre perl5!) versions of the DBI spec (or DBPerl as it then was) mentioned that specifically. I'll add it to the DBI docs. (Of course you could use an array ref blessed into a class that overloads the stringify method to do a join("\n",@$self) :-) Tim.