Home » SQL & PL/SQL » SQL & PL/SQL » Ping an IP from oracle-check for response.
Ping an IP from oracle-check for response. [message #172005] Sat, 13 May 2006 01:30 Go to next message
bhagat.singh-j
Messages: 39
Registered: April 2006
Member
Hi,
I need to ping an IP address and check whether am able to get a reply.
Is it possible from Oracle?

Thanks,
Kevin
Re: Ping an IP from oracle-check for response. [message #172021 is a reply to message #172005] Sat, 13 May 2006 04:46 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: March 2000
Senior Member
I am curious why you would want to do this from a database. What are you going to do if the ping succeeds and what if it does not succeed? A database is not (yet) an operating system; in my opinion some things (e.g. network connectivity) should be left to OS's
Not trying to be rude, just curious.
Re: Ping an IP from oracle-check for response. [message #172270 is a reply to message #172021] Mon, 15 May 2006 15:06 Go to previous messageGo to next message
andrew again
Messages: 2577
Registered: March 2000
Senior Member
You can run an OS command from pl/sql. I also think it's a strange requirement - you may as well just try to talk to the remote host using UTL_TCP and handle any errors returned.
Re: Ping an IP from oracle-check for response. [message #172317 is a reply to message #172005] Tue, 16 May 2006 00:28 Go to previous messageGo to next message
gp185007
Messages: 45
Registered: April 2005
Location: Mumbai
Member
You can ping from Sql Plus using

host ping (ip address);
Re: Ping an IP from oracle-check for response. [message #172321 is a reply to message #172317] Tue, 16 May 2006 01:03 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: March 2000
Senior Member
The OP wants to handle the ping-response. Host will not return any indication of the result.
Re: Ping an IP from oracle-check for response. [message #440008 is a reply to message #172005] Wed, 20 January 2010 09:55 Go to previous messageGo to next message
joseflores.cl
Messages: 1
Registered: January 2010
Junior Member
This is an example of PING in PL/SQL:
-------------------------------------
C_PING_OK           CONSTANT VARCHAR2(10)  := 'OK';
C_PING_ERROR        CONSTANT VARCHAR2(10)  := 'ERROR';

FUNCTION PING(p_HOST_NAME VARCHAR2, p_PORT NUMBER DEFAULT 1000) RETURN VARCHAR2;--Retorna 'OK', 'ERROR'

FUNCTION PING(p_HOST_NAME VARCHAR2, p_PORT NUMBER DEFAULT 1000) RETURN VARCHAR2--Retorna 'OK', 'ERROR'
  IS  
    tcpConnection  UTL_TCP.CONNECTION;  --TCP/IP connection to the server    
  BEGIN
    tcpConnection := UTL_TCP.open_connection(remote_host => p_HOST_NAME, remote_port => p_PORT);
    UTL_TCP.close_connection(tcpConnection);    
    --Que raro...el host tiene abierto el puerto 1000...
    RETURN C_PING_OK;    
  EXCEPTION 
    WHEN UTL_TCP.NETWORK_ERROR THEN
      IF( UPPER(SQLERRM) LIKE '%HOST%' )THEN --Host inaccesible
        RETURN C_PING_ERROR;        
      ELSIF(UPPER(SQLERRM) LIKE '%LISTENER%' )THEN--El host es accesible, pero no hay listener => el PING si funciono!
        RETURN C_PING_OK;        
      ELSE--Mensaje SQLERRM desconocido: este es un error grave!
        RAISE;
      END IF;            
  END PING;

[Updated on: Wed, 20 January 2010 10:06] by Moderator

Report message to a moderator

Re: Ping an IP from oracle-check for response. [message #440010 is a reply to message #440008] Wed, 20 January 2010 10:07 Go to previous messageGo to next message
Michel Cadot
Messages: 63820
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Thank you for the function.

Regards
Michel
Re: Ping an IP from oracle-check for response. [message #440066 is a reply to message #440010] Wed, 20 January 2010 22:25 Go to previous message
ramoradba
Messages: 2454
Registered: January 2009
Location: AndhraPradesh,Hyderabad,I...
Senior Member
i think this is the first positive responce from Michel for the 4 year old post......Wink

sriram Smile
Previous Topic: Pipe Delimitted file in CSV format
Next Topic: Does the value is set to null when exception raised?
Goto Forum:
  


Current Time: Sat Oct 01 17:52:24 CDT 2016

Total time taken to generate the page: 0.12356 seconds