TRIGGER WHICH WILL BE FIRED TO DELETING A RECORD FROM DEPT TABLE BUT BEFORE THAT IT DELETES THE CORRESPONDING EMPLOYEE INFORMATION IN ORACLE?



SQL> CREATE TRIGGER DEPT_TRIG
  2  BEFORE DELETE ON DEPT FOR EACH ROW
  3  BEGIN
  4  DELETE FROM EMP WHERE DEPTNO= :OLD.DEPTNO
  5  DBMS_OUTPUT.PUT_LINE(SQL%ROWCOUNT
      ||'RECORDS ARE DELETED FROM EMP');
  6  END;
  7  /

Trigger created.

SQL> @ TIRGGER1;

Trigger created.

SQL> DELETE FROM DEPT WHERE DEPTNO=20;

1 row deleted.

Comments

Popular posts from this blog

Write a program to add two number using inline function in C++?

Traversing of elements program with algorithm and Flowchart