X-Original-To: pgsql-sql@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id CF026476A4E for ; Fri, 16 May 2003 05:43:25 -0400 (EDT) Received: from postgresql.org ([64.49.215.8]) by localhost (postgresql.org [64.49.215.8:10024]) (amavisd-new) with ESMTP id 19729-10 for ; Fri, 16 May 2003 05:43:23 -0400 (EDT) Received: from fzkmail2.fzk.de (fzkmail2.fzk.de [141.52.27.52]) by postgresql.org (Postfix) with SMTP id 26818476A4B for ; Fri, 16 May 2003 05:43:23 -0400 (EDT) Received: FROM resy5.fzk.de BY fzkmail2.fzk.de ; Fri May 16 11:43:45 2003 +0200 Received: œby rodos.fzk.de with ESMTP (8.8.6 (PHNE_17135)/8.7.1) id LAA06565; Fri, 16 May 2003 11:43:23 +0200 (METDST) Message-ID: <3EC4B2BA.B872FCDF@rodos.fzk.de> Date: Fri, 16 May 2003 11:43:22 +0200 From: Christoph Haller X-Mailer: Mozilla 4.77 [en] (X11; U; HP-UX B.10.20 9000/780) X-Accept-Language: en MIME-Version: 1.0 To: pgsql-sql@postgresql.org Cc: rlucas@tercent.net Subject: Re: Testing castability of text to numeric Content-Type: text/plain; charset=iso-8859-2 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new X-Archive-Number: 200305/344 X-Sequence-Number: 13509 > > 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