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