Search code examples
perldbihashref

DBI::st=HASH()->_prepare(...): attribute parameter is not a hash - Perl


I begginer in Perl and I've got this problem:

my $query = qq {select a1, count(b2), c3 from tab where d1 = ? group by a1, c3 };  
my $res = $dbh->selectall_hashref( $query,{ Slice => {} }, $id->[0]); 

When execute the code, I get:

DBI::st=HASH()->_prepare(...): attribute parameter  is not a hash at /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/DBD/mysql.pm line 224.

Am I do something wrong?

Thanks for your attention.


Solution

  • try

    my $query = "select a1, count(b2), c3 from tab where d1 = ? group by a1, c3";
    my $res = $dbh->prepare($query) or die("cannot prepeare");
    $res->execute('10');