[postgis-users] isnumeric function

Paul Ramsey pramsey at cleverelephant.ca
Wed Jun 10 08:41:04 PDT 2009


As your link suggests, Alexandre, there is no such function, but it
can be done w/ a regex pattern, which postgresql supports.

pramsey=# CREATE FUNCTION isnumeric(text) RETURNS boolean AS 'SELECT
$1 ~ ''^[0-9]+$'' ' LANGUAGE 'sql';

pramsey=# select isnumeric('this');
 isnumeric
-----------
 f
(1 row)

pramsey=# select isnumeric('34');
 isnumeric
-----------
 t
(1 row)



On Wed, Jun 10, 2009 at 8:21 AM, Alexandre Dube<adube at mapgears.com> wrote:
> Hi,
>
>  Still searching for a solution...  Any hint ?
>
> Alexandre
>
> Alexandre Dube wrote:
>>
>> Hi,
>>
>>  I'm looking for an isnumeric() function in postgresql.  I did a quick
>> research and only found this :
>>
>> http://archives.postgresql.org/pgsql-sql/2004-04/msg00336.php
>>
>>  Is there still no such function in postgresql ?
>>
>
>
> --
> Alexandre Dubé
> Mapgears
> www.mapgears.com
>
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
>



More information about the postgis-users mailing list