Testing castability of text to numeric - Mailing list pgsql-sql

From Randall Lucas
Subject Testing castability of text to numeric
Date
Msg-id 14ACA3C2-8586-11D7-8D9A-000A957653D6@tercent.net
Whole thread Raw
In response to Re: Ok, how do I debug THIS?  (Larry Rosenman <ler@lerctr.org>)
List 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



pgsql-sql by date:

Previous
From: Larry Rosenman
Date:
Subject: Re: Ok, how do I debug THIS?
Next
From: "Katka a Daniel Dunajsky"
Date:
Subject: Postgresql and Top N Analysis?