Solved

Get os user name inside row level trigger

Posted on 2008-10-16
3
1,424 Views
Last Modified: 2013-12-18
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
Comment
Question by:PopoDi
3 Comments
 
LVL 29

Accepted Solution

by:
MikeOM_DBA earned 300 total points
ID: 22737363

Try:

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

Open in new window

0
 
LVL 27

Assisted Solution

by:sujith80
sujith80 earned 200 total points
ID: 22737400
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
 

Author Closing Comment

by:PopoDi
ID: 31506950
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever had to make fundamental changes to a table in Oracle, but haven't been able to get any downtime?  I'm talking things like: * Dropping columns * Shrinking allocated space * Removing chained blocks and restoring the PCTFREE * Re-or…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

815 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now