Testing castability of text to numeric

From: Randall Lucas <rlucas(at)tercent(dot)net>
To: pgsql-sql(at)postgresql(dot)org
Subject: Testing castability of text to numeric
Date: 2003-05-13 21:01:34
Message-ID: 14ACA3C2-8586-11D7-8D9A-000A957653D6@tercent.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


Hi All,

I am trying to create a function that will test if a given text value
may safely be cast to numeric, returning the numeric cast or null if
impossible.

Is there a way to "catch" the "ERROR: Bad numeric input format" error?

I ask that rather than about what the numeric format is for regex-style
testing because if this works I may want to use a similar method to
check if a given text value casts safely to other types, like date.

Best,

Randall

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Issa 2003-05-13 21:07:08 Inquiry From Form [pgsql]
Previous Message Larry Rosenman 2003-05-13 20:31:13 Re: Ok, how do I debug THIS?