Re: Q: Get OS Userid

From: Tony Jambu <aaj_at_cmutual.com.au>
Date: Mon, 20 Jun 1994 06:39:30 GMT
Message-ID: <Crontv.H9H_at_cmutual.com.au>


In article <1994Jun19.162306.24152_at_ericsson.se>, ebcrbj_at_ebcw150.ericsson.se (BO/EBC/KX/RGFC Roger Bjaerevall 08-682 4851) writes:
> Is it possible to get the OS userid of the current user (SUN OS)?
>
> The 'SELECT user FROM dual' call does only return current ORACLE userid.
> I did not find any matching parameter to the USERENV() call either.
>
> We need this because our application is connecting to only one static
> specified ORACLE userid/password. Though we need to track each specific
> user with the OS userid.
>
> Any solution?

I am not sure how you are accessing the database but I will assume it is through SQL*Plus. That is because that is where I have an answer for you.

Remember the glogin.sql file. Well what you do is create an executable file to be executed by glogin.sql using the HOST command. Lets call it

$ORACLE_HOME/local/etc/sqlrc.sh

So glogin.sql looks like

glogin.sql: host $ORACLE_HOME/local/etc/sqlrc.sh > $HOME/init.sql
glogin.sql: REM Execute the initialisation/startup script
glogin.sql: start $HOME/init.sql


In $ORACLE_HOME/local/etc/sqlrc.sh, have the following lines:
	echo "
	define LOGNAME=\"${LOGNAME}\"
	"

and whatever you want to setup.

At our site, it is a bit more complicated than this but the basic idea is to have a UNIX script generate an SQL script with all the information you would like and then execute it. The information is then stored in SQL*Plus variables.

In fact this is possible in SQLDBA Oracle 7 as well but that is another issue.  

Hope that helps.

ta
tony

-- 
 _____       ________ / ____ |Tony Jambu, Database Administrator
  /_  _        /_ __ /       |Colonial Mutual Invest Mgmt,Aust (ACN004021809)
 /(_)/ )(_/ \_/(///(/_)/_(   |EMAIL: TJambu_at_cmutual.com.au
 \_______/                   |PHONE: +61-3-2831639       FAX: +61-3-2831090
Received on Mon Jun 20 1994 - 08:39:30 CEST

Original text of this message