If I have a HEX string that I want to insert into a field\table is there a specific datatype I need to use?
Printable View
If I have a HEX string that I want to insert into a field\table is there a specific datatype I need to use?
You can use CHAR or VARCHAR2.
What I really need is to tell Oracle that this string is really a hex string and allow Oracle to convert it as needed. Example:
SELECT to_number('MY_HEX_STRING')
FROM DUAL:
The question is how do I tell Oracle that this is a HEX string?
Here is something what can help you:
http://niigata.cool.ne.jp/j8takagi/hex_to_num.txt
You can use TO_NUMBER with formatting, e.g.
--convert to number
select to_number('A','xxx') from dual
--convert to hex
select to_char(10,'x') from dual;
select to_char(10,'X') from dual;