Probleme avec mon trigger sous oracle 10g

Résolu
Bonjour,

voici mes table:
Ligne_Coms (Num_Com ,Num_Pro ,Qte_Com );
Commandes (Num_Com ,Date_Com,Nbre_lc),Mtot_Com,Num_Cli)
Produits ( Num_Pro,Lib_Pro),Prix_U,Qtestock,Seuil_Reapro)

Mon trigger est sensé incrementer nbre_lc,recalculer mtot_com et soustraire qtestock pour chaque ajout d'une nouvelle ligne si la fonction verifier_qtecom(Qte_Com,Num_Pro)==true sinon l'opération d'ajout est annulée.

Voic ce que j'ai essayé:
CREATE TRIGGER ajoutCommande
AFTER INSERT
ON Ligne_Coms
FOR EACH ROW
Vl_Prix_U  Produits.Prix_U%TYPE;
BEGIN
   IF (verifier_qtecom(:NEW.Qte_Com,:NEW.Num_Pro)) then
	UPDATE Produits
		SET qtestock = qtestock - :new.Qte_Com
		WHERE Num_Pro = :new.Num_Pro
		RETURNING Prix_U INTO Vl_Prix_U;
 
	UPDATE Commandes 
		SET nbre_lc= nbre_lc+1,
		    Mtot_Com = Mtot_Com + :new.Qte_Com * Vl_Prix_U
		WHERE Ligne_Coms.Num_Com=Commandes.Num_Com ;
 
   ELSE 
	RAISE_APPLICATION_ERROR (-20001, 'Ajout annulé') ;
   END IF;
END;

L'execution de ce trigger me donne cette erreur:
4/3 	PL/SQL: SQL Statement ignored
5/92 	PL/SQL: ORA-00904: "LIGNE_COMS"."NUM_COM" : identificateur non va lide
7/3 	PL/SQL: SQL Statement ignored
8/30 	PL/SQL: ORA-00904: "QTE_COM" : identificateur non valide

Quelqu'un peut m'aider?


--
C'est en forgeant qu'on devient bucheron! TYJ!

6 réponses

  • Votes
  • Date
  • Date décroissante
  1. Pourrais tu poster la solution? que tous le monde puisse en tirer bénéfice
    1. Modérateur
      Salut,

      Au moins il faut :

      WHERE :new.Ligne_Coms.Num_Com=Commandes.Num_Com ;

      que pour la compréhension j'ecrirai :

      WHERE Commandes.Num_Com = :new.Ligne_Coms.Num_Com ;

      1. L'execution du code sous oracle me ressort ceci;
        Vl_Prix_U  Produits.Prix_U%TYPE;
        *
        
        ERREUR à la ligne 5 :
        ORA-04079: spécification de déclencheur erronée


        Tandisque show err trigger ajoutcommande me dit qu'il n'ya pa d'erreurs.
        1. Modérateur
          Parce qu'il faut avant un titre de paragraphe :

          DECLARE
          Vl_Prix_U Produits.Prix_U%TYPE;
          BEGIN
          ...

          1. voici l code:
            CREATE OR REPLACE TRIGGER ajoutCommande
            AFTER INSERT
            ON Ligne_Coms
            FOR EACH ROW
            DECLARE
            Vl_Prix_U  Produits.Prix_U%TYPE;
            BEGIN
               IF (verifier_qtecom(:NEW.Qte_Com,:NEW.Num_Pro)) then
            	UPDATE Produits
            		SET qtestock = qtestock - :new.Qte_Com
            		WHERE Num_Pro = :new.Num_Pro
            		RETURNING Prix_U INTO Vl_Prix_U;
             
            	UPDATE Commandes 
            		SET nbre_lc= nbre_lc+1,
            		    Mtot_Com = Mtot_Com + :new.Qte_Com * Vl_Prix_U
            		WHERE :new.Ligne_Coms.Num_Com=Commandes.Num_Com ;
             
               ELSE 
            	RAISE_APPLICATION_ERROR (-20001, 'Ajout annulé') ;
               END IF;
            END;
            
             

            voici le message après execution:
            Avertissement : Déclencheur créé avec erreurs de compilation.

            show err trigger ajoutcommande me donne ceci:
            13/9 	PLS-00049: variable de lien erronée 'NEW.LIGNE_COMS' 
            1. Modérateur
              bah faut essayer :new.Num_Com à la place de :new.Ligne_Coms.Num_Com