I tend to use a combination of the packages/subroutines with business logic functionality, a database wrapper and an SQL phrasebook.

By using Class::Phrasebook, I have successfully transfered from a CSV mockup, through a MySQL implementation to MS SQL Server 7 (and stored procedures), by only changing the phrasebook. The functionality and wrapper haven't changed, just the database. Having the SQL wrapped up in the code, for me, has the same argument as wrapping HTML up Perl or visa versa. It can get ugly and awkward to maintain.

Using routines that implement the business logic is always a good thing. However the DB wrapper should be the one to handle all the connections, extract the SQL from the phrasebook, structure the data and handle any errors, so that if anything goes wrong, it's only one point of failure not potentially several hundred. My DB wrapper also handles the auditing required, and obtaining the ID for inserted records. To continually repeat this for each module containing business logic seems unnecessary.

I've heard good things about Class::DBI, however, it does seem to be more aimed at SQL based queries not stored procedures.

--
Barbie | Birmingham Perl Mongers | http://birmingham.pm.org/


In reply to Re: Re: Abstracting sql by barbie
in thread Abstracting sql by BUU

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.