http://qs321.pair.com?node_id=874795


in reply to Re: Flexible Update SQL
in thread Flexible Update SQL

But this does not solve the problems:
  • passing null parameters...
  • placement of the comma...
  • Replies are listed 'Best First'.
    Re^3: Flexible Update SQL
    by roboticus (Chancellor) on Dec 02, 2010 at 02:53 UTC

      bichonfrise74:

      Actually, placeholders *do* handle the null parameter. Constructing the update statement can do the rest...

      my @fields = qw(name phone city country); my $SQL = "update table set " . join(", ", map { "$_=?" } @fields) . "where ...."; my $ST=$DB->prepare($SQL); while (...) { my @values = (.....); $ST->execute(@values); }

      ...roboticus

      When your only tool is a hammer, all problems look like your thumb.