in reply to Fast Building of SQL Statements
WRT optimization, since you're using a closure to keep a constant list of field names inside of, what's the point of rebuilding the SQL for every query?my @FIELDS = qw( field1 field2 field3 ); my @PLACEHOLDERS = ('?') x @FIELD; my $sql = do { local $" = ','; "INSERT (@FIELDS) INTO foo VALUES (@PLACEHOLDERS)"; };
{ my $SQL; BEGIN { my @FIELDS = qw( field1 field2 field3 ); my @PLACEHOLDERS = ('?') x @FIELD; local $" = ','; $SQL = "INSERT (@FIELDS) INTO foo VALUES (@PLACEHOLDERS)"; } sub run_insert { my $dbh = shift || return; my $sth = $dbh->prepare($SQL); $sth->execute(@_); $sth->finish; } }
Makeshifts last the longest.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Fast Building of SQL Statements
by DapperDan (Pilgrim) on Aug 28, 2003 at 12:36 UTC | |
by Aristotle (Chancellor) on Aug 28, 2003 at 12:59 UTC |