in reply to Result set into array

Although you don't say, I assume you are using DBI. Try something like
my $hash = $dbh->selectall_hashref( "Select id, col2, col3, col4 From TableA". 'id' );

Replies are listed 'Best First'.
Re^2: Result set into array
by novicepl (Initiate) on Nov 19, 2006 at 01:08 UTC
    yes, I am using DBI. getting error msg "Can't locate object method "selectall_hashref" via package "DBI::st" at ./Test1.pl line 166. "
    $sth = $dbconn->prepare($sql_statement); $sth->execute() or die "Can not execute: " . $sth->errstr; $sth->{RaiseError} = 1; my $hash = $sth->selectall_hashref($sql_statement); #this is line +166 $sth->finish; $dbconn->commit(); $dbconn->disconnect();
      Guessing from reading the docs (!) but it looks like selectall_hashref() is executed using the DB handle, so your code might better be:
      my $hash = $dbconn->selectall_hashref($sql_statement);
      You may have been led astray by the talk of preparing a statement ahead of time, but even then you still use the DB handle.
      my $sth = $dbconn->prepare($sql_statement); . . . . . . . my $hash = $dbconn->selectall_hashref($sth);
      As for setting the valuable RaiseError flag, it looks like you'll have to do that on the DB handle when using selectall_hashref, perhaps something like:
      { local $dbconn->{RaiseError} = 1; my $hash = $dbconn->selectall_hashref($sql_statement); . . . . . . . }
      Go back and read the DBI docs whenever something goes 'wrong' - sometimes it takes me a couple "read again"s before it sinks in to my flat file head.