I`m trying to solve a trigger issue. So I have to replace the value for every inserted row with new value from the sequence DEPARTMENTS_SEQ. And I ended up here
create or replace TRIGGER hr_insert_tr on DEPARTMENTS
BEFORE INSERT on DEPARTMENTS
for each ROW
BEGIN
DEPARTMENT_ID = :new.DEPARTMENTS_SEQ;
END;
CodePudding user response:
That would be
create or replace trigger hr_insert_tr
before insert on departments
for each row
begin
:new.department_id := departments_seq.nextval;
end;
/