Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

DBI 1.3.7->1.4.5

by Anonymous Monk
on Nov 12, 2004 at 16:14 UTC ( #407402=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I have been using DBI 1.3.7 in our system and the perl code runs fine. However, when upgraded to 1.4.5 I get the follow error: DBD::ASAny::db selectall_hashref warning: at /home/licgen/perl/lib/iAS/LicGen/Database.pm line 1429. DBD::ASAny::db selectall_hashref warning: at /home/licgen/perl/lib/iAS/LicGen/Database.pm line 987. The warning is not too specific so I cant find out whats wrong. I've also checked the DBI changelog and cannot find anything particular about selectall_hashref. Does anyone know whats changed?

Replies are listed 'Best First'.
Re: DBI 1.3.7->1.4.5
by mpeppler (Vicar) on Nov 12, 2004 at 16:28 UTC
    I'd start by looking at the Database.pm module, which appears to be something that is local to your installation.

    You could add a $SIG{__WARN__} handler to print out a perl stack trace when the warnings occur to see if that gives you more information - something like:

    use Carp qw(cluck); $SIG{__WARN__} = sub { cluck(@_); } ... rest of code...
    You can also enable DBI tracing (DBI->trace(3)) to see what calls are being made around the location of the warnings.

    Michael

      But my code is done according to the docs. I cant see whats wrong with the selectall_hashref
        I don't really know what might be wrong - I haven't used DBD::ASAny. But what you need right now is more information - and the steps I suggested are one way of getting that.

        Michael

Re: DBI 1.3.7->1.4.5
by pingo (Hermit) on Nov 12, 2004 at 16:23 UTC
    I'm not too sure about what version it changed in, but in newer versions the number of params to selectall_hashref has changed:

    Old:
    $ary_ref = $dbh->selectall_hashref($statement);

    New:
    $hash_ref = $dbh->selectall_hashref($statement, $key_field);

    To quote the man page:
    This utility method combines the prepare, execute, and fetchall_hashref entries elsewhere in this document into a single call. It returns a reference to a hash containing one entry for each row. The key for each row entry is specified by $key_field. The value is a reference to a hash returned by "fetchrow_hashref".
      This is my relevant code:

      my $key_field = "ACCOUNT_ID";

      my $stmt = "SELECT ea_id AS $key_field, " .
      " ea_account_name AS ACCOUNT_NAME, " .
      " ea_password AS PASSWORD, " .
      " ea_inbox_server AS INBOX_SERVER, " .
      " ea_email_address AS EMAIL_ADDRESS, " .
      " ea_accept_requests AS ACCEPT_REQUESTS " .
      "FROM email_account " .
      " where ea_accept_requests = 'Y'";

      $email_accounts = $dbh->selectall_hashref( $stmt, $key_field );

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (5)
As of 2021-01-23 14:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?