[Dbix-class] Update first X rows

Peter Rabbitson rabbit+dbic at rabbit.us
Tue Jul 14 11:29:11 GMT 2009


On Tue, Jul 14, 2009 at 09:52:12AM +0200, Yves Räber wrote:
> Hello,
> 
> I need to update the first X rows of a resultset, and I've tried something like this :
> 
> my $to_dispatch = $c->model('myDB::Table')->search($sql_args, { rows => 10 });
> $to_dispatch->update( { state => 'TODO' } );
> 
> It works, but generate a query for each row.
> 
> What I would like to generate is a query that looks like "UPDATE Table SET state = 'TODO' WHERE blablabla LIMIT 10".
> 
> It it possible to do this with DBIx::Class ?

Anything is possible with DBIC, but the real question is - is it possible
with your RDBMS. What I ned to know is:

* Your rdbms type
* What kind of PK is on myDB::Table (single column or multicolumn)
* Are you absolutely sure UPDATE ... LIMIT X actually works, instead of
  LIMIT being simply ignored? Please test with manual queries.



More information about the DBIx-Class mailing list