Step 1: Logon to the database
Logon to the database using any user such as HR, SH, OE or any other you want.
1
| C:\> SQLPLUS hr/hr |
Step 2: Create a table.
Create a table to dump the data generated by your schema level logoff trigger.
1
2
3
4
5
6
7
8
| CREATE TABLE hr_evnt_audit ( event_type VARCHAR2(30), logon_date DATE , logon_time VARCHAR2(15), logof_date DATE , logof_time VARCHAR2(15) ); |
Step 3: Write the trigger.
Below written trigger will execute every time user HR logs off from the database.
1
2
3
4
5
6
7
8
9
10
11
12
13
| CREATE OR REPLACE TRIGGER log_off_audit BEFORE LOGOFF ON SCHEMA BEGIN INSERT INTO hr_evnt_audit VALUES ( ora_sysevent, NULL , NULL , SYSDATE, TO_CHAR(sysdate, 'hh24:mi:ss' ) ); COMMIT ; END ; / |
No hay comentarios:
Publicar un comentario