Question

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.

Was it helpful?

Solution 2

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');

OTHER TIPS

I have the feeling you mean to be using selectall_arrayref. selectall_hashref takes an extra parameter (between the SQL and the attributes) specifying which field should be used as the hash key in the returned hash.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top