Search code examples
triggerssqlplus

I have created trigger in SQL Plus without error but it doesn't work


I create following trigger in SQL Plus to show the old and the new telephone numbers when there is an update on table. It seems to work when I create but when I try following line to see if it works, there is nothing. Where is my mistake, could you please help me?

`CREATE OR REPLACE TRIGGER update_trig
 AFTER UPDATE OF number ON traveler
 FOR EACH ROW
 BEGIN
 DBMS_OUTPUT.PUT_LINE('New: ' || :new.number);
 DBMS_OUTPUT.PUT_LINE('Old:  ' || :old.number);
 END;
 /  `

Test line: UPDATE traveler SET number = 0651458621 WHERE number = 0651458625;


Solution

  • Apparently, I should have added a line and say 'SET SERVEROUTPUT ON' before all of it. This is the command that runs the dbms output