On Thu, 20 Sep 2007 11:25:34 -0500
"Daryl Fallin" <[EMAIL PROTECTED]> wrote:

> 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";
>     }
> 

  To echo what Teal said, $name is 'defined', it just happens
  to be defined to an empty string ( aka NULL ) if the column
  is null.  

 -------------------------------------------------------
   Frank Wiles, Revolution Systems, LLC. 
     Personal : [EMAIL PROTECTED]  http://www.wiles.org
     Work     : [EMAIL PROTECTED] http://www.revsys.com 

_______________________________________________
kc mailing list
[email protected]
http://mail.pm.org/mailman/listinfo/kc

Reply via email to