pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedcasting question
3+ messages / 3 participants
[nested] [flat]
* casting question
@ 2002-02-02 15:20 A. Van Hook <hook@kcp.com>
0 siblings, 2 replies; 3+ messages in thread
From: A. Van Hook @ 2002-02-02 15:20 UTC (permalink / raw)
To: pgsql-sql
I have a column (quantityonhand | character(15) | default '' )
that I would like to use to perform simple math.
I can't seem to get the syntax for casting and have tried various
combinations of "select to_number(quantityonhand::text, '99G999D9S')".
Can not get get past ERROR: Bad numeric input format ' '.
Any help would be greatly appreciated....
tanks
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: casting question
@ 2002-02-02 18:58 Stephan Szabo <sszabo@megazone23.bigpanda.com>
parent: A. Van Hook <hook@kcp.com>
1 sibling, 0 replies; 3+ messages in thread
From: Stephan Szabo @ 2002-02-02 18:58 UTC (permalink / raw)
To: A. Van Hook <hook@kcp.com>; +Cc: pgsql-sql
On Sat, 2 Feb 2002, A. Van Hook wrote:
>
>
> I have a column (quantityonhand | character(15) | default '' )
> that I would like to use to perform simple math.
> I can't seem to get the syntax for casting and have tried various
> combinations of "select to_number(quantityonhand::text, '99G999D9S')".
> Can not get get past ERROR: Bad numeric input format ' '.
>
>
> Any help would be greatly appreciated....
You probably have a value in there which is not convertable to a numeric
(such as the default '').
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: casting question
@ 2002-02-04 15:05 Jeff Eckermann <jeff_eckermann@yahoo.com>
parent: A. Van Hook <hook@kcp.com>
1 sibling, 0 replies; 3+ messages in thread
From: Jeff Eckermann @ 2002-02-04 15:05 UTC (permalink / raw)
To: A. Van Hook <hook@kcp.com>; pgsql-sql
Your fields contain spaces, because of the char(15)
datatype padding them out. The numeric conversion
routine can't handle those spaces: you will need to
use a trim function (probably rtrim() will be best) to
take them out.
You can avoid this problem if you use varchar (or
text) instead of char datatype.
--- "A. Van Hook" <hook@kcp.com> wrote:
>
>
> I have a column (quantityonhand | character(15)
> | default '' )
> that I would like to use to perform simple math.
> I can't seem to get the syntax for casting and have
> tried various
> combinations of "select
> to_number(quantityonhand::text, '99G999D9S')".
> Can not get get past ERROR: Bad numeric input
> format ' '.
>
>
> Any help would be greatly appreciated....
>
>
> tanks
>
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org
__________________________________________________
Do You Yahoo!?
Great stuff seeking new owners in Yahoo! Auctions!
http://auctions.yahoo.com
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2002-02-04 15:05 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-02-02 15:20 casting question A. Van Hook <hook@kcp.com>
2002-02-02 18:58 ` Stephan Szabo <sszabo@megazone23.bigpanda.com>
2002-02-04 15:05 ` Jeff Eckermann <jeff_eckermann@yahoo.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox