[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] TMTOWTDI: SQL creation




On Tue, 29 Jun 1999, Andy Lester wrote:

> I'm writing some code that happens to need to build some SQL on the fly,
> based on some field names and values.  I originally wrote it like:
> 
>         my $sql =
>             "INSERT INTO " . $parms{$table} .
>             "(" . join( ",", @fieldnames ) . ")" .
>             "VALUES ( " . join( ",", @values ) . ")";

I use:

  $dbh->insertrow($parms{$table}, 
      { field1 => $field1, field2 => $field2 });

With things like inserts, it's sometimes best to build your own little
abstraction, rather than trying to do everything inline.


==== Want to unsubscribe from Fun With Perl?
==== Well, if you insist... Send mail with body "unsubscribe" to
==== fwp-request@technofile.org