Many moons ago my uni lecturer told us we cant test for everything because we will never know all the possible combinations of run-time variables that could occur.

Given that she also said that we should attempt to trap everything in a generic method reporting back any errors via logs, emails, or whatever was appropriate for the system being built.

Having said all that, there are a few things that could go wrong, for example null values and most obviously your dbi calls.

As the others have mentioned, add some error handling to see what is going on in your code, and whatever you do make sure you are using -w and strict.

As an aside, if this is is going to be a part of an object, it will be called many times. To increase performance, have you considered using bind vars in your code?

I'm not sure if this specifically applies to mysql, however with oracle and postresql, if you make a call to the database the sql is cached in the database. What this means, is when the DB engine gets the a statement, it will compare it to what it has in memory and use the memory cached version, rather than the one being parsed, thus saving on expensive I/O.

If you dont use placeholders (bindvars) in your code, each statement is potentially different, and thus the db cache is filled with useless statements that are only ever executed once.

Using placeholders, means that all the statements are the same as the variables in them are the placeholders ("?") so the db can re-use it.

Its a smart, easy and efficient style to code in that will make your application more scalable. Its so simple to do, i dont know why people dont, when they can.

Yet again i digress from the topic at hand... <sigh>


In reply to Re: Hash Tie's DESTROY & DBI by Ryszard
in thread Hash Tie's DESTROY & DBI 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.