0

I created two tables:

CREATE TABLE "PARLAMENTO2018"."IMPIEGATO"
(
    "NOME" VARCHAR2(20 BYTE) NOT NULL ENABLE, 
    "STIPENDIO" NUMBER, 
    "NUMDIP" NUMBER, 
    CONSTRAINT "IMPIEGATO_PK" 
        PRIMARY KEY ("NOME")
    CONSTRAINT "IMPIEGATO_DIPARTIMENTO_FK1" 
        FOREIGN KEY ("NUMDIP")
        REFERENCES "PARLAMENTO2018"."DIPARTIMENTO" ("NUMDIP")
);

and

CREATE TABLE "PARLAMENTO2018"."DIPARTIMENTO" 
(
    "NUMDIP" NUMBER NOT NULL ENABLE, 
    "IMPIEGATO" VARCHAR2(20 BYTE), 
    CONSTRAINT "DIPARTIMENTO_PK" 
        PRIMARY KEY ("NUMDIP")
    CONSTRAINT "DIPARTIMENTO_IMPIEGATO_FK1" 
        FOREIGN KEY ("IMPIEGATO")
        REFERENCES "PARLAMENTO2018"."IMPIEGATO" ("NOME")
);

Now, I want create a trigger which sets an employe's (impiegato) salary (salario) at the same amount of the manager's salary of own department (dipartimento)

I wrote only this part of trigger

create or replace trigger reimposta_stipendio
before update on impiegato
for each row 


begin

  for c in(
    select stipendio
    from impiegato
    where nome=(
      select impiegato
      FROM dipartimento
      where numdip=(
        select numdip
        from impiegato
        where nome = :new.impiegato)))

  loop
    dbms_output.put('Stipendio: '||c.stipendio);
  end loop;


  null;
end;

but when I this trigger is runned, the system return me an error of table mutanting

keiichi
  • 113
  • 1
  • 1
  • 10
  • If error show up.. Please copy all error description.. It will get easier to identify what's error in your triggers.. – dwir182 Nov 22 '18 at 01:50
  • UPDATE "PARLAMENTO2018"."IMPIEGATO" SET STIPENDIO = '11' WHERE ROWID = 'AAAUW9AAEAAANK3AAB' AND ORA_ROWSCN = '10989213' One error saving changes to table "PARLAMENTO2018"."IMPIEGATO": Row 2: ORA-04091: table PARLAMENTO2018.IMPIEGATO is mutating, trigger/function may not see it ORA-06512: at "PARLAMENTO2018.REIMPOSTA_STIPENDIO", line 3 ORA-04088: error during execution of trigger 'PARLAMENTO2018.REIMPOSTA_STIPENDIO' – keiichi Nov 22 '18 at 10:19

0 Answers0