How can you create a trigger with two tables?

Viewed 19

I have the tables

Contract_j (id_cj
            date
            object
            onoray
            nr_pages
            id_client)
Payment(id_cj
        id_payment
        date
        sum)

I have to create a trigger that makes sure that 'onorary' can't be modified if there is payment that is executed. How do I do that?

I was thinking maybe:

CREATE OR REPLACE TRIGGER secure_onorary
BEFORE UPDATE OF onorary On Contract_j c FOR EACH ROW
BEGIN
   IF  EXISTS(select id_cj from Payment where c.id_cj = id_cj)
   THEN RAISE_APPLICATION_ERROR(-20050, 'Nu puteti actualiza onorariul decat daca nu exista rate achitate');
   END IF;
END;

ORA-04079: invalid trigger specification , it shows me this error

0 Answers
Related