Re: Verifying data type

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Verifying data type
Дата
Msg-id 18604.1092699055@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Verifying data type  (Elieser Leão <elieser@nho.com.br>)
Список pgsql-sql
Elieser Leão <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


В списке pgsql-sql по дате отправления:

Предыдущее
От: Elieser Leão
Дата:
Сообщение: Verifying data type
Следующее
От: Theo Galanakis
Дата:
Сообщение: Re: CROSS-TAB query help? I have read it cant be done in on