in reply to Re: Abstracting sql
in thread Abstracting sql

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/

Replies are listed 'Best First'.
Re: Re: Re: Abstracting sql
by princepawn (Parson) on Jul 31, 2003 at 17:14 UTC
    You might want to compare Class::Phrasebook to SQL::Catalog. I would be interested in hearing your feedback.

    Carter's compass: I know I'm on the right track when by deleting something, I'm adding functionality