===== web page: http://www.math2.org/david/sql-interpolate/ current version: 0.1 ===== ABSTRACT
The purpose of SQL::Interpolate is to make writing SQL queries in Perl more natural, less redundant, and less error-prone. SQL::Interpolate takes your query specification and generates a correctly formatted SQL statement along with a list of bind values. These result values can then be passed to DBI or used for another purpose. SQL::Interpolate serves a purpose similar to that of SQL::Abstract <http://search.cpan.org/%7Enwiger/SQL-Abstract/Abstract.pm> except that SQL::Interpolate still exposes and utilizes the full native SQL syntax of your database.
SYNOPSIS
use DBI;
use SQL::Interpolate;
my $rows = $dbh->selectall_arrayref(dbi_interpolate qq[
SELECT * FROM table
WHERE color IN], [EMAIL PROTECTED], qq[
AND y = ], \$x, qq[
LIMIT], [1, 10]
);
$dbh->do(dbi_interpolate qq[
INSERT INTO table ], {
color => $new_color,
shape => $new_shape}
);
$dbh->do(dbi_interpolate qq[
UPDATE table SET ], {
color => $new_color,
shape => $new_shape}, qq[
WHERE color <> ], \$color
);
my($sql, @bind) = sql_interpolate qq[
SELECT * FROM table WHERE color IN], [EMAIL PROTECTED], qq[
AND y = ], \$x
);
$d->prepare($sql);
$d->execute(@bind);
=====
- david