dbTalk Databases Forums  

IP address from long

comp.databases.oracle.misc comp.databases.oracle.misc


Discuss IP address from long in the comp.databases.oracle.misc forum.



Reply
 
Thread Tools Display Modes
  #11  
Old   
Maxim Demenko
 
Posts: n/a

Default Re: IP address from long - 05-27-2008 , 01:24 PM






DA Morgan schrieb:
Quote:
Á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


Reply With Quote
  #12  
Old   
Maxim Demenko
 
Posts: n/a

Default Re: IP address from long - 05-27-2008 , 01:24 PM






DA Morgan schrieb:
Quote:
Á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


Reply With Quote
  #13  
Old   
Maxim Demenko
 
Posts: n/a

Default Re: IP address from long - 05-27-2008 , 01:24 PM



DA Morgan schrieb:
Quote:
Á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


Reply With Quote
  #14  
Old   
sircco
 
Posts: n/a

Default Re: IP address from long - 05-27-2008 , 03:54 PM



On 2008-05-27, Maxim Demenko <mdemenko (AT) gmail (DOT) com> wrote:
Quote:
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
even better


Reply With Quote
  #15  
Old   
sircco
 
Posts: n/a

Default Re: IP address from long - 05-27-2008 , 03:54 PM



On 2008-05-27, Maxim Demenko <mdemenko (AT) gmail (DOT) com> wrote:
Quote:
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
even better


Reply With Quote
  #16  
Old   
sircco
 
Posts: n/a

Default Re: IP address from long - 05-27-2008 , 03:54 PM



On 2008-05-27, Maxim Demenko <mdemenko (AT) gmail (DOT) com> wrote:
Quote:
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
even better


Reply With Quote
  #17  
Old   
sircco
 
Posts: n/a

Default Re: IP address from long - 05-27-2008 , 03:54 PM



On 2008-05-27, Maxim Demenko <mdemenko (AT) gmail (DOT) com> wrote:
Quote:
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
even better


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.