Re: Determine if a string is digit - Mailing list pgsql-general

From Manuel Sugawara
Subject Re: Determine if a string is digit
Date
Msg-id m33ccrnclr.fsf@conexa.fciencias.unam.mx
Whole thread Raw
In response to Determine if a string is digit  (Josué Maldonado <josue@lamundial.hn>)
Responses Re: Determine if a string is digit
List pgsql-general
Josué Maldonado <josue@lamundial.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.

pgsql-general by date:

Previous
From: Josué Maldonado
Date:
Subject: Determine if a string is digit
Next
From: Josué Maldonado
Date:
Subject: Re: Determine if a string is digit