in reply to DBI error

From the DBI pod:

       "fetchall_hashref" NEW
             $hash_ref = $dbh->fetchall_hashref($key_field);

           The "fetchall_hashref" method can be used to
           fetch all the data to be returned from a pre­
           pared and executed statement handle. It returns
           a reference to a hash that contains, at most,
           one entry per row.

           If there are no rows to return,
           "fetchall_hashref" returns a reference to an
           empty hash. If an error occurs,
           "fetchall_hashref" returns the data fetched
           thus far, which may be none.  You should check
           "$sth-">"err" afterwards (or use the "RaiseEr­
           ror" attribute) to discover if the data is com­
           plete or was truncated due to an error.

           The $key_field parameter provides the name of
           the field that holds the value to be used for
           the key for the returned hash.  For example:

             $dbh->{FetchHashKeyName} = 'NAME_lc';
             $sth = $dbh->prepare("SELECT FOO, BAR, ID,
                              NAME, BAZ FROM TABLE");
             $hash_ref = $sth->fetchall_hashref('id');
      
           The $key_field parameter can also be specified
           as an integer column number (counting from 1).
           If $key_field doesn't match any column in the
           statement, as a name first then as a number,
           then an error is returned.

           This method is normally used only where the key
           field value for each row is unique.  If multi­
           ple rows are returned with the same value for
           the key field then later rows overwrite earlier
           ones.


           The $key_field parameter can also be specified
           as an integer column number (counting from 1).
           If $key_field doesn't match any column in the
           statement, as a name first then as a number,
           then an error is returned.

           This method is normally used only where the key
           field value for each row is unique.  If multi­
           ple rows are returned with the same value for
           the key field then later rows overwrite earlier
           ones.

       print "Name for id 42 is $hash_ref->{42}->{name}\n";

           The $key_field parameter can also be specified
           as an integer column number (counting from 1).
           If $key_field doesn't match any column in the
           statement, as a name first then as a number,
           then an error is returned.

           This method is normally used only where the key
           field value for each row is unique.  If multi­
           ple rows are returned with the same value for
           the key field then later rows overwrite earlier
           ones.

You need a unique key from the data to index the hash.

After Compline,
Zaxo