Re: Convert int to hex

From: "Ramakrishnan Muralidharan" <ramakrishnanm(at)pervasive-postgres(dot)com>
To: "Fernando Grijalba" <fgrijalba(at)gmail(dot)com>, <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Convert int to hex
Date: 2005-06-02 09:17:40
Message-ID: 02767D4600E59A4487233B23AEF5C59922C2B8@blrmail1.aus.pervasive.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi,

You can use to_hex() function to convert integer to hexa number. I have tried with a small example.

create table testing( id int4 , sHex varchar( 20 ) )

insert into testing( id ) values( 204678 );
insert into testing( id ) values( 2076876 );

update testing set sHex = ( cast( to_hex( id ) as varchar( 20 ) ) )

select * from testing

Id | shex
-------|------
204678 | 31f86
2076876| 1fb0cc

Regards,
R.Muralidharan

-----Original Message-----
From: pgsql-sql-owner(at)postgresql(dot)org
[mailto:pgsql-sql-owner(at)postgresql(dot)org]On Behalf Of Fernando Grijalba
Sent: Thursday, June 02, 2005 2:12 AM
To: pgsql-sql(at)postgresql(dot)org
Subject: [SQL] Convert int to hex

I want to be able to change an int4 from a sequence and store it as
varchar in the database as a hex number.

Is this possible?

Thank you,

Fernando

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Browse pgsql-sql by date

  From Date Subject
Next Message Ramakrishnan Muralidharan 2005-06-02 09:40:37 Re: [SQL] index row size 2728 exceeds btree maximum, 2713
Previous Message Richard Huxton 2005-06-02 07:14:39 Re: Convert int to hex