Oracleデータベース・トリガー・データの確認
詳細
一需要
給料が上がるほど少なくなるわけにはいかない.
にコード
一需要
給料が上がるほど少なくなるわけにはいかない.
にコード
-- 2:
--
/*
:old :new
:new ,
:old ,
*/
create or replace trigger checksalary
before update
on emp
for each row
begin
if:old.sal >:new.sal then
raise_application_error(-20002,' '||:old.sal||' '||:new.sal);
endif;
end;
/
SQL> update emp set sal=sal+1 where empno=7839;
1 。
SQL> update emp set sal=sal-1 where empno=7839;
update emp set sal=sal-1 where empno=7839
*
1 :
ORA-20002: 10101 10100
ORA-06512: "SCOTT.CHECKSALARY", line 3
ORA-04088: 'SCOTT.CHECKSALARY'