Thursday, February 8, 2018

LOGON & LOGOFF Triggers in PLSQL







/*****************************************************************************
 USER EVENT LOGON & LOGOFF Triggers Examples..

CREATE OR REPLACE TRIGGER DDLTrigger_name
AFTER LOGON/LOGOFF ON DATABASE/SCHEMA
BEGIN
-----
END;
******************************************************************************/
DROP TABLE USER_EVENT_LOG;
CREATE TABLE USER_EVENT_LOG
  (
    ora_login_user     VARCHAR2(100),
    creation_date      DATE,
    ora_sysevent       VARCHAR2(100)
  );
/


CREATE OR REPLACE TRIGGER MY_DDL_TRIGGER_LOGON AFTER LOGON   ON DATABASE
  BEGIN
    INSERT
    INTO USER_EVENT_LOG VALUES
      (
        ora_login_user ,
        sysdate ,
        ora_sysevent 
      );
  END;
  /
 
 
CREATE OR REPLACE TRIGGER MY_DDL_TRIGGER_LOGOFF BEFORE LOGOFF   ON DATABASE
  BEGIN
    INSERT
    INTO USER_EVENT_LOG VALUES
      (
        ora_login_user ,
        sysdate ,
        ora_sysevent  
      );
  END;
  /
  

No comments:

Post a Comment