Home » SQL & PL/SQL » SQL & PL/SQL » converting a number to hex
converting a number to hex [message #196352] Thu, 05 October 2006 02:01 Go to next message
Messages: 142
Registered: May 2005
Senior Member
Is there a builtin function for converting a number to hex?If not i need the logic for it.
Re: converting a number to hex [message #196354 is a reply to message #196352] Thu, 05 October 2006 02:06 Go to previous messageGo to next message
Messages: 7880
Registered: March 2000
Senior Member
I somehow doubt you googled for it and read all 558,000 hits.
Re: converting a number to hex [message #196364 is a reply to message #196352] Thu, 05 October 2006 02:21 Go to previous message
Messages: 7062
Registered: December 2001
Senior Member
From the "Oracle 9i SQL Reference"

Chapter 2: "Basic Elements of Oracle SQL", "Format Models", Table 2-13 "Number Format Elements": X

Returns the hexadecimal value of the specified number of digits. If the specified number is not an integer, then Oracle rounds it to an integer.


* This element accepts only positive values or 0. Negative values return an error.
* You can precede this element only with 0 (which returns leading zeroes) or FM. Any other elements return an error. If you specify neither 0 nor FM with X, then the return always has 1 leading blank.
So, you can use it as follows:
select to_char(1515,'XXXX') x
from   dual

[edit]Drat! Forgot that site Frank mentioned!


[Updated on: Thu, 05 October 2006 02:22]

Report message to a moderator

Previous Topic: Database Trigger
Next Topic: unable to update column
Goto Forum:

Current Time: Fri Oct 28 09:46:28 CDT 2016

Total time taken to generate the page: 0.09013 seconds