Home » SQL & PL/SQL » SQL & PL/SQL » cast RAW to number (oracle 10)
cast RAW to number [message #313028] Thu, 10 April 2008 07:33 Go to next message
DeeDee
Messages: 14
Registered: March 2008
Junior Member
Hi,
I have the problem that I need to cast a raw to a number. I did see the function "utl_raw.cast_to_number", but unfortunately this only returns a number containing the first 2 (or so) bytes, while the raw is 128 bits long and I want to store it in a number(16) :-/ any suggestions?
Re: cast RAW to number [message #313030 is a reply to message #313028] Thu, 10 April 2008 07:40 Go to previous messageGo to next message
Michel Cadot
Messages: 64122
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
This is not my experience.
Can you post exactly what you did: description of table, insert statements, values, select statements and so on that we can see and reproduce it.

Regards
Michel

Re: cast RAW to number [message #313034 is a reply to message #313030] Thu, 10 April 2008 07:54 Go to previous messageGo to next message
DeeDee
Messages: 14
Registered: March 2008
Junior Member
is
result raw(128);
num number(16);
begin
    select dbms_crypto.hash(utl_raw.cast_to_raw('asliie.sadfs'),
                            DBMS_CRYPTO.hash_md5) 
    into result from dual;
    dbms_output.PUT_LINE(result);
    num := utl_raw.cast_to_number(result);
    DBMS_OUTPUT.PUT_LINE(num);
end test;

will give me the output:

8E3384498E9D99F721CAA00ED03BD641
0



Well, I do need the output from the hash function. It returns a RAW. Wikipedia said, that md5 hash functions return 128bit values :-/

[Updated on: Thu, 10 April 2008 10:33] by Moderator

Report message to a moderator

Re: cast RAW to number [message #313076 is a reply to message #313034] Thu, 10 April 2008 10:36 Go to previous messageGo to next message
Michel Cadot
Messages: 64122
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
128/8 = 16 bytes = 32 hexa digits.
8E3384498E9D99F721CAA00ED03BD641 is 32 hexa digits, so Wikipedia is true.

But NUMBER(16) is 16 decimal digits far less than 32 hexadecimal digits.

Regards
Michel

Re: cast RAW to number [message #313080 is a reply to message #313076] Thu, 10 April 2008 10:54 Go to previous message
DeeDee
Messages: 14
Registered: March 2008
Junior Member
oh god, you're right.. wth gave me the idea the 16 hat anything to do with bytes? *grr*
why me??
Well, thanks for the help!
Previous Topic: Oracle Connect by - all parents of child in 1 row
Next Topic: Automatically create index on foreign key columns?
Goto Forum:
  


Current Time: Wed Dec 07 05:13:55 CST 2016

Total time taken to generate the page: 0.08901 seconds