Query length

Aaron Trevena aaron.trevena at gmail.com
Mon Mar 17 13:15:30 GMT 2008


Hi,

Two things :

1) use a prepare statement (with placeholders), then execute it

my $sth = $dbh->prepare($sql);
my $rv = $sth->execute(@values);

You could keep the SQL in a heredoc, or use Data::Phrasebook to hold a
collection of sql queries in a nice "phrasebook" organised by name,
etc : http://search.cpan.org/perldoc?Data::Phrasebook

2) use SQL::Abstract ( http://search.cpan.org/~nwiger/SQL-Abstract-1.22/ )

This allows you to create your query as a data structure, then fetch
the SQL (with placeholders) and a list of values. This is can avoid
typos or mistakes in value/placeholder ordering/matching and is
generally very helpful for any large query.

Regards,

A.



-- 
http://www.aarontrevena.co.uk
LAMP System Integration, Development and Hosting


More information about the london.pm mailing list