On 08/28/2014 02:01 PM, Sheeju Alex wrote:
Hi All,

     Is there any way in DBIx to delete all rows from resultset in a
single query, it looks like delete and delete_all will delete the
resultset row by row.

my $rs = $schema->resultset('User')->search({GroupId => 712});
$rs->delete_all;

If there are 100 Users in User table then the above statement will
delete in 100 query instead is there a way to delete in single query.

DELETE FROM User WHERE GroupId = 712;

This is exactly how ->delete_all is supposed to work (one by one, so that the business logic is invoked on per-object basis).

This is not supposed to happen with $rs->delete however. Please provide your version of DBIx::Class, and the true definition of the $rs (I have a strong suspicion you did *not* give us the actual code).


_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk

Reply via email to