$query = undef; $sth = undef; $ect = 0; @row = (); $macidx = undef; $query = "SELECT clmacidx FROM tblmac where clmac = ?"; if($debug == 1) { print "QUERY: \"$query\"\n"; } $sth = $dbh->prepare($query); $sth->execute($mac); $sth->bind_columns(undef, \$macidx); while(@row = $sth->fetchrow_array()) { $ect++; } $sth->finish; #### $macidx is now the value of "clmacidx" from select statement if($ect != 1) { print "UNK ECT: \"$ect\" FOR MAC: \"$mac\" L: \"" . __LINE__ . "\" NEXT\n"; } if(!(defined $macidx) || ($macidx eq "")) { print "MACIDX: \"$macidx\" IS UNDEF NEXT L: \"" . __LINE__ . "\"\n"; } if($debug == 1) { print "MACIDX: \"$macidx\" L: \"" . __LINE__ . "\"\n"; }