Re: How to find OS username for a session??

From: Bill Manry - Oracle Corp. <bmanry_at_ibmgate-aix.us.oracle.com>
Date: 1995/12/06
Message-ID: <4a4i33$kga_at_inet-nntp-gw-1.us.oracle.com>#1/1


Alan Nolan-Davies (Alan.Nolan-Davies_at_bcs.org.uk) wrote: [...]
>User is a standard function.
>So to find the current time and user for updating last_updated
>and last_updated_by fields
>do a select sysdate, user from dual.

The USER builtin function returns the Oracle userid, which is not necessarily the same as the OS userid. The original poster was on the right track...you get the OS userid from v$session based on (e.g.) the audit session id, which you get via USERENV:

  select osuser from v$session
   where audsid = userenv('sessionid')

Note that "osuser" may not be a reliable field if the client connected via SQL*Net.

/b

--
Bill Manry  -  Mainframe and Integration Technologies  -  Oracle Corporation
Standard disclaimer applies.
Received on Wed Dec 06 1995 - 00:00:00 CET

Original text of this message