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 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
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]).
"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 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
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.
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]). This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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....
|
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...
|
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...
|
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...
|
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...
|
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 =...
|
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 *,...
|
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...
|
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...
|
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,...
|
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$) {
}
...
|
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...
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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...
|
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...
| |