Solved

Get os user name inside row level trigger

Posted on 2008-10-16
3
1,410 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
Comment Utility

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
Comment Utility
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
Comment Utility
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.

Join & Write a Comment

How to Create User-Defined Aggregates in Oracle Before we begin creating these things, what are user-defined aggregates?  They are a feature introduced in Oracle 9i that allows a developer to create his or her own functions like "SUM", "AVG", and…
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.

763 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

6 Experts available now in Live!

Get 1:1 Help Now