Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Getting Current User from triggers

0 views
Skip to first unread message

Fabio GRANDE

unread,
Jul 16, 2001, 11:30:03 AM7/16/01
to
Hi all !
I have a trigger attached to a table, that run every time there's an insert
or an update.
In this trigger, I need to know the current Oracle User (and other info such
as those I can get from v$session view such as OSUSER and MACHINE).
Is there a way to do this with PL/SQL ?
Thanx in advance for Your co-operation

--
Fabio GRANDE
fab...@NOSPAMfileita.it

Fabio GRANDE

unread,
Jul 16, 2001, 11:30:52 AM7/16/01
to
(I'm using Oracle 8i on NT system.)
Fabio GRANDE

Guenter Huerkamp

unread,
Jul 16, 2001, 12:45:49 PM7/16/01
to
Fabio GRANDE wrote:
> (I'm using Oracle 8i on NT system.)
> Fabio GRANDE
>
>

Try USER

--
---------------------------------------------------------------
Dipl.-Inform. Günter Huerkamp

Web : http://gh.notrix.de

Email
privat : mailto:guenter-...@web.de
privat : mailto:guenter-...@t-online.de
dienstlich : mailto:Guenter....@lk-wl.nrw.de


---------------------------------------------------------------

Stephen Bell

unread,
Jul 16, 2001, 12:58:00 PM7/16/01
to
Hi,

You can use USER in the VALUES clause of an insert statement, for instance if
you want to insert the name of
the user that performed the insert/update....you could use a default value
(user) for when an insert occurs and when an update
occurs you can populate an "UPDATED BY" field in the table....whatever method
you use, I think it's the USER function
you're looking for.

Best regards,
Steve

Thomas Kyte

unread,
Jul 16, 2001, 12:34:46 PM7/16/01
to
In article <9iv0c1$s46$1...@fe2.cs.interbusiness.it>, "Fabio says...

the USER psuedo column works. As well, you can get the v$session row via:


select * from v$session
where sid = ( select sid from v$mystat where rownum=1 );

you'll need DIRECT access to v_$session and v_$mystat or have your dba setup
that above query as a view and grant you DIRECT select on that view.

--
Thomas Kyte (tk...@us.oracle.com) http://asktom.oracle.com/
Expert one on one Oracle, programming techniques and solutions for Oracle.
http://www.amazon.com/exec/obidos/ASIN/1861004826/
Opinions are mine and do not necessarily reflect those of Oracle Corp

Van Messner

unread,
Jul 16, 2001, 6:47:54 PM7/16/01
to
If you do use the user pseudo column be sure to test that your are getting
the results you want. Is your middle tier product sending the requests from
each actual user to Oracle with a different user name or as a single user?
Any connection pooling?

Van


"Stephen Bell" <stephe...@cgi.ca> wrote in message
news:3B531D18...@cgi.ca...

Fabio GRANDE

unread,
Jul 17, 2001, 2:54:11 AM7/17/01
to
Thanx a lot to everybody !
I think that the best solution comes from Thomas Kyte : that's because I
need to know also the machine name and the OS User...
Bye Bye by Fabio GRANDE

0 new messages