in reply to Interface flap detection in Perl
withmy $iface_result = $dbh->prepare("UPDATE device_iface_cache SET interf +ace_status='$stat', lastcheck='$date', hostname='$host' WHERE hostnam +e='$host' AND interface_name='$int_table{$key}';"); $iface_result->execute();
(no need to set hostname again where you select on it) or even easier, using DBIx::Simple with SQL::Abstract:my $iface_result = $dbh->prepare("UPDATE device_iface_cache SET interf +ace_status=?, lastcheck=? WHERE hostname=? AND interface_name=?"); $iface_result->execute($stat, $date, $host, $int_table{$key});
(DBIx::Simple uses a database handle that replaces DBI's $dbh, but is not exactly the same thing. Hence the different name $db. You get it by connecting through DBIx::Simple->connect instead of DBI->connect.)$db->update('device_iface_cache', { interface_status => $stat, lastcheck => $date }, { hostname => $host, interface_name => $int_table{$key} } );
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Interface flap detection in Perl
by sunnyfedora99 (Novice) on Apr 13, 2011 at 14:11 UTC | |
by moritz (Cardinal) on Apr 13, 2011 at 14:20 UTC | |
by sunnyfedora99 (Novice) on Apr 13, 2011 at 14:39 UTC | |
by sunnyfedora99 (Novice) on Apr 14, 2011 at 09:09 UTC |