[Kc] why doesn't this work - fetchrow_array

Daryl Fallin darylvf at gmail.com
Thu Sep 20 09:25:34 PDT 2007

Even when the query is empty the If clause in the while loop will not print
"name NOT defined"

I suspect this has something to do with fetchrow_array and using !defined()
doesn't work.


my $query = "select deviceip, devicename from (select * from admDevice where
admDevice.devicename like \'%$_%\') as devi
    ces, admSyslogSrc where devices.deviceId = admSyslogSrc.deviceId";

$sth = $dbh->prepare($query);

if( defined( $sth )) {
    $sth->execute(  );

while ( my ($hostint, $name) = $sth->fetchrow_array ) {
    if ( !defined($name) ) {
        print "name NOT defined";
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/pipermail/kc/attachments/20070920/44859df9/attachment.html 

More information about the kc mailing list