Re: Testing castability of text to numeric

From: Christoph Haller <ch(at)rodos(dot)fzk(dot)de>
To: pgsql-sql(at)postgresql(dot)org
Cc: rlucas(at)tercent(dot)net
Subject: Re: Testing castability of text to numeric
Date: 2003-05-16 09:43:22
Message-ID: 3EC4B2BA.B872FCDF@rodos.fzk.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

>
> 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.
>
I don't know of any way to catch errors.
And I can't see any way how to test castability via regex. Can you?
The only way I can think of at the moment is writing a C function.

Regards, Christoph

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Christoph Haller 2003-05-16 10:53:45 Re: lock status check
Previous Message Christoph Haller 2003-05-16 08:41:40 Re: See Temp Table from Trigger