Advertisement

05.07.2008 at 11:57AM PDT, ID: 23383901
[x]
Attachment Details

Hex to Decimal conversion in postgresql

Asked by bethamsetty in PostgreSQL Database

Tags: postgresql, postgresql

Hi,
Can anyone tell me how to convert hex to decimal conversion only through sql (don't want to create function). I tried 2 things first one worked when I pass value physically but second one got error message

1)
select x'80512b5e'::bigint as f

Results are : -2131666964

Above one worked well

2)
create table hello(num int, name char(15));
insert into hello values(1,'80f157ec');

select name::bigint as DecimalVallue from hello

Getting below exception when i issue above sql command

Error: Bad int8 external representation "80f157ec"


Any thoughts how to do that ?

Thanks
SriStart Free Trial
 
 
[+][-]05.14.2008 at 12:35PM PDT, ID: 21567889

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.14.2008 at 02:43PM PDT, ID: 21569011

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: PostgreSQL Database
Tags: postgresql, postgresql
Sign Up Now!
Solution Provided By: bethamsetty
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628