Hello. I created trigger. and I want when I update table, it works and show results which written in dbms_output function in trigger.
SQL> set serveroutput on;
SQL> CREATE OR REPLACE TRIGGER farechanges AFTER UPDATE ON tickets FOR EACH ROW
DECLARE
cname varchar2(25);
origname varchar2(25);
destname varchar2(25);
BEGIN
select origin into origname from route where route_id=:Old.route_id;
select destination into destname from route where route_id=:Old.route_id;
select name into cname from buscompanies where bus_id=:Old.bus_id;
dbms_output.put(cname || ' (' || origname || '->' || destname || '):');
dbms_output.put(' New Fare: ' || :New.fare ||',');
dbms_output.put(' Old Fare: ' || :old.fare ||',');
dbms_output.put(' Change Amount: ' || (( :New.fare-:old.fare ) / :old.fare) * 100 );
END;
/ 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Trigger created.
SQL> update tickets set fare=23.32 WHERE ROUTE_ID=1 AND BUS_ID=1;
1 row updated.
I can'T see any result. I want the result as
SQL> update tickets set fare=23.32 WHERE ROUTE_ID=1 AND BUS_ID=1;
A Bus (Ankara -> Bursa) New Fare : 23.32 Old Fare: 13.32 Change Amount: 100
1 row updated.