From: | John DeSoi <desoi(at)pgedit(dot)com> |
---|---|
To: | "padmanabha konkodi" <konkodi221(at)rediffmail(dot)com> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: catching errors in function |
Date: | 2005-10-06 13:51:24 |
Message-ID: | 36747E9C-455C-4C74-A49F-46AEFB12118D@pgedit.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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
From | Date | Subject | |
---|---|---|---|
Next Message | Dmitri Bichko | 2005-10-06 15:59:51 | UNION index use help |
Previous Message | Tom Lane | 2005-10-06 13:33:09 | Re: Scripting GRANT on functions |