Paul Boutros wrote:

my $sql = qq{
 INSERT INTO table
        ( ${\comma_separated_values(@col)} )
 VALUES ( ${\comma_separated_placeholders(@col)} )
};


I'm not sure I like this, but if it is to be used, a better name might be "comma_list" which is the BNF short notation for all comma separated lists in SQL (e.g. select lists, value lists, etc.). Also, no reason to have two routines or to call them twice -- have the first set an attribute and then later read it. For example the call to $dbh->comma_list() would both return a comma separated list of the column names and set $dbh->{placeholders} to a string of comma separated placeholder marks which could be used later without a second call to a method:


   my $sql = qq{
       INSERT INTO table
                   ( $dbh->comma_list(@col) )
            VALUES ( $dbh->{placeholders}   )
   };

--
Jeff




Reply via email to