[Dbix-class] Update with more bound variables

Peter Rabbitson rabbit+dbic at rabbit.us
Wed Mar 10 17:21:47 GMT 2010


Ion Pop wrote:
> Hello,
> 
> When I make an update for a field and I need to use more bind
> variables, it gives an error.
> 
> I tried:
> 
> $rs->update({
>   open => \["(open + ? * ?) / (1 + ? + ?)",
>     [dummy1 => $var1, dummy2 => $var2, dummy3 => $var3, dummy4 => $var4]],
> });
> 
> The error given is:
> 
> DBIx::Class::Schema::txn_do(): bindtype 'columns' selected, you need
> to pass: [column_name => bind_value] at
> e:/usr/site/lib/SQL/Abstract.pm line 1108.
> 
> It gives the same error if I just do:
> 
>   open => \["(open + ? * ?) / (1 + ? + ?)",
>     $var1, $var2, $var3, $var4],
> 
> and the same error if I do:
> 
>   open => \["(open + ? * ?) / (1 + ? + ?)",
>     [$var1, $var2, $var3, $var4]],
> 
> Please tell me which is the correct syntax if this is possible with DBIC.
> 

The correct syntax is \[ $sql, [ col1 => bind1 ], [ col2 => bind2 ], ... ]
Please refer to this ticket and work with the submitter to make docs/exceptions
clearer on this matter: https://rt.cpan.org/Ticket/Display.html?id=55189



More information about the DBIx-Class mailing list