Re: Conversion from CHAR HEX - Mailing list pgsql-general

From Shaun Thomas
Subject Re: Conversion from CHAR HEX
Date
Msg-id 538634D1.80309@optionshouse.com
Whole thread Raw
In response to Conversion from CHAR HEX  (saqibrafique <saqibrafique@gmail.com>)
List pgsql-general
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@optionshouse.com

______________________________________________

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


pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: memory leaking ?
Next
From: Adrian Klaver
Date:
Subject: Re: Error while upgrading from 8.4 to 9.3