| Trigger created with error [message #319090] |
Fri, 09 May 2008 00:43  |
aslamsadia Messages: 13 Registered: December 2006 |
Junior Member |
|
|
I have coded a trigger for updation of BALANCE column in BILL_MR table, but trigger created with compilation error. Code is :-
CREATE OR REPLACE TRIGGER UPD_BILL_AMT
AFTER UPDATE OF BILL_AMT ON BILL_MR
FOR EACH ROW
DECLARE
PLUS_DIFF NUMBER(12,2);
MINUS_DIFF NUMBER(12,2);
BEGIN
IF UPDATING THEN
IF :NEW.BILL_AMT > :OLD.BILL_AMT THEN
PLUS_DIFF := :NEW.BILL_AMT - :OLD.BILL_AMT;
UPDATE BILL_MR SET BALANCE = BALANCE + PLUS_DIFF;
END IF;
IF :NEW.BILL_AMT < :OLD.BILL_AMT THEN
MINUS_DIFF := :OLD.BILL_AMT - :NEW.BILL_AMT;
UPDATE BILL_MR SET BALANCE = BALANCE _ MINUS_DIFF;
END IF;
END IF;
END;
The error is :-
LINE/COL ERROR
-------- -------------------------------------
12/4 PL/SQL: SQL Statement ignored
12/41 PL/SQL: ORA-00911: invalid character
Pls help.
|
|
|
| Re: Trigger created with error [message #319093 is a reply to message #319090 ] |
Fri, 09 May 2008 00:55   |
Michel Cadot Messages: 15244 Registered: March 2007 Location: Nanterre, France, http://... |
Senior Member |
|
|
1/ please read OraFAQ Forum Guide, especially "How to format your post?" section.
Make sure that lines of code do not exceed 80 characters when you format.
Indent the code (See SQL Formatter) and align the columns in result.
Use the "Preview Message" button to verify.
2/ Which one is line 12. Use SQL*plus and copy and paste your session
3/ You can neither read nor write the table you are currently modifying: the UPDATE statement are wrong. Use :NEW.BALANCE := ...
Regards
Michel
|
|
|
| Re: Trigger created with error [message #319138 is a reply to message #319090 ] |
Fri, 09 May 2008 02:32  |
JRowbottom Messages: 2663 Registered: June 2006 Location: Sunny North Yorkshire, ho... |
Senior Member |
|
|
Can you not replace this whole piece of code with:CREATE OR REPLACE TRIGGER UPD_BILL_AMT
AFTER UPDATE OF BILL_AMT ON BILL_MR
FOR EACH ROW
BEGIN
:new.BALANCE := :new.BALANCE + :new.BILL_AMT - :old.BILL_AMT;
END;
|
|
|