Re: EXCEPTION clause not identified

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: EXCEPTION clause not identified
Дата
Msg-id 9192.1179148830@sss.pgh.pa.us
обсуждение исходный текст
Ответ на EXCEPTION clause not identified  ("Jasbinder Singh Bali" <jsbali@gmail.com>)
Список pgsql-general
"Jasbinder Singh Bali" <jsbali@gmail.com> writes:
> In one of my trigger functions, i'm trying to catch invalid ip address
> exception

> CREATE OR REPLACE FUNCTION func_client_socket()
>   RETURNS "trigger" AS
> $BODY$
>         DECLARE
>                       ip_address_present int4;
> BEGIN
>                       ip_address_present = 1;
> SELECT inet(NEW.canonical_name);
>             EXCEPTION WHEN invalid_text_representation THEN
>                     ip_address=0;
> END;
> $BODY$
>   LANGUAGE 'plpgsql' VOLATILE;

> when i run this function, it gives me the followin error

> ERROR:  syntax error at or near "EXCEPTION" at character 1343
> which is the line where I have the EXCEPTION clause.

When I run the function as given, it doesn't complain about the
EXCEPTION, but it does complain about the misspelled variable name
on the next line.  Maybe you miscounted lines?  It'd be worth your
while to update to a more recent PG version that gives better-localized
syntax error messages.  8.1 or 8.2 will say something like

ERROR:  syntax error at or near "ip_address" at character 1
QUERY:  ip_address=0
CONTEXT:  SQL statement in PL/PgSQL function "func_client_socket" near line 7
LINE 1: ip_address=0
        ^

            regards, tom lane

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

Предыдущее
От: Alban Hertroys
Дата:
Сообщение: Re: Streaming large data into postgres [WORM like applications]
Следующее
От: Paula Ta-Shma
Дата:
Сообщение: migrating a tablespace between postgres instances in shared disk environment