Re: [SQL] Type conversion from TEXT to DOUBLE PRECISION

2004-01-09 Thread Daniel Lau
On Fri, 9 Jan 2004, Tom Lane wrote: > Richard Huxton <[EMAIL PROTECTED]> writes: > > Since your error seems to be complaining about a space, I'd guess you've got > > other than numeric values in _aaa. > > In fact, with a bit of experimentation I see the same error message: > > regression=# sel

Re: [SQL] Type conversion from TEXT to DOUBLE PRECISION

2004-01-09 Thread Tom Lane
Richard Huxton <[EMAIL PROTECTED]> writes: > Since your error seems to be complaining about a space, I'd guess you've got > other than numeric values in _aaa. In fact, with a bit of experimentation I see the same error message: regression=# select to_number('12345', '9'); to_number

Re: [SQL] Type conversion from TEXT to DOUBLE PRECISION

2004-01-09 Thread Richard Huxton
On Friday 09 January 2004 07:35, Daniel Lau wrote: > 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 > Varchar[10] | Double Precision > _aaa _bbb > 1234567890 > I used two functions t

Re: [SQL] Type conversion from TEXT to DOUBLE PRECISION

2004-01-09 Thread Tom Lane
Daniel Lau <[EMAIL PROTECTED]> writes: > 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), '9'); > The machine fails me and said > ERROR: invalid input syntac for type numeric: " " Works for me

Re: [SQL] Type conversion

2000-07-10 Thread Thomas Lockhart
> select TheNumberFromConsole/(select max(division_point) from table1) Try select '1234.5678'/(select max(division_point) from table1); The quotes around the apparent floating point number keeps Postgres from assuming that it *is* a floating point number, and it later decides that it must hav

Re: [SQL] Type conversion

2000-06-20 Thread Ed Loehr
Tom Lane wrote: > > Ice Planet <[EMAIL PROTECTED]> writes: > > B: insert into t2 values (select int2(int4(b)) from t1 where a = 1) > > Works for me when spelled correctly: I think you can also leave out the 'values' for a sub-select insert, though I haven't checked to see if it matters... Rega

Re: [SQL] Type conversion

2000-06-20 Thread Tom Lane
Ice Planet <[EMAIL PROTECTED]> writes: > B: insert into t2 values (select int2(int4(b)) from t1 where a = 1) Works for me when spelled correctly: regression=# insert into t2 (select int2(int4(b)) from t1 where a = 1); INSERT 314647 1 If you make a suitable conversion function then you can omit