Question

enter image description here

CREATE SEQUENCE EVALUATIONS_SEQ
  INCREMENT BY 1
  START WITH 1 ORDER;

CREATE OR REPLACE TRIGGER NEW_EVALUATION_TRIGGER
  BEFORE INSERT ON angajati
  FOR EACH ROW
  BEGIN
    :NEW.id_angajat := evaluations_seq.NEXTVAL
  END;

how can i test this trigger?

enter image description here

Was it helpful?

Solution

When I write triggers to create auto-incremented values in Oracle, I use the syntax:

select evaluations_seq.NEXTVAL into :NEW.id_angajat from dual;

I haven't used a direct assignment. Try this and see if it fixes the problem.

(I also express deep appreciation that they have finally put this functionality directly into the language, so triggers aren't needed in Oracle 12, just a default statement in create table.)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top