Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

How can I convert a string to a double precision in PostgreSQL ?

I tried something like :

update points set latitude2 = cast(latitude as double) ;

where latitude is a string and latitude2 is a double. I just can't get it to work.

share|improve this question
3  
"can't get it to work" is not a valid Postgres error message. Please post the complete error (or describe what exactly isn't working) –  a_horse_with_no_name Jul 11 '11 at 7:01
add comment

1 Answer

double is not a postgres data type:

select cast('324342' as double);
ERROR:  type "double" does not exist

but double precision is:

select cast('132342' as double precision);

 float8
--------
 132342
(1 row)

So try:

update points set latitude2 = cast(latitude as double precision) ;
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.