|
Re: Ping an IP from oracle-check for response. [message #172021 is a reply to message #172005] |
Sat, 13 May 2006 04:46   |
Frank
Messages: 7901 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 #440008 is a reply to message #172005] |
Wed, 20 January 2010 09:55   |
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
|
|
|
|
|