Re: Error handling inside PL/pgSQL functions

Поиск
Список
Период
Сортировка
От Tony Caduto
Тема Re: Error handling inside PL/pgSQL functions
Дата
Msg-id 452EA3EA.3010206@amsoftwaredesign.com
обсуждение исходный текст
Ответ на Error handling inside PL/pgSQL functions  ("Germán Hüttemann Arza" <ghuttemann@gmail.com>)
Ответы Re: Error handling inside PL/pgSQL functions  (Jeff Davis <pgsql@j-davis.com>)
Список 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


В списке pgsql-general по дате отправления:

Предыдущее
От: Wei Weng
Дата:
Сообщение: Re: Question on MD5 authentication
Следующее
От: "Jim C. Nasby"
Дата:
Сообщение: Re: more anti-postgresql FUD