Re: IP address from long

From: Maxim Demenko <mdemenko_at_gmail.com>
Date: Tue, 27 May 2008 20:24:18 +0200
Message-ID: <483C51D2.7090103@gmail.com>


DA Morgan schrieb:
> Álvaro G. Vicario wrote:

>> Does Oracle (10g) have a built-in function to convert an IPv4 address 
>> in long format into dot notation?
>>
>> For example from 3494755494 to 208.77.188.166

>
> No.

On the other side, it is a matter of few keystrokes to do it yourself...

SQL> with t as (

   2 select 3494755494 ip from dual    3 )

   4  select bitand(ip / power(2, 24), power(2, 8) - 1) || '.' ||
   5         bitand(ip / power(2, 16), power(2, 8) - 1) || '.' ||
   6         bitand(ip / power(2, 8), power(2, 8) - 1) || '.' ||
   7         bitand(ip, power(2, 8) - 1) ip_dot
   8 from t
   9 /

IP_DOT



208.77.188.166

Best regards

Maxim Received on Tue May 27 2008 - 13:24:18 CDT

Original text of this message