Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1457
  • Last Modified:

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?
0
PopoDi
Asked:
PopoDi
2 Solutions
 
MikeOM_DBACommented:

Try:

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

Open in new window

0
 
sujith80Commented:
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

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now