Looks like you forgot to add the { Columns=>{} } part ...

> -----Original Message-----
> From: Randall Perry [mailto:[EMAIL PROTECTED]] 
> Sent: Friday, June 14, 2002 5:03 PM
> To: Tim Bunce
> Cc: [EMAIL PROTECTED]
> Subject: Re: Upgrade to 1.27 causes script failure
> 
> 
> Ok, here's text from DBI::Changes re: 1.20 change:
> 
>  To get previous selectall_hashref() behaviour (an array of hash refs)
>          change $ary_ref = $dbh->selectall_hashref( $statement, undef,
> @bind);
>              to $ary_ref = $dbh->selectall_arrayref($statement, {
> Columns=>{} }, @bind);
> 
> When I do the above, and change my code from:
>      $arrayref = $dbh->selectall_hashref($query);
> to:
>      $arrayref = $dbh->selectall_arrayref($query);
> 
> It returns an array of array refs; not an array of hash refs. 
> Got this error
> when trying to access it as array of hash refs:
> 
>     Can't coerce array into hash at 
> /perl/clean/confirm_warning_1.0.71c.pl
> line 60
> 
> So, is there a single method comparable to the old behaviour of
> selectall_hashref?
> 
> 
> 
> 
> 
> > I bet you've upgraded from a version < 1.20.
> > 
> > The interface to selectall_hashref changed in version 1.20.
> > 
> > Read the Changes file (or perldoc DBI::Changes).
> > 
> > Tim.
> > 
> > On Fri, Jun 14, 2002 at 11:14:23AM -0400, Randall Perry wrote:
> >> Seems to be an error with selectall_hashref method. Anyone 
> know what the
> >> problem is?
> >> 
> >> 
> >> Here are the errors:
> >> 
> >> [Fri Jun 14 11:00:00 2002] confirm_warning_1.0.7c.pl: DBI 
> selectall_hashref:
> >> invalid number of parameters: handle + 1
> >> [Fri Jun 14 11:00:00 2002] confirm_warning_1.0.7c.pl: Usage:
> >> $h->selectall_hashref($statement, $keyfield [, \%attr [, 
> @bind_params ] ])
> >> at /perl/clean/confirm_warning_1.0.7c.pl line 124.
> >> [Fri Jun 14 11:00:00 2002] confirm_warning_1.0.7c.pl: 
> Database handle
> >> destroyed without explicit disconnect at
> >> /perl/clean/confirm_warning_1.0.7c.pl line 124.
> >> 
> >> And here's my code (marked offending line with #124):
> >> sub doQuery {
> >>     my ($driver, $db, $user, $query) = @_;
> >>     my($dbh, $arrayref);
> >> 
> >> 124:    $dbh = DBI->connect("dbi:$driver:$db", "$user")  
> or confess "Can't
> >> connect to tasbill  $DBI::errstr";
> >>     $arrayref = $dbh->selectall_hashref($query);
> >>     $dbh->disconnect;
> >>     return  $arrayref;
> >> }
> >> -- 
> >> Randy Perry
> >> sysTame
> >> Mac Consulting/Sales
> >> 
> >> phn                 772.589.6449
> >> mobile email        [EMAIL PROTECTED]
> >> 
> >> 
> 
> -- 
> Randy Perry
> sysTame
> Mac Consulting/Sales
> 
> phn                 772.589.6449
> mobile email        [EMAIL PROTECTED]
> 
> 
> 

Reply via email to