Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^3: Having problems with DBI selectall_arrayref

by Corion (Pope)
on Dec 26, 2020 at 18:57 UTC ( #11125752=note: print w/replies, xml ) Need Help??


in reply to Re^2: Having problems with DBI selectall_arrayref
in thread Having problems with DBI selectall_arrayref

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;

Replies are listed 'Best First'.
Re^4: Having problems with DBI selectall_arrayref
by SergioQ (Beadle) on Dec 26, 2020 at 20:33 UTC

    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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11125752]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (6)
As of 2021-04-22 12:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?