Oracleデータベース・トリガの複雑なセキュリティ・チェック
詳細
一需要
非就業禁止新入社員の従業員表への挿入禁止
にコード
三検証
SQL> insert into emp(empno,ename,sal,deptno) values(1003,'Tome','3000',10);
insert into emp(empno,ename,sal,deptno) values(1003,'Tome','3000',10)
*
1行目のエラー:
ORA-20001:非勤務時間における新入社員の挿入を禁止する
ORA-06512:「SCOTT.SECURITYEMP」、line 5
ORA-04088:トリガ'SCOTT.SECURITYEMP'の実行中にエラーが発生しました
一需要
非就業禁止新入社員の従業員表への挿入禁止
にコード
-- 1:
--
/*
1、 :to_char(sysdate,'day') in (' ',' ')
2、 :to_number(to_char(sysdate,'hh24')) not between 9 and 18
*/
create or replace trigger securityemp
before insert
on emp
begin
if to_char(sysdate,'day')in(' ',' ')or
to_number(to_char(sysdate,'hh24'))not between 9and18then
-- insert
raise_application_error(-20001,' ');
endif;
end;
/
三検証
SQL> insert into emp(empno,ename,sal,deptno) values(1003,'Tome','3000',10);
insert into emp(empno,ename,sal,deptno) values(1003,'Tome','3000',10)
*
1行目のエラー:
ORA-20001:非勤務時間における新入社員の挿入を禁止する
ORA-06512:「SCOTT.SECURITYEMP」、line 5
ORA-04088:トリガ'SCOTT.SECURITYEMP'の実行中にエラーが発生しました