Oh help me please Holy Monks, this one is killing me.

I have an old pm module that does all the connecting and querying with MySQL, so I have faith in it.

Now I am trying to retrieve multiple rows with all columns using selectall_hashref and am tripping all over myself.

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

And I get back: Not an ARRAY reference at /usr/local/lib/x86_64-linux-gnu/perl/5.26.1/DBI.pm line 2106.

I know all the column names, this is not a read any strange table function.

Somewhere my approach has it all wrong, should I take a different approach?

What I am trying to get back is an array of hash references, that's al, to my multiple row query, and yes my query works manually.

Can you help me?

p.s. I found this thread <a href="https://www.perlmonks.org/?node_id=1040177 "target="_blank> How does DBI return an arrayref with key/value pairs? so I tried that, switching to selectall_arrayref

But when I ran

for my $row (@$data_all)<br> {<br> my %currec = $row;<br> foreach my $columns (keys %currec){<br> say $columns;<br> say $currec{$columns};<br> }<br> }

What I got back was that $columns was another hash, and that led my second "say" to output nothing.

So confused


In reply to Having problems with DBI selectall_arrayref by SergioQ

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.