Re: Determine if a string is digit

From: Manuel Sugawara <masm(at)fciencias(dot)unam(dot)mx>
To: Josué Maldonado <josue(at)lamundial(dot)hn>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Determine if a string is digit
Date: 2003-11-13 22:10:56
Message-ID: m33ccrnclr.fsf@conexa.fciencias.unam.mx
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Josué Maldonado <josue(at)lamundial(dot)hn> writes:

> Hello list,
>
> That's my question, I can't figure out a way to know if a given string is
> digit, soemthing like this:
>
>
> ISDIGIT("ARWA") = False
> ISDIGIT("5334") = True
>
> If anyone know a way to get that done, I'll appreciate the help.

create function isdigit(text) returns boolean as '
select $1 ~ ''^(-)?[0-9]+$'' as result
' language sql;

masm=# select isdigit('ARWA');
isdigit
---------
f
(1 row)

masm=# select isdigit('5334');
isdigit
---------
t
(1 row)

Regards,
Manuel.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Josué Maldonado 2003-11-13 22:19:26 Re: Determine if a string is digit
Previous Message Josué Maldonado 2003-11-13 21:57:42 Determine if a string is digit