我正在尝试创建一个触发器,当我插入“director”模式和另一个表空间中的“Investigadores”时,该触发器应该验证“grado_academico”的新输入值。
这是我的桌子
CREATE TABLE director.Investigadores (
id_investigador numeric(6, 0) NOT NULL,
nombre varchar(40) NOT NULL, apellido_pat varchar(40) NOT NULL,
apellido_mat varchar(40) NOT NULL, grado_academico varchar(40) NOT NULL,
fecha_ingreso date NOT NULL, nivel_sni numeric(2, 0) NOT NULL,
CONSTRAINT id_investigador PRIMARY KEY (id_investigador))
tablespace sni_tablespace;
这是我的触发器
CREATE OR REPLACE TRIGGER verificarGrado
before insert on director.Investigadores
for each row
begin
IF (new.grado_academico='MC' OR new.grado_academico='DOCTOR' OR new.grado_academico='LICENCIATURA')
return new;
else
RAISE EXCEPTION 'El grado academico solo puede ser MC, DOCTOR o LICENCIATURA';
end if;
END;
/
但是当我创建触发器时会给我一个警告,所以我运行
SQL> show errors
ERROR:
ORA-00942: table or view does not exist
那么,如果我的表已经存在,为什么它会返回这个警告呢?
我的触发器不正确吗?
我的用户“主管”有权创建任何触发器。
我应该做更多的事情吗?
请我希望你能帮助我解决这个问题。
编辑
我使用架构更改了触发器
CREATE OR REPLACE TRIGGER director.verificarGrado
before insert on director.Investigadores
for each row
begin
IF (:new.grado_academico='MC' OR :new.grado_academico='DOCTOR' OR :new.grado_academico='LICENCIATURA')
then
:new.grado_academico:=:new.grado_academico;
else
RAISE EXCEPTION 'El grado academico solo puede ser MC, DOCTOR o LICENCIATURA';
end if;
END;/
给我同样的错误。
行 :new.grado_academico:=:new.grado_academico; 是我不确定我应该做什么的地方,我只需要插入继续进行
编辑 我改变了我使用的条件的逻辑如果不是......谢谢你的建议
无论如何,看起来这是一个关于权限的问题,我仍然不知道如何解决它。