Oracle HEXTORAW() Function
Oracle HEXTORAW()
is a built-in function that converts a hexadecimal value specified as a parameter into a raw value.
HEXTORAW()
is the opposite of RAWTOHEX()
.
Oracle HEXTORAW()
Syntax
Here is the syntax for the Oracle HEXTORAW()
function:
HEXTORAW(str)
Parameters
str
-
Required. It is a string that contains hexadecimal digits. It can be of
CHAR
,VARCHAR2
,NCHAR
, orNVARCHAR2
data type.
Return Value
The Oracle HEXTORAW()
function converts the hexadecimal value specified by the parameter into a raw value and returns a value of type RAW
.
If any of the arguments are NULL
, HEXTORAW()
returns NULL
.
Oracle HEXTORAW()
Examples
Here are a few examples that demonstrate how to use the Oracle HEXTORAW()
function.
Basic Usage
The following statement converts the hexadecimal value A
into a raw value:
SELECT
HEXTORAW('A')
FROM dual;
输出:
HEXTORAW('A')
________________
0A
The following statement converts the hexadecimal value 1234
into a raw value:
SELECT
HEXTORAW('1234')
FROM dual;
输出:
HEXTORAW('1234')
___________________
1234
You can use the DUMP()
function to see the type of the return value of HEXTORAW()
:
SELECT
DUMP(HEXTORAW('1234'))
FROM dual;
输出:
DUMP(HEXTORAW('1234'))
_________________________
Typ=23 Len=2: 18,52
NULL Parameter
If any of the arguments are NULL
, HEXTORAW()
returns NULL
.
SET NULL 'NULL';
SELECT
HEXTORAW(NULL)
FROM dual;
输出:
HEXTORAW(NULL)
_________________
NULL
In this example, we used the statement SET NULL 'NULL';
to display the NULL
value as the string 'NULL'
.
Conclusion
Oracle HEXTORAW()
is a built-in function that converts a hexadecimal value specified as a parameter into a raw value.