A bit of advice for you. I have been told this a couple of times myself at this site.;)

Checking $DBI::errstr is best done when instantiating a DBI::db object, since you will not have a reference to the object if the connect fails. After the instantiation, say to the var $dbh, you should check the err() method or the more useful errstr() method: or die $dbh->errstr(). But....

An even lazier solution is to force errors to raise exceptions via the RaiseError attribute. You do so by passing a hash ref to the constructor like so:

my $dbh = DB->connect( 'DBI:vendor:database:host','user','pass', { RaiseError => 1}, );

Now you don't have to 'or die' after every query (method call).

Setting 'PrintError' to false is useful in conjunction with 'RaiseError' set to true when you use eval to catch exceptions, rather than die on them. Doing so supresses the 'error messages' that are generated when DBI calls die.

just tryin to be helpful ;)

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
F--F--F--F--F--F--F--F--
(the triplet paradiddle)

In reply to (jeffa) 2Re: SQL Query by jeffa
in thread SQL Query by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.