Racolta Tudor
Racolta Tudor

Reputation: 51

insert trigger ORACLE

I'm trying to create an AFTER INSERT TRIGGER ON Certificare that will update the "salariu" value for that specific person,identified by "idan" with the old value + 100.. I did write the follow trigger and when I try to insert into Certificare it says the following: 04098. 00000 - "trigger '%s.%s' is invalid and failed re-validation"

Here are the 2 tables and the trigger :

CREATE TABLE Angajati(
    idan INT PRIMARY KEY,
    numean VARCHAR(30),
    salariu INT
    );
CREATE TABLE Certificare(
    idan INT,
    idav INT,
    PRIMARY KEY(idan,idav),
    FOREIGN KEY (idan) REFERENCES Angajati(idan),
    FOREIGN KEY (idav) REFERENCES Aeronave(idav)
    );
CREATE TRIGGER trigNou
    AFTER INSERT ON Certificare
    BEGIN
        UPDATE Angajati
        SET salariu=salariu+100
        WHERE new.idan IN (SELECT idan FROM Angajati);
    END;

PS: I'm working in SQL Developer

Upvotes: 1

Views: 82

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1269463

I would expect something like this:

CREATE TRIGGER trigNou AFTER INSERT ON Certificare
FOR EACH ROW
BEGIN
    UPDATE Angajati
        SET salariu = salariu+100
    WHERE :new.idan = Angajati.idan;
END;

Upvotes: 1

Related Questions