Re: catching errors in function

Поиск
Список
Период
Сортировка
От John DeSoi
Тема Re: catching errors in function
Дата
Msg-id 36747E9C-455C-4C74-A49F-46AEFB12118D@pgedit.com
обсуждение исходный текст
Ответ на catching errors in function  ("padmanabha konkodi" <konkodi221@rediffmail.com>)
Список pgsql-sql
On Oct 6, 2005, at 2:55 AM, padmanabha konkodi wrote:

> i have written function in which while executing it may throw error.
> if the error thrown i want rollback the transaction if not i want  
> commit.
>
> how can i achive this task.
>
> how can catch exception thrown in the function


The function itself cannot start or rollback a transaction (functions  
are always executed in the context of a transaction). But I think you  
can use a SAVEPOINT to accomplish your request:

http://www.postgresql.org/docs/8.0/interactive/sql-savepoint.html

And see this page on how to catch exceptions:

http://www.postgresql.org/docs/8.0/interactive/plpgsql-control- 
structures.html#PLPGSQL-ERROR-TRAPPING


John DeSoi, Ph.D.
http://pgedit.com/
Power Tools for PostgreSQL



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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Scripting GRANT on functions
Следующее
От: "Dmitri Bichko"
Дата:
Сообщение: UNION index use help