I have a very simple trigger, that prints out the username and date when a new row is inserted into the users table. But after it successfully compiled, the trigger didn't get triggered (there was no output in the dbms window). So, I simplified my code until I got this:
CREATE OR REPLACE TRIGGER logger
AFTER INSERT ON USERS
BEGIN
DBMS_OUTPUT.PUT_LINE('User added with name:');
END;
If I run the code in the SQL worksheet (from BEGIN to END), I can see the output, but not when I try to use the trigger. Where is the problem?
DBMS_OUTPUT.PUT_LINEis aimed to write to console. So, you need to have the trigger making some change that could be checked without using the console. You can, for instance, send an e-mail to yourself (just to test that the trigger is fired, not as the normal functionality of the trigger).set serveroutput oncommand without need ofbegin .. endunless you call from an external application.