From: | Elieser Leão <elieser(at)nho(dot)com(dot)br> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: Verifying data type |
Date: | 2004-08-17 13:48:49 |
Message-ID: | 41220CC1.1050608@nho.com.br |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
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(at)nho(dot)com(dot)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
>
>
>
From | Date | Subject | |
---|---|---|---|
Next Message | Bruno Wolff III | 2004-08-17 14:12:29 | Re: SELECT MAX(c) FROM (SELECT ... FOR UPDATE) AS foo |
Previous Message | Kaloyan Iliev Iliev | 2004-08-17 13:16:31 | Re: Inheriting text[] field |