Trigger
Trigger
6: Triggers
SET A :
Create a RDB in 3NF and write PL/SQL blocks in Oracle for the
following:
1) Write a trigger which will fire before insert or update on Employee having
Emp id less than equal to zero (Raise user defined exception and give
appropriate message)
create or replace trigger t5 before insert or update on employee for each row
begin
if(:new.emp_id<=0) then
raise_application_error(-20003,'ERROR::Emp id should be greater than
zero');
end if;
end;
2..Write a trigger which will fire before insert or update on Investment having
investment amount less than 10000. (Raise user defined exception and give
appropriate message)
create or replace trigger t6 before insert or update on inv for each row
begin
if(:new.i_amt<10000) then
raise_application_error(-20001,'ERROR::Investment amt should be greater than
50000');
end if;
end;
Slip Questions:
1.Write a trigger which will fire before insert or update on book having price less
than or equal to zero. (Raise user defined exception and give appropriate message)
create or replace trigger t5 before insert or update on book for each row
begin
if(:new.price<=0) then
end if;
end;
2.Write a trigger which will fire before insert or update on mobile number having
length less than or greater than10. (Raise user defined exception and give
appropriate message)
create or replace trigger t8 before insert or update on cust for each row
begin
end if;
end;
3. Write a trigger which will fire before insert or update on project having budget
less than or equal to zero. (Raise user defined exception and give appropriate
message)
create or replace trigger t9 before insert or update on project1 for each row
begin
If(:new.budget<=0) then
end if;
end;
SET B
1. Write a trigger which will fire before insert or update on Gym having charges
less than 1000. (Raise user defined exception and give appropriate message)
create or replace trigger t11 before insert or update on gym1 for each row
begin
if(:new.charges<1000) then
end if;
end;
6.Write a trigger which will fire before delete on Lab (Raise user defined exception
and give appropriate message)
create or replace trigger t12 before delete on lab4 for each row
declare
del_lab exception;
begin
raise del_lab;
exception