From: | Glyn Astill <glynastill(at)yahoo(dot)co(dot)uk> |
---|---|
To: | Medhavi Mahansaria <medhavi(dot)mahansaria(at)tcs(dot)com>, Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com> |
Cc: | "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Reg: PL/pgSQL commit and rollback |
Date: | 2015-03-18 10:43:19 |
Message-ID: | 674773469.622453.1426675399340.JavaMail.yahoo@mail.yahoo.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
> From: Medhavi Mahansaria <medhavi(dot)mahansaria(at)tcs(dot)com>
>To: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
>Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
>Sent: Tuesday, 17 March 2015, 14:30
>Subject: Re: [GENERAL] Reg: PL/pgSQL commit and rollback
>
>
>
>Yes. I have read this document.
>
>But my issue is that even when it throws
and exception I need to rollback the changes made by that query and move
on to the next block.
>
>Is there any way to accomplish that?
>
Yes, as per the docs in the link:
"When an error is caught by an EXCEPTION clause, the local variables of the PL/pgSQL function remain as they were when the error occurred, but all changes to persistent database state within the block are rolled back."
So you do something like:
BEGIN
UPDATE .....
EXCEPTION WHEN <whatever> THEN
.. <whatever>
END;
From | Date | Subject | |
---|---|---|---|
Next Message | Tim Rowe | 2015-03-18 11:05:02 | Windows installer |
Previous Message | Luca Ferrari | 2015-03-18 07:37:30 | Re: [GENERAL] psql sqlstate return code access |