Home » SQL & PL/SQL » SQL & PL/SQL » Query to find machine name
Query to find machine name [message #184463] Wed, 26 July 2006 12:04 Go to next message
bella13
Messages: 90
Registered: July 2005
Member
In my procedure I want a certain task to be performed only if it is running in a specific machine.

What table can I query to find if my application is running on a certain machine. is this information stored anywhere in the database?

Appreciate your response.

thanks
Re: Query to find machine name [message #184475 is a reply to message #184463] Wed, 26 July 2006 13:45 Go to previous messageGo to next message
ebrian
Messages: 2794
Registered: April 2006
Senior Member
select sys_context('userenv', 'ip_address') from dual;


Will provide the IP address of your client's session, however if it's a webapp, it will show the IP of your webserver. You may want to look into Secure Applicaton Roles.
Re: Query to find machine name [message #184488 is a reply to message #184475] Wed, 26 July 2006 15:05 Go to previous messageGo to next message
andrew again
Messages: 2577
Registered: March 2000
Senior Member
select machine
  FROM v$session
--where sid = ( select sid from v$mystat where rownum = 1 );

-- Try HOST
select 'DB_NAME="'		|| sys_context('userenv', 'DB_NAME') 		||
	'", CLIENT_INFO="'	|| sys_context('userenv', 'CLIENT_INFO')  	||
	'", SESSION_USER="'	|| sys_context('userenv', 'SESSION_USER')    	||
	'", CURRENT_SCHEMA="'	|| sys_context('userenv', 'CURRENT_SCHEMA')  	||
	'", HOST="'		|| sys_context('userenv', 'HOST')     		||
	'", EXTERNAL_NAME="'	|| sys_context('userenv', 'EXTERNAL_NAME')    	||
	'", IP_ADDRESS="'	|| sys_context('userenv', 'IP_ADDRESS')    	||
	'", DBMS_JOB#="'	|| sys_context('userenv', 'BG_JOB_ID')     
from dual;
Re: Query to find machine name [message #184490 is a reply to message #184488] Wed, 26 July 2006 15:12 Go to previous messageGo to next message
bella13
Messages: 90
Registered: July 2005
Member
Thanks for the replies.

I also explored v$instance table.

It gives me the host name. Do you think that is correct too? Will v$instance at any given time return only 1 row?

Thank you and Rgds,
Re: Query to find machine name [message #184494 is a reply to message #184490] Wed, 26 July 2006 15:43 Go to previous message
ebrian
Messages: 2794
Registered: April 2006
Senior Member
The hostname in V$INSTANCE is for the database hostname.
Previous Topic: Can values of rows being queried dynamically altered even as they are queried?
Next Topic: Dynamic SQL and For Loop Question
Goto Forum:
  


Current Time: Sat Dec 10 16:22:25 CST 2016

Total time taken to generate the page: 0.12584 seconds