|
|
|
|
|
Re: debugging of trigger in sql developer [message #632453 is a reply to message #632452] |
Sat, 31 January 2015 08:02 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
![](/forum/images/custom_avatars/171883.jpg) |
sss111ind
Messages: 636 Registered: April 2012 Location: India
|
Senior Member |
![s](/forum/theme/orafaq/images/google.png)
|
|
As my condition was not appropriate so the trigger was failing.
create or replace
PROCEDURE sal_percent
IS
BEGIN
UPDATE emp SET sal=SAL+(SAL)*(10/100) WHERE JOB='KINGA';--wrong
end;
create or replace
TRIGGER hiredate_trg
BEFORE UPDATE ON emp
FOR EACH ROW
BEGIN
IF :OLD.JOB='SALESMAN' THEN
:NEW.SAL:=:NEW.SAL+(:new.SAL)*(10/100);
END IF;
END;
[Updated on: Sat, 31 January 2015 08:03] Report message to a moderator
|
|
|
|
Re: debugging of trigger in sql developer [message #635635 is a reply to message #632454] |
Fri, 03 April 2015 14:25 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) |
Bill B
Messages: 1971 Registered: December 2004
|
Senior Member |
|
|
It would be cleaner to simply use and what is the trigger do if they simply update something besides job. You have to restrict the trigger or they will be getting a raise every time the user is updated.
create or replace
TRIGGER hiredate_trg
BEFORE UPDATE ON emp
FOR EACH ROW
BEGIN
IF :OLD.JOB='SALESMAN'
and :new.job <> 'SALESMAN' THEN
:NEW.SAL:=:NEW.SAL * 1.10;
END IF;
END;
[Updated on: Fri, 03 April 2015 14:29] Report message to a moderator
|
|
|