Name Type Nullable Default Comments
-------- ------------ -------- ------- --------
EMPNO NUMBER(4)
ENAME VARCHAR2(10) Y
JOB VARCHAR2(9) Y
MGR NUMBER(4) Y
HIREDATE DATE Y
SAL NUMBER(7,2) Y
COMM NUMBER(7,2) Y
DEPTNO NUMBER(2) Y
表结构是这样的,为什么触发器会报错啊,找不到哪里错了,大家帮忙看下哦create trigger emp_trigger2
before update of sal,comm or delete
on emp
for each row
when (old.job='SALESMAN')
BEGIN
case when updating('sal') then
if :new.sal< :old.sal then
raise_application_error(-20001,'职业为saleman的员工工资不能降');
end if;
when updating('comm') then
if :new.comm< :old.comm then
raise_application_error((-20001,'职业为saleman的员工comm不能降');
end if;
when deleting
raise_application_error(-20003,'职业为saleman的员工不能删');
end case;
end
drop trigger emp_trigger
update emp set sal=2000.00 where ename='ALLEN' and job='SALEMAN'
-------- ------------ -------- ------- --------
EMPNO NUMBER(4)
ENAME VARCHAR2(10) Y
JOB VARCHAR2(9) Y
MGR NUMBER(4) Y
HIREDATE DATE Y
SAL NUMBER(7,2) Y
COMM NUMBER(7,2) Y
DEPTNO NUMBER(2) Y
表结构是这样的,为什么触发器会报错啊,找不到哪里错了,大家帮忙看下哦create trigger emp_trigger2
before update of sal,comm or delete
on emp
for each row
when (old.job='SALESMAN')
BEGIN
case when updating('sal') then
if :new.sal< :old.sal then
raise_application_error(-20001,'职业为saleman的员工工资不能降');
end if;
when updating('comm') then
if :new.comm< :old.comm then
raise_application_error((-20001,'职业为saleman的员工comm不能降');
end if;
when deleting
raise_application_error(-20003,'职业为saleman的员工不能删');
end case;
end
drop trigger emp_trigger
update emp set sal=2000.00 where ename='ALLEN' and job='SALEMAN'
解决方案 »
- ODI加载大数据非常缓慢,不确定是磁盘问题还是sql问题,求解答
- 分组筛选SQL语句求教
- 急,存储过程参数长度不够问题!!!
- ORACLE 10G中有关闪回问题
- .net 连接 linux 下Oracle 10.2 求助
- rac 下一个节点的归档日志满了,删除不了。
- 游标CURSOR问题
- 在ArcGIS Engine中如何创建一个组件实现把创建和管理geodatabase的API进行封装
- 如何对SQl语句中的IN表达式使用参数?
- 更改SQL语句Oracle必须重启才升效???
- oracle数据库中数据前后带有空格,如何用sql语句去掉
- 表结构如下所示是否能够去出,GWET,QTY中的重复的数据,(Oracle的)
create or replace trigger emp_trigger2
before update of sal,comm or delete
on emp
for each row
when (old.job='SALESMAN')
BEGIN
case
when updating('sal') then
if :new.sal< :old.sal then
raise_application_error(-20001,'职业为saleman的员工工资不能降');
end if;
when updating('comm') then
if :new.comm< :old.comm then
raise_application_error(-20001,'职业为saleman的员工comm不能降');--多个括号
end if;
when deleting then --少个then
raise_application_error(-20003,'职业为saleman的员工不能删');
end case;
end;
/
--你的测试部分估计也不会有你想要的结果,job='SALESMAN'吧,还有ename注意大小写,可用upper(ename)=...
update emp set sal=2000.00 where ename='ALLEN' and job='SALEMAN'
update emp set sal=2000.00 where ENAME='ALLEN' and JOB='SALEMAN'
但是用这两句测试都提示 0行被更新。按理说工资调成2000 应该是没问题的啊。而且oracle对于列的大小写没有限制
ora06512 line4
ora04088 触发器执行过程中出错
怎么回事啊