<?xml version="1.0" encoding="windows-1252"?>
<node id="596763" title="Re: use of DBI perl function fetchall_arrayref" created="2007-01-26 12:53:54" updated="2007-01-26 07:53:54">
<type id="11">
note</type>
<author id="209598">
ptum</author>
<data>
<field name="doctext">
&lt;p&gt;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:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;You don't check if the fetchall_arrayref was successful, in terms of displaying $DBI::errstr.&lt;/li&gt;
&lt;li&gt;You don't check if the array reference is really an array reference.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt; I usually do something like this:&lt;/p&gt;
&lt;code&gt;
my $ary_ref = $sth-&gt;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
  }
}
&lt;/code&gt;</field>
<field name="root_node">
596638</field>
<field name="parent_node">
596638</field>
</data>
</node>
