Bonjour,
Voila mon code :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| my $db_trap =
"SELECT * FROM traps ;";
verb("Mysql Query: $db_trap");
my $sth_trap = $dbh->prepare($db_trap);
if ( !$sth_trap->execute() ) {
print
"CRITICAL ERROR - Unable to execute '$db_trap' on server '$HOSTNAME' connected as user '$USERNAME' - $DBI::errstr\n";
exit $ERRORS{"CRITICAL"};
}
my $db_trap_relation ="SELECT * FROM traps_service_relation ;";
verb("Mysql Query: $db_trap_relation");
my $sth_trap_relation = $dbh->prepare($db_trap_relation);
if ( !$sth_trap_relation->execute() ) {
print
"CRITICAL ERROR - Unable to execute '$db_trap_relation' on server '$HOSTNAME' connected as user '$USERNAME' - $DBI::errstr\n";
exit $ERRORS{"CRITICAL"};
}
my $compteur=1;
while ( my @list_trap = $sth_trap->fetchrow_array ) {
while ( my @list_trap_relation = $sth_trap_relation->fetchrow_array ) {
if($list_trap[0] == $list_trap_relation[1]){
my $db_nom_service = "SELECT service_description FROM service WHERE service_id = '$list_trap_relation[2]' LIMIT 1;";
my $sth_nom_service = $dbh->prepare($db_nom_service);
$sth_nom_service->execute();
my $nom_service = $sth_nom_service->fetchrow_array();
}
}
$compteur=$compteur+1;
} |
J'aimerais pouvoir incrémenter les données contenu dans list_trap_relation a chaque boucle de list_trap.
Apres avoir fait quelque test , je me rend compte que seul la premiere valeur de list_trap est accessible dans :
while ( my @list_trap_relation = $sth_trap_relation->fetchrow_array ) {
En gros j'ai une liste d'un champ ID dans la premiere table @list_trap, et j'aimerais comparer chaque valeur de ce champs aux valeur du champs TEMP_ID contenu dans @list_trap_relation
Merci pour votre aide.
Partager