pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Elieser Leão <elieser@nho.com.br>
To: pgsql-sql@postgresql.org
Subject: Re: Verifying data type
Date: Tue, 17 Aug 2004 10:48:49 -0300
Message-ID: <41220CC1.1050608@nho.com.br> (raw)

Thanks, but the number may be a float, like '1.23,00', '12.323,00', 
'12,34'.... :(
The regex works fine if it just an integer...

Have some regex to "compare"?

Tom Lane wrote:

>=?ISO-8859-1?Q?Elieser_Le=E3o?= <elieser@nho.com.br> 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
>
>  
>

view thread (3+ messages)

Message-ID: <41220CC1.1050608@nho.com.br>
Permalink:  ../41220CC1.1050608@nho.com.br/
Also on:    postgresql.org/message-id/41220CC1.1050608@nho.com.br

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: elieser@nho.com.br
  Subject: Re: Verifying data type
  In-Reply-To: <41220CC1.1050608@nho.com.br>

* 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