Re: is_numeric() or extract_numeric() functions? - Mailing list pgsql-general

From Tom Lane
Subject Re: is_numeric() or extract_numeric() functions?
Date
Msg-id 17340.1043810314@sss.pgh.pa.us
Whole thread Raw
In response to is_numeric() or extract_numeric() functions?  ("Ron St.Pierre" <rstpierre@syscor.com>)
Responses Re: is_numeric() or extract_numeric() functions?
List pgsql-general
"Ron St.Pierre" <rstpierre@syscor.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

pgsql-general by date:

Previous
From: "Christopher Kings-Lynne"
Date:
Subject: Re: stopping access to a database
Next
From: "Evan Macosko"
Date:
Subject: unsubscribe