Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Oracle Warning: Trigger Created With Compilation Errors

1002068Apr 10 2013 — edited Apr 10 2013
I Can't seem to find what is wrong with this code. I have searched through it numerous times and cannot correct/find the error.

/* Trigger AskingPriceInitialValue */
CREATE OR REPLACE TRIGGER TRANS_AskingPriceIniValue
AFTER INSERT ON Transactions
FOR EACH ROW

DECLARE

rowcount INTEGER;
NetProfit NUMBER(10,2);
avgNetProfit NUMBER(10,2);
pragma autonomous_transaction;

BEGIN

SELECT Count(*) INTO rowcount
FROM Transactions T
WHERE T.WorkID = :new.WorkID;

IF rowcount = 1 THEN

UPDATE TRANSACTIONS
SET T.SalesPrice = 2 * T.AcquisitionPrice
WHERE T.TransactionID = :new.TransactionID;


ELSIF rowcount > 1 THEN

SELECT Sum(NetProfit) INTO NetProfit
FROM ArtistWorkNetView AW
WHERE AW.WorkID = :new.WorkID
GROUP BY AW.WorkID;

avgNetProfit := NetProfit / (rowcount - 1);

IF (avgNetProfit + :new.AcquisitionPrice) > (2 * :new.AcquisitionPrice) THEN

UPDATE TRANSACTIONS
SET T.AskingPrice = (avgNetProfit + :new.AcquisitionPrice)
WHERE T.TransactionID = :new.TransactionID;


ELSE

UPDATE TRANSACTIONS
SET T.AskingPrice = 2 * :new.AcquisitionPrice
WHERE T.TransactionID = :new.TransactionID;

END IF;
ELSE
dbms_output.put_line('ERROR');
END IF;
END;
/
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 8 2013
Added on Apr 10 2013
14 comments
5,994 views