List:MySQL and Perl« Previous MessageNext Message »
From:Gisbert W. Selke Date:December 18 2007 7:03pm
Subject:AW: how to allow variable number of argumets in mysql insert quer
y
View as plain text  
> -----Ursprüngliche Nachricht-----
> Von: Baron Schwartz [mailto:baron@stripped]
> Gesendet: Dienstag, 18. Dezember 2007 19:36
> You could also use this idiom:
> 
> $dbh->do($sql, \%attrs, @args)
> 
> For example,
> 
> $dbh->do("select foo from bar where bar in(" . join(',', map { '?' }
> @args) . ")",
>    {}, @args);
Right, Baron, that's much better (safer) than my second solution! TMTOWTDI.
The problem is (in both approaches) that the statement should be an INSERT
rather than a SELECT. Unless the columns are specified excplitly, the number
of parameters in the VALUES(...) part must match the number of columns in
the table, unless I'm mistaken about SQL syntax. You may, of course, insert
NULLs (aka undefs in the Perl world), but you have to do so explicitly.

\Gisbert
Thread
how to allow variable number of argumets in mysql insert queryfungazid18 Dec
  • Re: how to allow variable number of argumets in mysql insert queryCBTS) GEAE19 Dec
    • Re: how to allow variable number of argumets in mysql insert queryfungazid19 Dec
    • Re: how to allow variable number of argumets in mysql insert queryfungazid19 Dec
  • Re: how to allow variable number of argumets in mysql insert queryCBTS) GEAE19 Dec
  • RE: how to allow variable number of argumets in mysql insert queryJohn Trammell19 Dec
  • Re: how to allow variable number of argumets in mysql insert queryCBTS) GEAE26 Dec
AW: how to allow variable number of argumets in mysql insert queryGisbert W. Selke18 Dec
  • Re: how to allow variable number of argumets in mysql insert quer yBaron Schwartz18 Dec
AW: how to allow variable number of argumets in mysql insert queryGisbert W. Selke18 Dec
  • Re: AW: how to allow variable number of argumets in mysql insertquer yfungazid18 Dec
    • Re: AW: how to allow variable number of argumets in mysql insert quer yBaron Schwartz18 Dec
      • Re: AW: how to allow variable number of argumets in mysql insertquer yfungazid18 Dec