On 09/03/2016 03:38 AM, Rajeev Prasad wrote: > DBIx error in webserver log: > > [cgi:error] [pid 29640] ... AH01215: Can't locate object method "HAVING" via > package "COUNT" (perhaps you forgot to load > "COUNT"?) > > > the query: > > my $obj_rs = $schema->resultset('itemList')->serach( > { t_id => { -in => [ $tStr ] }}, > { > group_by => [ qw(i_id) ], > HAVING COUNT('t_id') = $tCount > } > ); > > > currently database has no records which match the query. but i was not > expecting such an error. > > what is wrong in my statement?
You can't just drop in literal SQL like that and expect it to work - because Perl now assumes "HAVING COUNT" being Perl code. I suppose "use strict; use warnings" would have alerted you of that. It is possible to you use literal SQL with DBIx::Class, please refer to the docs. I would suggest a different approach - using subqueries. Please take a look at the excellent advent calendar post from fREW: http://www.perladvent.org/2012/2012-12-21.html This is still accurate. I covered a few use cases in my presentation at the Alpine Perl Workshop: https://www.linuxia.de/talks/alpine2016/dbic-pr-en-beamer.pdf Regards Racke > > thank you. > Rajeev > > > _______________________________________________ > 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 > -- Ecommerce and Linux consulting + Perl and web application programming. _______________________________________________ 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