Home » SQL & PL/SQL » SQL & PL/SQL » triggers
triggers [message #37731] Mon, 25 February 2002 20:29 Go to next message
krishna
Messages: 141
Registered: October 1998
Senior Member
My trigger's intention is to prevent user to update salary column of employee2 table with a salary greater than 4000
User name is plsql
My trigger is
create or replace trigger t3
after insert or update on employee2
for each row
declare
new_sal number(6);
begin

/*select sum(sal) into new_sal from employee2;*/
new_sal:=:new.sal;
if new_sal>4000 then
RAISE_APPLICATION_ERROR(-20001,'Error raised');
else dbms_output.put_line('');
end if;
end;

My trigger is getting created successfully but when i try to increase BLAKE's salary in employee2 table by 7000, I get the following error.
ERROR at line 1:
ORA-20001: Error raised
ORA-06512: at "PLSQL.T3", line 8
ORA-04088: error during execution of trigger 'PLSQL.T3'
Re: triggers [message #37741 is a reply to message #37731] Tue, 26 February 2002 04:22 Go to previous message
pratap kumar tripathy
Messages: 660
Registered: January 2002
Senior Member
u r supposed to get the error as u have raised the error inside the trigger.

it is the way it supposed to work
Previous Topic: Cummulative SUM
Next Topic: krishna
Goto Forum:
  


Current Time: Fri Apr 19 18:06:33 CDT 2024