Click here to Skip to main content
15,879,490 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
DBI fetchall_hashref: invalid number of arguments: got handle + 0, expected handle + between 1 and 1
Usage: $h->fetchall_hashref($key_field) 


What I have tried:

sub pending_running_partition
{

my $str=shift;
$DBH=&connect or die "cant connect to the sql server \n";
$DBH->do("USE $str;");
my $stmt="select queue_name,jobs_pending,jobs_running from queues order by time desc;";
my $sth=$DBH->prepare($stmt);
$sth->execute() or print "could not prepare_overall_queues_data";
my %TABLE_DATA=();
my @sys=qw/Adice Incisive Calibre Vcs others/; 
  my $table = $sth->fetchall_hashref; 
  
  for my $r (@$table) { 
    my $name='others'; 
    print $name;
    for my $s (@sys){ 
      if ($r->{queue_name}=~m/$s/i) {$name=$s; last;} 
      } 
    $TABLE_DATA{$name}{jobs_pending}+=$r->{jobs_pending};  
    $TABLE_DATA{$name}{jobs_running}+=$r->{jobs_running}; 
    } 
  for my $var(qw/running pending/) { 
    my @parts=(); 
    for my $s (@sys){ 
      push @parts,'["'.$s.'",'
                  .$TABLE_DATA{$s}{'jobs_'.$var}
                  .']'; 
      } 

}
}
Posted
Updated 22-Mar-17 19:15pm

1 solution

Your error message tells you that fetchall_hashref requires exactly one argument, and even suggests that it could be a key_field.
But your code is
my $table = $sth->fetchall_hashref;
whicxh is calling it with no arguments.
 
Share this answer
 
Comments
example file 23-Mar-17 4:06am    
i am confused to pass which arguments.
Peter_in_2780 23-Mar-17 7:01am    
I have no idea. I was simple interpreting your error message for you.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900