var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: IP Address stored as Binary(4)
But, I want to display normally in report. This is just something I am not familiar with.
My IP Address for 126.96.36.199 is stored as 00AEC590. How do I convert that binary(4) back to its original format?
I'm not connected to DB so I can't test it, but my suggestion is:
your hex: 00AEC590 represent your IP
00 = 0
AE = 174
C5 = 197
90 = 144
so split your string to four char(2) and convert them from HEX to DEC using dump() or similar function.
substr(IP, 7,2) returns 90
substr(IP, 5,2) returns C5
substr(IP, 3,2) returns AE
substr(IP, 1,2) returns 00
then put strings together using || and separate them by '.' something like:
see manual how to use dump()
select dump(substr(IP, 7, 2)...) || '.' || dump(substr(IP, 5, 2)...) || '.' || dump(substr(IP, 3, 2)...) || '.' || dump(substr(IP, 1, 2)...);
Yes, I agree with the substr/concatenation solution, however, I want to convert the HEX values to decimal for display...
ipaddress = 00AEC590
substr(ipaddress,7,2)||'.'||substr(ipaddress,5,2)| |'.'||substr(ipaddress,3,2)||'.'||substr(ipaddress ,1,2)
will yield something like 90.C5.AE.00. Now I need to get to
use dump() for conversion. I'm not familiar with this function and I'm not connected to DB (I can't test it), so you have to do it your self. use manuals, helps, examples, google. I'm sure finaly you'll sort this out.
SQL> col ip_address format a15
SQL> SELECT TO_NUMBER(SUBSTR(val,7,2),'XX') || '.' ||
2 TO_NUMBER(SUBSTR(val,5,2),'XX') || '.' ||
3 TO_NUMBER(SUBSTR(val,3,2),'XX') || '.' ||
4 TO_NUMBER(SUBSTR(val,1,2),'XX') AS ip_address
5 FROM ( SELECT '00AEC590' AS val FROM dual ) b;
1 row selected.
Last edited by WilliamR; 11-29-05 at
Thanks for the help.