Discussion:
dbi selectall_hashref drops results
Kyle A. Hamilton
2015-05-15 14:56:58 UTC
Permalink
I ran into an issue where dbi’s selectall_hashref will drop results returned from the database. If I change the query to count the number of results returned, it returns 96, but I am missing some records that I get when I manually query the database. If I use selectall_array ref and loop through the results, I get the same data as I get from manually querying the database. I can provide the proprietary code as an example, just want to make sure this is the correct place to submit this.

Kyle A. Hamilton | OSS Administrator
Office: 515-830-0577

[Loading Image...]<http://www.IowaNetworkServices.com/> 312 8th St
Des Moines, IA 50322
800-CALL-INS
www.IowaNetworkServices.com<http://www.iowanetworkservices.com/>

[Loading Image...]<http://insfamilyofcompanies.com>

How are we doing? Let us know here.<http://www.IowaNetworkServices.com/feedback/>

We’re on the front line for your back office
 from our new corporate headquarters! We have moved to 7760 Office Plaza Drive South, West Des Moines, IA 50266

This message may contain confidential and/or privileged information. If you are not the addressee or authorized to receive this for the addressee, you must not use, copy, disclose, or take any action based on this message or any information herein. If you have received this message in error, please advise the sender immediately by reply e-mail and delete this message. Thank you for your cooperation.
Martin J. Evans
2015-05-15 15:13:29 UTC
Permalink
I ran into an issue where dbi’s selectall_hashref will drop results
returned from the database. If I change the query to count the number
of results returned, it returns 96, but I am missing some records
that I get when I manually query the database. If I use
selectall_array ref and loop through the results, I get the same data
as I get from manually querying the database. I can provide the
proprietary code as an example, just want to make sure this is the
correct place to submit this.
For selectall_hashref you have to give it a key field. If that field is not a unique key you will lose rows.

Martin
Kyle A. Hamilton
2015-05-15 15:19:00 UTC
Permalink
There's the issue. I was using a primary key from the database as the hash key so I assumed there were no duplicates. Just did a manual query and there are duplicate ids, must be my query or the database.

Thank you!

-----Original Message-----
From: Martin J. Evans [mailto:***@ntlworld.com]
Sent: Friday, May 15, 2015 10:13 AM
To: Kyle A. Hamilton; 'dbi-***@perl.org'
Subject: Re: dbi selectall_hashref drops results
I ran into an issue where dbi’s selectall_hashref will drop results
returned from the database. If I change the query to count the number
of results returned, it returns 96, but I am missing some records that
I get when I manually query the database. If I use selectall_array ref
and loop through the results, I get the same data as I get from
manually querying the database. I can provide the proprietary code as
an example, just want to make sure this is the correct place to submit
this.
For selectall_hashref you have to give it a key field. If that field is not a
Loading...