X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 1D0015E46C0 for ; Mon, 16 Aug 2004 20:30:59 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 02344-01 for ; Mon, 16 Aug 2004 23:30:57 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 339E25E46C4 for ; Mon, 16 Aug 2004 20:30:55 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i7GNUtlx018605; Mon, 16 Aug 2004 19:30:55 -0400 (EDT) To: =?ISO-8859-1?Q?Elieser_Le=E3o?= Cc: pgsql-sql@postgresql.org Subject: Re: Verifying data type In-reply-to: <4121241C.6000300@nho.com.br> References: <4121241C.6000300@nho.com.br> Comments: In-reply-to =?ISO-8859-1?Q?Elieser_Le=E3o?= message dated "Mon, 16 Aug 2004 18:16:12 -0300" Date: Mon, 16 Aug 2004 19:30:55 -0400 Message-ID: <18604.1092699055@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200408/152 X-Sequence-Number: 18649 =?ISO-8859-1?Q?Elieser_Le=E3o?= writes: > I need to verify if the data in p_valor is just number or it is a string. > What is the best way to do this? In PG 8.0 you can just do it exactly the way your Oracle original does, viz try to cram it into a numeric variable and catch the exception if any. In earlier versions, my thoughts would run to some kind of string matching test using a regular expression. The regexp method is probably significantly faster though, so maybe you want to do it anyway, especially if you don't need the full generality of possible floating-point formats. You might get away with something as simple as "p_valor ~ '^[0-9]+$'" if you only care about unsigned integer inputs. regards, tom lane