[Dbix-class] DBIx HAVING and COUNT error

Nigel Metheringham nigel at dotdot.it
Sat Sep 3 08:40:17 GMT 2016


No idea why you decided it was appropriate to add some individual
developers to your original email.

The syntax for the HAVING clause in DBIX::Class is documented:-
    https://metacpan.org/pod/DBIx::Class::ResultSet#having

You appear to have pasted some straight SQL in, which won't work well. 

So you want something along the lines of (untested):-
my $obj_rs = $schema->resultset('itemList')->search(
                { t_id => $tStr },
                {
                    group_by => [ qw(i_id) ],
                    having =>\[ 'count(t_id) = ?', $tCount ],
                }
            );

    Nigel.
> Rajeev Prasad <mailto:rp.neuli at yahoo.com>
> 3 September 2016 at 02:38
> 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?
>
> 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

-- 

[ Nigel Metheringham ------------------------------ nigel at dotdot.it ] 
[                 Ellipsis Intangible Technologies                  ]
 


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20160903/d0e9a180/attachment.htm>


More information about the DBIx-Class mailing list