my $dbh = DBI->connect('dbi:ODBC:driver=Microsoft Access Driver (*.mdb, *.accdb);dbq=D:\Project\Project\BSC_KPIMonitoring\CHN\E_BSC_KPIMonitorDB.mdb'); my $stat1="SELECT * FROM SDCCHBLOCKING WHERE NE=?"; my $sth1 = $dbh->prepare($stat1); my $stat2="SELECT * FROM SDCCHDROP WHERE NE=?"; my $sth2 = $dbh->prepare($stat2); my $stat3="SELECT * FROM TCHBLOCKING WHERE NE=?"; my $sth3 = $dbh->prepare($stat3); my $stat4="SELECT * FROM TCHDROP WHERE NE=?"; my $sth4 = $dbh->prepare($stat4); my $sqlstatement="SELECT * FROM KPI_Master"; my $sth = $dbh->prepare($sqlstatement); $sth->execute || die "Could not execute SQL statement ... maybe invalid?"; while (my @row=$sth->fetchrow_array()){ $bsc = $row[0]; $kpi = $row[1]; $thresh= $row[2]; if($kpi eq "SDCCHBLOCKING") { $sth1->execute($bsc) || die "Could not execute SQL statement ... maybe invalid?"; while (my @row1=$sth1->fetchrow_array()) { if($row1[2]>$thresh) { print "SB,$bsc,$thresh,/$row1[2]"; } } } if($kpi eq "SDCCHDROP") { $sth2->execute($bsc) || die "Could not execute SQL statement ... maybe invalid?"; while (my @row2=$sth2->fetchrow_array()) { if($row2[2]>$thresh) { print "SD,$bsc,$thresh,/$row2[2]"; } } } if($kpi eq "TCHBLOCKING") { $sth3->execute($bsc) || die "Could not execute SQL statement ... maybe invalid?"; while (my @row3=$sth3->fetchrow_array()) { if($row3[2]>$thresh) { print "TB,$bsc,$thresh,/$row3[2]"; } } } if($kpi eq "TCHDROP") { $sth4->execute($bsc) || die "Could not execute SQL statement ... maybe invalid?"; while (my @row4=$sth4->fetchrow_array()) { if($row4[2]>$thresh) { print "TD,$bsc,$thresh,/$row4[2]"; } } }