Home » SQL & PL/SQL » SQL & PL/SQL » how to get server name
how to get server name [message #184350] Wed, 26 July 2006 05:27 Go to next message
satish@123
Messages: 15
Registered: February 2006
Junior Member
hi,

I am connecting to the server using telnet or putty.using pl/sql how can i get that server name.
Re: how to get server name [message #184352 is a reply to message #184350] Wed, 26 July 2006 05:34 Go to previous messageGo to next message
Frank Naude
Messages: 4502
Registered: April 1998
Senior Member
DB server name:
SELECT host_name FROM v$instance;


Client machine name:
SELECT machine FROM v$session WHERE audsid = USERENV('SESSIONID');
Re: how to get server name [message #184353 is a reply to message #184350] Wed, 26 July 2006 05:35 Go to previous messageGo to next message
oralover
Messages: 97
Registered: January 2005
Member
use code below to get some info after connection to server...
i am using Oracle9i Release 9.2.0.1.0
set linesize 120
set feedback off
set serveroutput on
DECLARE
  my_name   varchar2(15);
  my_ip     varchar2(15);
  my_server varchar2(15);
  v_host_name varchar2(15);
  v_ip_address varchar2(15);
BEGIN
  DBMS_OUTPUT.PUT_LINE('MY NAME         MY IP ADDRESS   SERVER NAME     SERVER_IP       SERVER');
  DBMS_OUTPUT.PUT_LINE('--------------- --------------- --------------- --------------- ---------------');
  SELECT UTL_INADDR.GET_HOST_NAME(v_host_name) into v_host_name FROM DUAL;
  SELECT UTL_INADDR.GET_HOST_ADDRESS(v_host_name) into v_ip_address FROM DUAL;
  SELECT RPAD(sys_context('USERENV','SESSION_USER'),15,' ') MY_NAME,
         RPAD(sys_context('USERENV','IP_ADDRESS'),15,' ') MY_IP ,
         RPAD(SYS_CONTEXT('USERENV', 'DB_NAME'),15,' ') SERVER
    INTO my_name, my_ip, my_server
    FROM DUAL;
  DBMS_OUTPUT.PUT_LINE(rpad(my_name,15,' ')||' '||
                       rpad(my_ip,15,' ')||' '||
                       rpad(my_server,15,' ')||' '||
                       rpad(v_ip_address,15,' ')||' '||
                       rpad(v_host_name,15,' '));
END;
.
/
select
.
set feedback on

[Updated on: Wed, 26 July 2006 05:38]

Report message to a moderator

Re: how to get server name [message #184360 is a reply to message #184353] Wed, 26 July 2006 06:04 Go to previous message
satish@123
Messages: 15
Registered: February 2006
Junior Member
hi,

In oracle tnsoranames file i changed the origin of host to some other server.so when i am giving this select utl_inaddr.get_host_name it is displaying the oracle hostname but i want is when ever we connect to server using telnet i want that server name .
Previous Topic: getting table of ref while inserting data
Next Topic: Moving average
Goto Forum:
  


Current Time: Fri Dec 02 20:44:20 CST 2016

Total time taken to generate the page: 0.13447 seconds