---------------------------------------------------------
-- EJECUTAR CON ACC_ADMIN O ASTSYSADMIN
---------------------------------------------------------

SET FEEDBACK OFF

DEFINE MES = M&2
DEFINE ANO = A&3
DEFINE PART = &MES&ANO

COLUMN TIMESTAMP FORMAT A20
COLUMN OS_USERNAME FORMAT A15
COLUMN USERNAME FORMAT A15
COLUMN USERHOST FORMAT A30
COLUMN TERMINAL FORMAT A20
COLUMN ACTION_NAME FORMAT A15
column RETURNCODE format 99999
column ACTION format 99999


EXEC DBMS_OUTPUT.PUT_LINE(chr(10) || '*** REGISTROS DE AUDITORIA DE HOY ***');
select TIMESTAMP, OS_USERNAME, USERNAME, USERHOST, TERMINAL, ACTION, ACTION_NAME, RETURNCODE from dba_audit_trail where username like upper('&1') ORDER BY TIMESTAMP DESC;
EXEC DBMS_OUTPUT.PUT_LINE(chr(10));

---------------------------------------------------------

COLUMN NTIMESTAMP# FORMAT A25
COLUMN USERID FORMAT A15
COLUMN SPARE1 FORMAT A20
column ACTION# format 99999

EXEC DBMS_OUTPUT.PUT_LINE(chr(10) || '*** REGISTROS DE AUDITORIA DEL MES Y ANO INDICADOS ***');
select NTIMESTAMP#, USERID, USERHOST, TERMINAL, ACTION#, RETURNCODE, SPARE1 from aud$final partition (&PART) where userid like upper('&1') order by ntimestamp# desc;
EXEC DBMS_OUTPUT.PUT_LINE(chr(10));

---------------------------------------------------------

COLUMN LOGON_DATE FORMAT A25
COLUMN OS_USUARIO FORMAT A15
COLUMN ORA_USUARIO FORMAT A20
COLUMN MAQUINA FORMAT A30
COLUMN PROGRAMA FORMAT A20
COLUMN ORIGEN FORMAT A20

EXEC DBMS_OUTPUT.PUT_LINE(chr(10) || '*** REGISTROS DE ACCESO EN EL MODULO DE SERVICIOS ***');
select logon_date, os_usuario, ora_usuario, maquina, programa, origen from astsysadmin.t_mods_logon_log where ora_usuario like upper('&1') order by logon_date desc;
EXEC DBMS_OUTPUT.PUT_LINE(chr(10));

SET FEEDBACK ON