Search Postgresql Archives

Re: Conversion from CHAR HEX

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 05/27/2014 09:47 AM, saqibrafique wrote:

fm_db_Server1=# *select to_hex(to_number(substr(from_ip, 1, 3), '999'))  as
price from operator;*
/ERROR:  function to_hex(numeric) does not exist
LINE 1: select to_hex(to_number(substr(from_ip, 1, 3), '999'))  as p...
                ^

There's no to_hex function for the NUMERIC type. You also don't need the to_number function call. And of course, your function usage will break if there are ever less than 3 characters in your first octet.

Change your query to this:

select to_hex(split_part(from_ip, '.', 1)::INT) as price
  from operator;

--
Shaun Thomas
OptionsHouse, LLC | 141 W. Jackson Blvd. | Suite 800 | Chicago IL, 60604
312-676-8870
sthomas@xxxxxxxxxxxxxxxx

______________________________________________

See http://www.peak6.com/email_disclaimer/ for terms and conditions related to this email



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux