Type conversion from TEXT to DOUBLE PRECISION

From: Daniel Lau <iedaniel(at)ust(dot)hk>
To: pgsql-sql(at)postgresql(dot)org
Subject: Type conversion from TEXT to DOUBLE PRECISION
Date: 2004-01-09 07:35:20
Message-ID: Pine.WNT.3.96L2.1040109152354.256D-100000@iey118.ust.hk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi all,

Thank you for reading this mail.

I am trying to do the following:
Extract the first half of _aaa and put it in column _bbb

Here is the table, named: _table:

Varchar[10] | Double Precision
_aaa _bbb
_________________________________

1234567890

I used two functions to do it: substring() and to_number(). The SQL is
like this:
UPDATE _table SET _bbb = to_number(substring(_aaa from 1 for 5), '99999');
The machine fails me and said
ERROR: invalid input syntac for type numeric: " "

I guess the machine can not treat TEXT as CHAR[5]. I tries to CAST TEXT as
CHAR[5]. It also doesnt allow me to do so.

Can anyone give me some hints on this?

regards,
Daniel

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2004-01-09 07:47:50 Re: Type conversion from TEXT to DOUBLE PRECISION
Previous Message azwa 2004-01-09 07:15:01 Missing data for column