Home » SQL & PL/SQL » SQL & PL/SQL » sql
sql [message #20854] Tue, 25 June 2002 20:20 Go to next message
moloy
Messages: 8
Registered: June 2002
Junior Member
How can i convert char data to hexadecimal and vice versa in oracle
Re: sql [message #20855 is a reply to message #20854] Tue, 25 June 2002 22:31 Go to previous messageGo to next message
Maaher
Messages: 7065
Registered: December 2001
Senior Member
The numeric format 'X' defines hexadecimal.

SQL> select to_char(123,'XXX') from dual;

TO_C
----
  7B

SQL> select to_number('7B','XXX') from dual;

TO_NUMBER('7B','XXX')
---------------------
                  123


HTH,
MHE
Re: sql [message #20859 is a reply to message #20854] Wed, 26 June 2002 00:45 Go to previous messageGo to next message
moloy
Messages: 8
Registered: June 2002
Junior Member
but maher

u are passing number argument.
Actually i need to pass character
and get hexadecimal in return..

moloy
Re: sql [message #20866 is a reply to message #20854] Wed, 26 June 2002 09:17 Go to previous message
Todd Barry
Messages: 4819
Registered: August 2001
Senior Member
sql>select rawtohex('moloy') tohex from dual;
 
TOHEX
----------
6D6F6C6F79
 
sql>select utl_raw.cast_to_varchar2(hextoraw('6D6F6C6F79')) fromhex from dual;
 
FROMHEX
------------------------------------------------------------------------------
moloy
Previous Topic: nested sql statement
Next Topic: Controlling number of employees in specific department
Goto Forum:
  


Current Time: Thu Apr 25 10:22:52 CDT 2024