[Dbix-class] update with result of a function

Cedric Boudin cedric at dreamgnu.com
Fri Dec 7 17:47:39 GMT 2007


my $rs=$schema->resultset('...')->search({....});

my $what='not column';

$rs->update({column=>\$what});

Automagical

thx

cedric



Cedric Boudin wrote:
> Dear Members of the list,
>
> I want to do this on a table:
>
> update table set column=function(column) where fk=some_value;
>
> I'm generalising here, in fact in this first case function is "not" and
> column type is boolean.
>
> I tried :
> a) something inspired of "Using database functions or stored procedures"
> $rs->search(..)
> b)creating a "customized" query like "Arbitrary SQL through a custom
> ResultSource"
>
> both without success
>
> I found:
> a description of something equivalent in the mailing list archives:
> http://www.grokbase.com/topic/2006/05/23/dbix-class-update-or-insert-from-hash-reference/PJ2q4Sgq4N1UNmM9l7V3Gswz-Mg
>
> where you dig into the resultset to get a $dbh, and then make your query
> the good all DBI way.
>
> As TIMTOWTDI, is there some more straightforward way to do it.
>
> cheers
>
> cedric
>
>
> _______________________________________________
> 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.rawmode.org
>   




More information about the DBIx-Class mailing list