How to get login and hostname from the invoker of a procedure [message #259446] |
Wed, 15 August 2007 11:27  |
diribuf
Messages: 8 Registered: August 2007 Location: Rio de Janeiro, Brazil
|
Junior Member |
|
|
I need to know the login (username) and hostname (or IP) of the invoker of a given procedure so I can insert it on a table.
I've looked all over for some variables that would give me that. I know those infos can be found at v$session, but how can I know what is the current session?
Or is there a easier way?
Thanks in advance,
Christian
|
|
|
|
Re: How to get login and hostname from the invoker of a procedure [message #259448 is a reply to message #259447] |
Wed, 15 August 2007 11:37   |
diribuf
Messages: 8 Registered: August 2007 Location: Rio de Janeiro, Brazil
|
Junior Member |
|
|
anacedent wrote on Wed, 15 August 2007 13:33 | >I need to know the login (username) and hostname (or IP) of the invoker of a given procedure so I can insert it on a table.
Is this a 2 tier or 3 tier application environment?
|
Sorry, I'm not sure and don't know how this is relevant.
It is a simple procedure. A user will login into the database and execute it to execute some tasks. I'd like the capture it's username and host (the machine from where this is user logged from) to log these infos to a table.
|
|
|
|
|
|
Re: How to get login and hostname from the invoker of a procedure [message #259457 is a reply to message #259446] |
Wed, 15 August 2007 11:59   |
 |
Michel Cadot
Messages: 68737 Registered: March 2007 Location: Saint-Maur, France, https...
|
Senior Member Account Moderator |
|
|
SQL> SQL> select sys_context('userenv','sid') sid, sys_context('userenv','session_user') username,
2 sys_context('userenv','os_user') osuser, sys_context('userenv','host') host
3 from dual;
SID USERNAME OSUSER HOST
---------- ---------- ------------------------------ ------------------------------
150 MICHEL XXXXXXXXX\Michel WORKGROUP\XXXXXXXXX
1 row selected.
(Of course I replace confidential data with X)
Regards
Michel
|
|
|
|
|
Re: How to get login and hostname from the invoker of a procedure [message #259745 is a reply to message #259455] |
Thu, 16 August 2007 06:52   |
Frank
Messages: 7901 Registered: March 2000
|
Senior Member |
|
|
sarans wrote on Wed, 15 August 2007 18:54 | The following works only within the PL/SQL calls.
Use the following to get the user Login(Oracle user)
SELECT user FROM DUAL;
Use the following to get the IP address.
SELECT SYS_CONTEXT ('USERENV', 'IP_ADDRESS') FROM DUAL;
Confirm whether it worked for you????
|
Don't select from dual what you can assign as variable.
|
|
|
|
|
|
|
Re: How to get login and hostname from the invoker of a procedure [message #265732 is a reply to message #265648] |
Fri, 07 September 2007 03:42   |
sarans
Messages: 30 Registered: November 2006 Location: UK
|
Member |
|
|
I agree to your point, but by using dual the user can view the value instantly, this is for convenient, by this way the user can understand what is the return value in the sqlplus or toad, then within the procedure he can assign to an variable as you have mentioned.... this is my point... hope its clear...
|
|
|
|