On Tue, Aug 14, 2007 at 09:16:15AM -0400, Robert Hicks wrote: > Tim Bunce wrote: > >On Tue, Aug 14, 2007 at 11:17:26AM +1000, Stuart Cooper wrote: > >>>First off, I had no idea it existed until I started going through a dbi > >>>tutorial. The idea is you don't have to litter your code with "or > >>>die..." statements. > > > >I recommend that everyone who doesn't carefully read the release notes > >(ie the Changes file extract I post with each release announcement) > >should reread the DBI docs at least every couple of years. > > > >>>Is it good practice to use this or is an explicit "or die..." better > >>>because you can "see" there is error trapping? > >>I think setting the RaiseError and PrintError attributes on your database > >>handle is the best way to do these things. > >> > >>$dbh = DBI->connect($DSN, $user, $pass, { RaiseError => 1, PrintError => > >>0, ... > > > >Yes, ShowErrorStatement just tweaks the behaviour of RaiseError and > >PrintError. > > > > $dbh = DBI->connect($DSN, $user, $pass, { RaiseError => 1, PrintError => > > 0, ShowErrorStatement => 1, ... > > So I should still "or die..." even if I set ShowErrorStatement?
Setting ShowErrorStatement is unrelated to "or die..." so the question seems flawed. ShowErrorStatement just adds information to the message produced by RaiseError and PrintError. I recommend RaiseError. I recommend ShowErrorStatement. I don't recommend "or die ...", generally. If you're using RaiseError then "or die ..." is redundant. If you're not using RaiseError then ShowErrorStatement is redundant (unless PrintError is on). Hopefully that helps. Tim.