Mostly, it's preferable to use a DB Trigger for DML operations for logging People and related Module Information. At the Application layer Client and Module Info might be set as :
dbms_application_info.set_client_info( my_client_name );
dbms_application_info.set_module( my_mdl, null );
It's proper to create a table for logging for DML operations applied for the table test
as :
create table test( col1 int, col2 varchar2(50) .... ); -- <-- assuming test is as this.
create table log_test( col1 int, col2 varchar2(50) ...., col_cl_info varchar2(64),
col_terminal varchar2(64), col_opr_time date, col_machine varchar2(64),
col_dml_type varchar2(1) , col_module varchar2(64) );
and then, you may create such a trigger as follows :
create or replace trigger trg_log_test
before update or insert on test
for each row
declare
v_cl_info v$session.client_info%type;
v_machine v$session.machine%type;
v_module v$session.module%type;
v_action v$session.osuser%type;
v_dml_type varchar2(1);
begin
select client_info, machine, module
into v_cl_info, v_machine, v_module
from v$session
where audsid = userenv('SESSIONID');
if v_cl_info in ('oracle') then
dbms_application_info.read_client_info( v_cl_info );
dbms_application_info.read_module( v_module, v_action );
end if;
if inserting then
v_dml_type := 'I';
elsif updating then
v_dml_type := 'U';
end if;
insert into log_test( col1, col2, .... ,
col_cl_info, col_terminal, col_opr_time , col_machine, col_dml_type, col_module )
values(:new.col1, :new.col2, ..........,
v_cl_info , userenv('TERMINAL'),sysdate , v_machine , v_dml_type , v_module );
end;
where v$session is a public synonym for sys.v_$session dictionary view.