Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> translate an ip

translate an ip

From: Andrew Kerber <andrew.kerber_at_gmail.com>
Date: Tue, 28 Aug 2007 09:27:36 -0500
Message-ID: <ad3aa4c90708280727s21e2d6afq5b51eb971b7d9f33@mail.gmail.com>


Hello experts,

I am trying to build a function to translate an IP address into its name, or vice versa. I have a mixed bag of IP addresses and DNS names, all culled from AUD$ history tables. What I need is a consistent format, either IP or DNS name, so I can consolidate the information. I am trying to use utl_inaddr.get_host_name. It works, but if it encounters an IP that it can't translate, my SQL statement fails. The same for using utl_inaddr.get_host_address. What I have so far is below. It compiles, but it doesn't catch the error. What I need is something that will either translate the address, or else return the original value. I would appreciate any help you might have to offer.

Create or replace function translate_address (input_val IN VARCHAR2) RETURN VARCHAR2
is
return_val varchar2(30);
unknown_host_errcode CONSTANT PLS_INTEGER := -29257; unknown_host EXCEPTION; -- Unknown host BEGIN
select SYS.utl_inaddr.get_host_name(input_val) into return_val from DUAL; if input_val is not null
then
  RETURN (return_val);
else

    raise unknown_host;
end if;
EXCEPTION
WHEN unknown_host
THEN
  RETURN (input_val);
END;
/

Thanx,

-- 
Andrew W. Kerber

'If at first you dont succeed, dont take up skydiving.'

--
http://www.freelists.org/webpage/oracle-l
Received on Tue Aug 28 2007 - 09:27:36 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US