473,386 Members | 1,828 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Unsigned integer to IP address?

Hello everyone,
My question is how to upload an unsigned integer so that it looks like
an IP address in Oracle?
A Perl program captures IP addresses from a log server and puts them
into a .csv file that I then sqload into Oracle. When I query the db
the numbers look very different e.g., (just an example) 2423598587
instead of 134.290.34.59 (this was made up, any similarity to real IP
is pure coincidence).
I need them to look like an IP address.

Thank you much,

Monica
Jul 19 '05 #1
6 23999
mo*********@yahoo.com (Monica Roman) wrote in message news:<9e**************************@posting.google. com>...
Hello everyone,
My question is how to upload an unsigned integer so that it looks like
an IP address in Oracle?
A Perl program captures IP addresses from a log server and puts them
into a .csv file that I then sqload into Oracle. When I query the db
the numbers look very different e.g., (just an example) 2423598587
instead of 134.290.34.59 (this was made up, any similarity to real IP
is pure coincidence).
I need them to look like an IP address.

Thank you much,

Monica


How did you load it to get different values out versus what was
loaded? Your process obviously is flawed. IMHO you can store it in the
DB as either

a text field and load and use it as text

or

4 integer fields, one for each portion.

Those are the choices I see.

HTH
ed
Jul 19 '05 #2
Monica Roman wrote:
Hello everyone,
My question is how to upload an unsigned integer so that it looks like
an IP address in Oracle?
A Perl program captures IP addresses from a log server and puts them
into a .csv file that I then sqload into Oracle. When I query the db
the numbers look very different e.g., (just an example) 2423598587
instead of 134.290.34.59 (this was made up, any similarity to real IP
is pure coincidence).
I need them to look like an IP address.

Thank you much,

Monica


Inside the OS an IP# is just a 32-bit integer.
It is typically represented in what is called "dottted-quad" notation.
This means that each 8-bit byte (0-255) represents one of the 4 numbers
displayed. So you need to "convert" the large decimal number into the
appropriate ONE & ZERO, group them into four 8 bits bytes & the convert
those four values back to decimal (Small Matter Of Programming [SMOP]).

Jul 19 '05 #3
"Ana C. Dent" <an*******@hotmail.com> wrote in message news:<lGhgb.54981$Ms2.34316@fed1read03>...

Inside the OS an IP# is just a 32-bit integer.
It is typically represented in what is called "dottted-quad" notation.
This means that each 8-bit byte (0-255) represents one of the 4 numbers
displayed. So you need to "convert" the large decimal number into the
appropriate ONE & ZERO, group them into four 8 bits bytes & the convert
those four values back to decimal (Small Matter Of Programming [SMOP]).


Ana, Thank you! Now the question is how do I do that? Or, where can I
find info, any books or articles you can recommend?

Thanks,

Monica
Jul 19 '05 #4
mo*********@yahoo.com (Monica Roman) wrote in message news:<9e**************************@posting.google. com>...
"Ana C. Dent" <an*******@hotmail.com> wrote in message news:<lGhgb.54981$Ms2.34316@fed1read03>...

Inside the OS an IP# is just a 32-bit integer.
It is typically represented in what is called "dottted-quad" notation.
This means that each 8-bit byte (0-255) represents one of the 4 numbers
displayed. So you need to "convert" the large decimal number into the
appropriate ONE & ZERO, group them into four 8 bits bytes & the convert
those four values back to decimal (Small Matter Of Programming [SMOP]).


Ana, Thank you! Now the question is how do I do that? Or, where can I
find info, any books or articles you can recommend?

Thanks,

Monica

Your initial quest was about loading it into the DB and then
displaying it later. Have you yet chosen what datatype to store it in:
VARCHAR, CHAR, INTEGER, BLOB?

You need the format for input via SQL*Loader
You need the format desired for display (this might be the default if
you choose the datatype well)
You may need the format for programs (PERL, C, PL/SQL) to use

The books I'd recommend are the oracle manuals. Basically your
questions are too vague to warrant a more precise answer.

Since you said you did get it to load some data but it did "look
right", how about showing us the code you've tried so far. That would
certainly show a little better what your problem is.

Ed
Jul 19 '05 #5
Monica Roman wrote:
"Ana C. Dent" <an*******@hotmail.com> wrote in message news:<lGhgb.54981$Ms2.34316@fed1read03>...
Inside the OS an IP# is just a 32-bit integer.
It is typically represented in what is called "dottted-quad" notation.
This means that each 8-bit byte (0-255) represents one of the 4 numbers
displayed. So you need to "convert" the large decimal number into the
appropriate ONE & ZERO, group them into four 8 bits bytes & the convert
those four values back to decimal (Small Matter Of Programming [SMOP]).

Ana, Thank you! Now the question is how do I do that? Or, where can I
find info, any books or articles you can recommend?

Thanks,

Monica

PERL has a built-in function ( but I don't recall its name right now)
which "converts" the integer into a dotted-quad string; complete with
three decimal points in the correct places.

Jul 19 '05 #6
In no particular language (i.e., you may need FLOOR() instead of INT())...

To convert dotted (A.B.C.D) to a number:
D
+ 256 * C
+ 256 * 256 * B
+ 256 * 256 * 256 * A

To convert number (X) back to dotted:
temp = X / 256
D = 256 * (temp - INT(temp))
temp = (INT (temp)) / 256
C = 256 * (temp - INT(temp))
temp = (INT (temp)) / 256
B = 256 * (temp - INT(temp))
A = INT (temp)

(There is a chance I have the endian-ness wrong,
in which case swap A<->D and B<->C in the calculations.)

Regards,

ETA

"Ana C. Dent" <an*******@hotmail.com> wrote in message news:<lGhgb.54981$Ms2.34316@fed1read03>...
Monica Roman wrote:
Hello everyone,
My question is how to upload an unsigned integer so that it looks like
an IP address in Oracle?
A Perl program captures IP addresses from a log server and puts them
into a .csv file that I then sqload into Oracle. When I query the db
the numbers look very different e.g., (just an example) 2423598587
instead of 134.290.34.59 (this was made up, any similarity to real IP
is pure coincidence).
I need them to look like an IP address.

Thank you much,

Monica


Inside the OS an IP# is just a 32-bit integer.
It is typically represented in what is called "dottted-quad" notation.
This means that each 8-bit byte (0-255) represents one of the 4 numbers
displayed. So you need to "convert" the large decimal number into the
appropriate ONE & ZERO, group them into four 8 bits bytes & the convert
those four values back to decimal (Small Matter Of Programming [SMOP]).

Jul 19 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Rade | last post by:
Following a discussion on another thread here... I have tried to understand what is actually standardized in C++ regarding the representing of integers (signed and unsigned) and their conversions....
5
by: Mathieu Malaterre | last post by:
Hello, I have the following problem. I need to convert a unsigned char array into a string using only number (0-9) and '.'. The goal being to stored it on the minimal number of bytes. The...
9
by: John Rigler | last post by:
It seems like I should be able to define an unsigned integer type for a DB2 field, but I don't see that option. What is the cleanest way to do this; I could represent my number as a signed...
10
by: Peter Piper | last post by:
A Quick question if someone could help, im sure this has been asked before, but googling is getting me now where slowly. Is it possible to get an unsigned 32 bit integer field in Access. Im...
3
by: codefixer | last post by:
Hi, I was wondering what will be the output for this piece of code. I am in confusion regarding the promotions of bitfield. If your reply is to compile, execute and check out myself, Thank you...
3
by: Mike Miller | last post by:
What is the best way to convert a managed unsigned int64 to an unsigned long? Basically I need to do the following: System::UInt64 managedInt = 10; unsigned long unmanagedInt; unmanagedInt =...
6
by: Steven Jones | last post by:
Can anybody illustrate the usefulness of having char and unsigned char? I mean, under what circumstances would one want to use unsigned char (or unsigned char *) rather than char (or char *,...
3
by: QQ | last post by:
Hello, Here is my simple program int main() { unsigned char a =0x81; char b = 0x81; printf("unsigned char = 0x%x(%d), char = 0x%x(%d)\n",a,a,b,b); printf("cast char to unsigned...
2
by: Christian Christmann | last post by:
Hi, what does the ANSI C-99 standard says when an unsigned variable is assigned a negative number?, i.e. unsigned char a = -100; Is this undefined behavior or should the negative number...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.