Re: is_numeric() or extract_numeric() functions?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Ron St(dot)Pierre" <rstpierre(at)syscor(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: is_numeric() or extract_numeric() functions?
Date: 2003-01-29 03:18:34
Message-ID: 17340.1043810314@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Ron St.Pierre" <rstpierre(at)syscor(dot)com> writes:
> CREATE OR REPLACE FUNCTION getnumber(varchar(1)) RETURNS integer AS '
> BEGIN
> return ($1 ~ '[0-9]');
> END;
> ' LANGUAGE 'plpgsql';

> I get the following error:
> parse error at or near "["

You need to double the quotes in the function body, viz

...
return ($1 ~ ''[0-9]'');
...

Backslash-quote (\') is an alternative way.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Evan Macosko 2003-01-29 03:44:25 unsubscribe
Previous Message Christopher Kings-Lynne 2003-01-29 03:01:46 Re: stopping access to a database