From: | Tony Caduto <tony_caduto(at)amsoftwaredesign(dot)com> |
---|---|
To: | Germán Hüttemann Arza <ghuttemann(at)gmail(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Error handling inside PL/pgSQL functions |
Date: | 2006-10-12 20:22:02 |
Message-ID: | 452EA3EA.3010206@amsoftwaredesign.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Germán Hüttemann Arza wrote:
> I am writing triggers procedures in PL/pgSQL and I need to handle some
> errors inside the procedures.
> Specifically, I am doing a CAST(char AS integer) and I want to know
> when the char isn't a digit. How can I get do that?
>
Just off the top of my head I would say you could use a regular
expression to check if the char is numeric value.
something like this maybe:
CREATE or REPLACE FUNCTION public.isnumeric(
text)
RETURNS pg_catalog.bool AS
$BODY$
SELECT $1 ~ '^[0-9]*(.[0-9]+)?$'
$BODY$
LANGUAGE 'sql' VOLATILE;
You might have to modify the regular expression a bit as I was using it
to test for doubles not just integers.
--
Tony Caduto
AM Software Design
http://www.amsoftwaredesign.com
Home of PG Lightning Admin for Postgresql
Your best bet for Postgresql Administration
From | Date | Subject | |
---|---|---|---|
Next Message | Wei Weng | 2006-10-12 20:22:14 | Re: Question on MD5 authentication |
Previous Message | Magnus Hagander | 2006-10-12 20:21:34 | Re: List of supported 64bit OS |