http://qs321.pair.com?node_id=11125749


in reply to Having problems with DBI selectall_arrayref

->selectall_hashref does not return an array of hashrefs. You want ->selectall_arrayref:

my $data_all = $connection->selectall_arrayref($query, { 'Columns' => + {} } );

Replies are listed 'Best First'.
Re^2: Having problems with DBI selectall_arrayref
by SergioQ (Beadle) on Dec 26, 2020 at 17:18 UTC
    Was just editing my question, you can see the update there. It still is confusing on the return.

      Sorry, I posted my reply too hastily. The second parameter you pass to ->selectall_arrayref must be a hash with the key Slice, not Columns:

      my $data_all = $connection->selectall_arrayref($query, { Slice => {} +} );

      Then, each element of $data_all will be a hashref (not a hash as you assume):

      my $currec = $row; foreach my $columns (keys %$currec){ say $columns; say $currec{$columns}; }

      Whenever you're in doubt about a data structure, consider using Data::Dumper to print it:

      use Data::Dumper; say Dumper $row;

        Then, each element of $data_all will be a hashref (not a hash as you assume)

        Thank you so much! This was killing me! And a big duh on my assumption error.

        I love that there's still a place on the internet where people can get helped, without being scolded (for their own errors, or judgement answers like "why do you want to do that?" Am old enough to miss newsgroup forums for help.

        Thank you again.