Get os user name inside row level trigger

Hi,

I have a trigger on a table and I want to capture the os user who updates a field in that table. How can I do that on a row level trigger?
PopoDiAsked:
Who is Participating?
 
MikeOM_DBACommented:

Try:

SELECT SYS_CONTEXT ('USERENV', 'OS_USER') INTO OSUSER FROM DUAL;

Open in new window

0
 
SujithData ArchitectCommented:
The following code can get you the username in cases where the database connection is made directly through a client tool. But if your application web based/uses a connection pool or something like that; then this query will return the os user that has started the respective service.

declare
 l_usr varchar2(20);
begin
 l_usr := sys_context('userenv', 'os_user');
 dbms_output.put_line(l_usr);
end;
/

Bottom line: If the idea is to track the application users who has made the changes; you must use more complex techniques like the supplied package dbms_application_info.
0
 
PopoDiAuthor Commented:
Thank you guys, I wish I could give 500 to each, but I split them based on the order they came in.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.