DECLARE Eno NUMBER 1 Name VARCHAR220 N Job VARCHAR220 Sal NUMBER BEGIN DEMOEno

Declare eno number 1 name varchar220 n job varchar220

This preview shows page 8 - 11 out of 16 pages.

Image of page 8
EMP TABLE (BEFORE INSERT) 7.WRITE A DATABASE TRIGGER TO UPDATE THE SAL FIELD.IF SAL IS MORE THAN5000 OR LESS THAN 1000 THEN RAISE THE ERROR.(BEFORE UPDATE).8.WRITE A DATABASE TRIGGER WHERE WHEN CONDITION IS SPECIFIED. WHEN JOB IS MANAGER THEN CHECK FOR SALARY. 16.WRITE A DATABASE TRIGGER WHICH FIRES BEFORE PERFORMING INSERT OR UPDATE OPERATIONS. IF THE JOB IS MANAGER THEN HIS SALARY SHOULD BE IN THE GRADE 5.ELSE RAISE THE APPLICATION ERROR._________________________________________________________________________ 9
Image of page 9
A VARCHAR2(10); BEGIN --select to_char(sysdate,'hh24') into a from dual; A:=TO_CHAR(SYSDATE,'HH24'); IF TO_NUMBER(A) > 19 OR TO_NUMBER(A) < 7 then RAISE_APPLICATION_ERROR(-20500,'YOU CANT DO THIS OPERATION NOW'); END IF; END; ....... ASSG ......... WRITE A DATABASE TRIGGER WHICH FIRES IF YOU TRY TO INSERT ,UPDATE OR DELETE AFTER 7'O' CLOCK CREATE OR REPLACE TRIGGER GEETIME BEFORE INSERT ON EMP for each row DECLARE A VARCHAR2(10); BEGIN SELECT TO_CHAR(SYSDATE,'HH:MI') INTO A FROM DUAL; IF A > '07:00' then RAISE_APPLICATION_ERROR(-20500,'YOU CANT DO THIS OPERATION NOW'); END IF; END; output after the insert operation is SQL> insert into emp(empno,deptno) values(7788,20); insert into emp(empno,deptno) values(7788,20) * ERROR at line 1: ORA-20500: YOU CANT DO THIS OPERATION NOW ORA-06512: at "GEETHA.GEETIME", line 6 ORA-04088: error during execution of trigger 'GEETHA.GEETIME' _______________________________________________________________________
Image of page 10
Image of page 11

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture