Skip site navigation (1) Skip section navigation (2)

Re: Function testing if a string is a number ?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Arnaud Lesauvage <thewild(at)freesurf(dot)fr>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Function testing if a string is a number ?
Date: 2006-02-20 15:09:46
Message-ID: 26030.1140448186@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-novice
Arnaud Lesauvage <thewild(at)freesurf(dot)fr> writes:
> I am searching for a function that would return true if a string 
> is a number.
> In Access I would have written IsNumeric('mystring'), but this 
> function does not exist in postgres.

Write your own using a pattern test, for instance
	varchar ~ '^[0-9]+$'
See
http://www.postgresql.org/docs/8.1/static/functions-matching.html

			regards, tom lane

In response to

Responses

pgsql-novice by date

Next:From: Arnaud LesauvageDate: 2006-02-20 15:14:45
Subject: Re: Function testing if a string is a number ?
Previous:From: Arnaud LesauvageDate: 2006-02-20 14:14:51
Subject: Function testing if a string is a number ?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group