PROGRAMS WITH TRIGGERS | HOW TO CREATE TRIGGER IN SQL | UPDATE AND DELETE TIRGGER

AIM :
To write and execute a SQLprogram using triggers.

TRIGGERS:

A trigger is a statement that the system executes automatically as a side effect of a modification to the database.

ALGORITHM:

Create a trigger
If there is a updating in client master table, then enter the modification into -audit client table.
If there is a deletion in client master table, then enter the deletion into audit client -table.

View the audit client table.
Stop the program.


PROGRAM:


SQL> create or replace trigger auditclient1 after update or delete on clientmaster1 for each row
2 declare
3 oper varchar(8);
4 clie ntno clientmaster1.clientno %type;
5 name clientmaster1.name %type;
6 baldue clientmaster1.baldue %type;
7 begin
8 if updating then
9 oper:='update';
10 end if;
11 if deleing then
12 oper:='delete';
13 end if;
14 clientno:=:old.baldue;
15 insert into auditclient1 values(clientno,name,baldue,oper,sysdate);
16 end auditclient1;
17 /

Trigger created

Related post