Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: use of DBI perl function fetchall_arrayref

by ptum (Priest)
on Jan 26, 2007 at 17:53 UTC ( #596763=note: print w/ replies, xml ) Need Help??


in reply to use of DBI perl function fetchall_arrayref

It sounds like others have already pointed you to some good resources for derefencing, etc., but there are two things which are conspicuous in their absence from your code:

  • You don't check if the fetchall_arrayref was successful, in terms of displaying $DBI::errstr.
  • You don't check if the array reference is really an array reference.

I usually do something like this:

my $ary_ref = $sth->fetchall_arrayref(); if ($DBI::errstr) { print "Error detected: $DBI::errstr\n"; return; } else { if (ref($ary_ref) eq 'ARRAY') { # go on to process the array reference. } else { # do something with Data::Dumper } }


Comment on Re: use of DBI perl function fetchall_arrayref
Download Code
Replies are listed 'Best First'.
Re^2: use of DBI perl function fetchall_arrayref
by Anonymous Monk on Sep 02, 2009 at 12:01 UTC
    The fetchall_arrayref method can be used to fetch all the data to be returned from a prepared and executed statement handle. It returns a reference to an array that contains one reference per row.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (13)
As of 2015-07-28 20:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (258 votes), past polls