Useful shortcuts for vi editor

Tuesday 21 March 2017

How to manage logon mechanism with trigger ?

CREATE OR REPLACE TRIGGER SYS.DENY_LOGIN
   AFTER LOGON
   ON DATABASE
BEGIN
   IF     TO_CHAR (SYSDATE, 'hh24') BETWEEN 08 AND 22
      AND SYS_CONTEXT ('USERENV', 'SESSION_USER') = 'HR'
   THEN
      raise_application_error (
         -20001,
         'You cannot login between 08 AM and 06 PM. Please contact with Alper!');
   END IF;
END deny_login;
/

Error message:
ORA-00604: error occurred at recursive SQL level 1
ORA-20001: You cannot login between 08 AM and 06 PM. Please contact with Alper!
ORA-06512: at line 5