The question is published on by Tutorial Guruji team.
I am trying to make a trigger for every day a movie gets returned late 2$ gets added to the unpaid balance. The return and due date are in the transaction table, and the unpaid balance is in the members table. Here is what I have so far, and the errors I am getting any help or suggestions would be great I am really struggling with this one.
Create or Replace Trigger Late_Rule BEFORE INSERT ON Transaction For each Row DECLARE Fee Number; BEGIN Select Date_Due, Date_Returned From Transaction; If new.Date_Returned > new.Date_Due THEN Fee := (new.Date_Returned - new.Date_Due) * 2; END IF; Update Member Set Unpaid_Bal = Unpaid_Bal + Fee; end; / show error;
7/1 PLS-00428: an INTO clause is expected in this SELECT statement
10/1 PL/SQL: Statement ignored
10/4 PLS-00201: identifier ‘NEW.DATE_RETURNED’ must be declared
You must use
new. Also i think you don’t need
Create or Replace Trigger Late_Rule BEFORE INSERT ON Transaction For each Row DECLARE Fee Number; BEGIN If :new.Date_Returned > :new.Date_Due THEN Fee := (:new.Date_Returned - :new.Date_Due) * 2; END IF; Update Member Set Unpaid_Bal = Unpaid_Bal + Fee; end;
Let me know if you get any error.