简体   繁体   中英

Oracle 12c How to audit specified Stored procedure for specified User

I would like to audit specific procedure for specific user. For example i have a stored procedure prc_user_error and i have user which name of Ktd. When the Ktd user execute prc_user_error procedure should be audited.

I cant use trigger. Also fine grained auditing cant use for execute. Can you please help me?

Thanks,

How about setting up your procedure like this and test for the name(s) and exit without doing anything in your procedure. If coded correctly than nothing should be printed in my example


create or replace procedure sp as
    v_user varchar2(32) := SYS_CONTEXT( 'USERENV', 'SESSION_USER' );
   begin  dbms_output.put_line(v_user);
    end;
   /


 begin 
sp; 
end;

IDK how you want to audit it, but assume to insert a record into some table:

create table myAudit( auditTime TIMESTAMP, auditUser VARCHAR2(30));

in procedure:

insert into myAudit values (SYSTIMESTAMP, SYS_CONTEXT ('USERENV','SESSION_USER') );

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM