hello all,
I worked out what I need to do, but I'm not
sure why the first thing I tried did not work.
observe the following code snippet:
$qry = "SELECT * FROM table WHERE field=5";
$sth = $dbconn->prepare($qry);
$sth->execute or die($sth->errstr);
$row1 = $sth->fetchrow_hashref;
print " got here ** ";
if ($row1 not "") {
print "row not empty";
} else {
print "row is empty";
}
when my SQL query returns no rows
this prints out:
got here ** row is empty
now the following code:
$qry = "SELECT * FROM table WHERE field=5";
$sth = $dbconn->prepare($qry);
$sth->execute or die($sth->errstr);
$row1 = $sth->fetchrow_hashref;
$temp = $$row1{'field'};
print " got here ** ";
if ($row1 ne "") {
print "row not empty";
} else {
print "row is empty";
}
with the same SQL statement and database
prints out:
got here ** row not empty
why? why is the reference not undef still
in the second case? By dereferencing an
undef reference it becomes defined? Isn't
that akin to raising the dead? I am running activestate Perl 5.004 under win98se. I
am
using DBD::ADO and an access2000 database.
thanks for any help,
andrew