HIGH LEVEL LANGUAGE EXTENSION
WITH
TRIGGERRS
AIM:
To write a
mysql program to create triggers for deletion and updating operation.
Algorithm:
1.
start the program.
2.
2.create a trigger named t1 for deletion and updation
operation.
3.
if deletion or updation operation is performed. Then if
raises an error’no updation’ or ’no deletion’.
4.
stop the program.
Program:
Sql>create or replace trigger t1
before insert on ngj for each row
2 begin
3 if(:new.sturno>8)then
raise_application_error(-20010,’cannor possible’);
4 end if;
5 end;
6 /
Trigger created.
Sql>insert into ngj values(7,’kumar’,’mech’,erd’,20000);
1row created.
Sql>create or replace trigger t2
before delete or update on ngj for each row
2 begin
3 if updating then
raise_application_error (-20013,’no updation’);
4 end if;
5 if deleting then
raise_application_error (-20014,’no deletion’);
6 end if;
7 end;
8 /
Trigger created.
Output:
Sql>insert into ngj values (11,’siva’,’it’,
erd’, 20000);
Insert into ngj values (11,’siva’,’it’,’erd’,
20000)
ERROR AT LINE 1:
ORA-20010: cannot possible
ORA-06512: at”SCOTT.T1”,line 2
ORA-04088: error during execution
of trigger’SCOTT.T1’
SQL>delete from ngj where
sturno=7;
delete from ngj where sturno=7;
ERROR AT LINE 1:
ORA-20010: cannot possible
ORA-06512: at”SCOTT.T2”, line 4
ORA-04088: error during execution
of trigger’SCOTT.T2’
Sql>update ngj set fes=34000
where course=’cse’
2/
Update ngj set fees=34000 where
course=’cse’
ERROR AT LINE 1:
ORA-20010: cannot possible
ORA-06512: at”SCOTT.T2”, line 4
ORA-04088: error during execution
of trigger’SCOTT.T2’
0 comments:
Post a Comment