Re: is_numeric() or extract_numeric() functions?

From: "Ron St(dot)Pierre" <rstpierre(at)syscor(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: is_numeric() or extract_numeric() functions?
Date: 2003-01-29 18:19:09
Message-ID: xWUZ9.142239$H7.5829077@news2.calgary.shaw.ca
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Thanks everyone, that worked and I now have a new plpgsql function to
extract numbers from a string. I placed it in the PL/pgSQL CookBook
(linked from the Users Lounge on the postgres home page ->
http://www.brasileiro.net:8080/postgres/cookbook/) if anyone wants it.

Tom Lane wrote:

>"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
>
>---------------------------(end of broadcast)---------------------------
>TIP 1: subscribe and unsubscribe commands go to majordomo(at)postgresql(dot)org
>
>

--
Ron St.Pierre
Syscor R&D
tel: 250-361-1681
email: rstpierre(at)syscor(dot)com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Neil Conway 2003-01-29 18:22:06 Re: psql command line question..
Previous Message Neil Conway 2003-01-29 18:16:09 Re: Ref to last INSERT on a table without OIDs?