Databases Reference
In-Depth Information
BEGIN
insert into user_login_audit values(
user,
sys_context('USERENV','SESSIONID'),
sys_context('USERENV','HOST'),
sysdate,
to_char(sysdate, 'hh24:mi:ss'),
null,
null
);
COMMIT;
END;
Most of the data is populated upon login, but the logout date and time
are populated using the trigger that is fired when the user logs out:
create or replace trigger
user_logout_audit_trigger
BEFORE LOGOFF ON DATABASE
BEGIN
-- logout day
update
user_login_audit
set
logout_day = sysdate
where
sys_context('USERENV','SESSIONID') = session_id;
-- logout time
update
user_login_audit
set
logout_time = to_char(sysdate, 'hh24:mi:ss')
where
sys_context('USERENV','SESSIONID') = session_id;
COMMIT;
END;
That's all you need to do in an Oracle environment. If you run a Sybase
environment, it is even easier, because you can audit all access to all data-
bases using the following commands:
sp_configure "auditing", 1
go
sp_audit "dbaccess", "all", "all", "on"
go
Search WWH ::




Custom Search