TRIGGER

Document Sample
TRIGGER Powered By Docstoc
					  1 CREATE OR REPLACE TRIGGER SECURE_EMP
  2 BEFORE
  3 INSERT ON EMP
  4 BEGIN
  5 IF TO_CHAR(SYSDATE,'DY') IN ('SAT','SUN') THEN
  6 RAISE_APPLICATION_ERROR(-2001,'YOU MAY NOT INSERT DURINF BUSSINESS
HOURS');
  7 END IF;
  8* END;
SQL> /


SQL> INSERT INTO EMP(EMPNO,ENAME,JOB,DEPTNO)
  2 VALUES(7,'TOOBA','ABC',10);

1 row created.

SQL> SELECT * FROM EMP;


  1    CREATE OR REPLACE TRIGGER SECURE_EMP
  2    BEFORE INSERT ON EMP
  3    BEGIN
  4    IF TO_CHAR(SYSDATE,'DY') IN ('SAT','SUN') OR
  5 TO_CHAR(SYSDATE,'HH:MI') NOT BETWEEN '08:00' AND '18:00' THEN
  6    RAISE_APPLICATION_ERROR(-2001,'YOU MAY NOT INSERT DURINF BUSSINESS
HOURS');
  7    END IF;
  8* END;
SQL> /

Trigger created.

SQL> INSERT INTO EMP(EMPNO,ENAME,JOB,DEPTNO)
  2 VALUES(7,'TOOBA','ABC',10);

				
DOCUMENT INFO
Shared By:
Categories:
Stats:
views:2
posted:11/1/2012
language:
pages:1