-- System trigger to restrict certain users to time of day
-- Copyright (c) 2004, Caleb.com

-- Insert and commit a record in the log table, independant of the
-- current txn in progress.
CREATE OR REPLACE PROCEDURE log_autonomous( v_str  IN VARCHAR2)
IS
   PRAGMA AUTONOMOUS_TRANSACTION;  -- This is the magic
BEGIN
   INSERT INTO cs_log
      VALUES (sysdate, ora_login_user, v_str);
   -- Must commit before the procedure ends or txn will be rolled back.
   -- Commit does not affect the outter txn in any way.
   COMMIT;
END;
/

-- Edit old logon trigger and substitute the following:
--         log_autonomous('Logon denied!');
--   log_autonomous('Logon');
