Home » SQL & PL/SQL » SQL & PL/SQL » binary to hexadecimal conversion (oracle 11gr2)
binary to hexadecimal conversion [message #643735] Fri, 16 October 2015 09:08 Go to next message
guddu_12
Messages: 227
Registered: April 2012
Location: UK
Senior Member
Dear gurus

How to convert binary value into hexadecimal in oracle, i googled for the solution and couldn't get any clue.

Any help will be greatly appreciated.

Thanks
Re: binary to hexadecimal conversion [message #643736 is a reply to message #643735] Fri, 16 October 2015 09:10 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
guddu_12 wrote on Fri, 16 October 2015 07:08
Dear gurus

How to convert binary value into hexadecimal in oracle, i googled for the solution and couldn't get any clue.

Any help will be greatly appreciated.

Thanks


Starting from the right most bit, every 4 binary digits equals 1 hexadecimal character; which has NOTHING to do with Oracle DB.
Re: binary to hexadecimal conversion [message #643737 is a reply to message #643736] Fri, 16 October 2015 09:19 Go to previous messageGo to next message
guddu_12
Messages: 227
Registered: April 2012
Location: UK
Senior Member
Hi Blackswan

I have some data in binary e.g 1010 which is not informational, i need to convert into hexadecimal so as it will return "A" for binary 1010.

I am looking for any function in oracle
Re: binary to hexadecimal conversion [message #643738 is a reply to message #643737] Fri, 16 October 2015 09:33 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
guddu_12 wrote on Fri, 16 October 2015 07:19
Hi Blackswan

I have some data in binary e.g 1010 which is not informational, i need to convert into hexadecimal so as it will return "A" for binary 1010.

I am looking for any function in oracle



You are free to write your own function because Oracle does not supply what you desire.
Realize that "1010" is text string & not really binary; even though it can be viewed as a binary value.
Re: binary to hexadecimal conversion [message #643739 is a reply to message #643737] Fri, 16 October 2015 09:36 Go to previous messageGo to next message
Littlefoot
Messages: 21826
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Here are some conversion functions; check what they do, get the idea, develop your own function.
Re: binary to hexadecimal conversion [message #643745 is a reply to message #643735] Fri, 16 October 2015 10:27 Go to previous message
John Watson
Messages: 9003
Registered: January 2010
Location: Global Village
Senior Member
orclz> select to_char(1234,'XXXX') from dual;

TO_CH
-----
  4D2

orclz>
orclz> select bin_to_num(1,0,1,0,1) from dual;

BIN_TO_NUM(1,0,1,0,1)
---------------------
                   21

orclz>

[Updated on: Fri, 16 October 2015 10:32]

Report message to a moderator

Previous Topic: I need to process a string with arithmetic operators
Next Topic: To replace value where the date falls
Goto Forum:
  


Current Time: Sun Jul 19 15:33:10 CDT 2026