Re: is_numeric() or extract_numeric() functions?

From: "Rod Kreisler" <rod(at)23net(dot)net>
To: "Ron St(dot)Pierre" <rstpierre(at)syscor(dot)com>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: is_numeric() or extract_numeric() functions?
Date: 2003-01-29 01:59:21
Message-ID: JNEGKNDJGBKLBDGPOPFOKEJADHAA.rod@23net.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

You forgot to escape the quotes:

CREATE OR REPLACE FUNCTION getnumber(varchar(1)) RETURNS integer AS '
BEGIN
return ($1 ~ ''[0-9]'');
END;
' LANGUAGE 'plpgsql';

> -----Original Message-----
> From: pgsql-general-owner(at)postgresql(dot)org
> [mailto:pgsql-general-owner(at)postgresql(dot)org]On Behalf Of Ron St.Pierre
> Sent: Tuesday, January 28, 2003 5:56 PM
> To: pgsql-general(at)postgresql(dot)org
> Subject: [GENERAL] is_numeric() or extract_numeric() functions?
>
>
> I can't find an is_numeric() or extract_numeric() function in postgres
> so I decided I would make my own. However, when I try to create the
> following function:
>
>
> 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 "["
>
>
> Anyone know how to fix this, or if there is an is_numeric() or
> extract_numeric() function available?
>
> Thanks
>
> --
> Ron St.Pierre
> Syscor R&D
> tel: 250-361-1681
> email: rstpierre(at)syscor(dot)com
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo(at)postgresql(dot)org
>
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2003-01-29 02:20:52 Re: 7.3 LOCK TABLE problem
Previous Message scott.marlowe 2003-01-29 01:33:37 Re: How do I unsubscribe?