#!perl
use Win32::ODBC;
$Data = new Win32::ODBC("DSN=dhcp;UID=netman;PWD=netman;");
$Data2 = new Win32::ODBC("DSN=dhcp;UID=netman;PWD=netman;");
$Data1 = new Win32::ODBC("DSN=dhcp;UID=netman;PWD=netman;");
$Data3 = new Win32::ODBC("DSN=dhcp;UID=netman;PWD=netman;");
$Data->Sql("select ip,mac,host from dhcplist");
while ($Data->FetchRow())
{
($ip,$mac,$host) = $Data->Data;
print $host,"\n";
$Data1->Sql("select * from Employee ");
while ($Data1->FetchRow())
{
($cname,$dept,$dno,$id,$ext) = $Data1->Data;
print "$cname","\n";
print "$id","\n";
}
$Data1->Close();
$flag = '';
$Data2->Sql("select * from dhcp_data where host = '$host' and ip = '$ip' ");
#print "select * from dhcp_data where host = '$host' and ip = '$ip'" ;
while ($Data2->FetchRow())
{
#@flag = $Data2->Data;
if ( $flag ne "" )
{
print "ok";
$Data3->sql("update dhcp_data set ip = '$ip',host = '$host',mac ='$mac',cname = '$cname',dept = '$dept',dno = $dno',notesid = '$id',ext = '$ext',modifydate = getdate()");
$Data3->Close();
}
else
{
print "ok2";
$Data3->sql("insert into dhcp_data(ip,host,mac,cname,dept,dno,notesid,ext,modifydate) values('$ip','$host','$mac','$cname','$dept','$dno','$id','$ext',getdate())");
$Data3->Close();
}
}
$Data2->Close();
}
$Data->Close();