abdeen-ahmad
3/3/2016 - 7:34 PM

trigger a System Events

trigger a System Events

create or replace trigger login_audit
after logon on database
declare
    v_subject   varchar2(100) := 'User login audit event triggered';
    v_message   varchar2(1000);
begin
if (to_char(sysdate,'DY')= 'SAT' or to_char(sysdate,'DY')='SUN') then
    insert into lgoin_audit_table valuse(sysdate,
    sys_context('USERENV','SESSION_USERID'),    
    sys_context('USERENV','IP_ADDRESS'),
    sys_context('USERENV','HOST'));
    
    v_message   :='USER ' || sys_context('USERENV','SESSION_USERID') || 'logged into database';
    
    SEND_EMAIL('dba@abc.com',v_subject,v_message);
end if;
    end;