in reply to Managing Dynamic SQL

BUU is right on with keeping a @args (i personally use @bind) array to push stuff onto as you append to $sql, and i use that all the time... I have, however, tried to start using SQL::Abstract when i can.
my %where = (); $where{time} = $time if $time; $where{date} = $date if $date; my $SA = SQL::Abstract->new(); my ($whereSql, @whereBind) = $SA->where(\%where); # also look at the $SA->select(), $SA->update(), etc methods

Replies are listed 'Best First'.
Re^2: Managing Dynamic SQL
by bart (Canon) on Jun 26, 2005 at 11:30 UTC
    I have, however, tried to start using SQL::Abstract when i can.
    You can go one step further still, and use DBIx::Simple to actually execute the thusly constructed queries, all in one method call.