in reply to Simple Template System That Supports Conditional Content?

Just to note, when doing a dynamic SQL statement building, it is usually a very bad idea to do simple string substitution based on the user input. You open yourself to SQL injection attacks among other things, like proper special character handling, etc. There is a much better option of using binding with prepare method of DBI package.
my $dbh = DBI->connect($data_source, $opts...); my $update_stmt = $dbh->prepare("UPDATE tbl_name SET `CUSTOMER NAME` = + ?, AGE = ?, STATUS = ?, ..."); ... $update_stmt->execute( defined $customer_name ? $customer_name : undef, defined $age ? $age : undef, defined $status ? $status : undef, ...);
Regards,

- caelifer

Replies are listed 'Best First'.
Re^2: Simple Template System That Supports Conditional Content?
by eric256 (Parson) on Aug 29, 2007 at 18:54 UTC

    Yours doesn't do the same thing. It actually updates fields they didn't mean to update setting them to undef/null.


    ___________
    Eric Hodges
      This was never intended to be a working code or an actual solution to the user's problem. I only wanted to show how to use binding with prepare.

      Regards,

      - caelifer