pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Randall Lucas <rlucas@tercent.net>
To: Achilleus Mantzios <achill@matrix.gatewaynet.com>
Cc: Christoph Haller <ch@rodos.fzk.de>
Cc: pgsql-sql@postgresql.org
Subject: Re: Testing castability of text to numeric
Date: Wed, 21 May 2003 14:55:17 -0400
Message-ID: <C3B949D4-8BBD-11D7-8176-000A957653D6@tercent.net> (raw)
In-Reply-To: <Pine.LNX.4.44.0305161248550.10647-100000@matrix.gatewaynet.com>

Hi Folks,

I thought that I would point out that an answer that answers my 
original query (how to test for castability without throwing exception) 
was posted to the pgsql-general list on Sunday, by Joe Conway.  He has 
an "str_validate" set of functions which he makes available at 
joeconway.com.  Thanks to Joe.

Best,

Randall


On Friday, May 16, 2003, at 10:57 AM, Achilleus Mantzios wrote:

> On Fri, 16 May 2003, Christoph Haller wrote:
>
>>>
>>> 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.
>
> I think that progress is being made on
> having java as a serverside language
> (i.e. plpgjava).
> Stored procedures in java would be really handy in order
> to do staff like that, java is known for its
> "exceptional" exception handling!
>
> What language do you use to bould your applications??
>
>>>
>>> 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
>>
>>
>>
>> ---------------------------(end of 
>> broadcast)---------------------------
>> TIP 4: Don't 'kill -9' the postmaster
>>
>
> -- 
> ==================================================================
> Achilleus Mantzios
> S/W Engineer
> IT dept
> Dynacom Tankers Mngmt
> Nikis 4, Glyfada
> Athens 16610
> Greece
> tel:    +30-210-8981112
> fax:    +30-210-8981877
> email:  achill@matrix.gatewaynet.com
>         mantzios@softlab.ece.ntua.gr
>
>
> ---------------------------(end of 
> broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
>




view thread (8+ messages)  latest in thread

Message-ID: <C3B949D4-8BBD-11D7-8176-000A957653D6@tercent.net>
Permalink:  ../C3B949D4-8BBD-11D7-8176-000A957653D6@tercent.net/
Also on:    postgresql.org/message-id/C3B949D4-8BBD-11D7-8176-000A957653D6@tercent.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: rlucas@tercent.net, achill@matrix.gatewaynet.com, ch@rodos.fzk.de
  Subject: Re: Testing castability of text to numeric
  In-Reply-To: <C3B949D4-8BBD-11D7-8176-000A957653D6@tercent.net>
  References: <Pine.LNX.4.44.0305161248550.10647-100000@matrix.gatewaynet.com> <C3B949D4-8BBD-11D7-8176-000A957653D6@tercent.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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