Re: Reg: PL/pgSQL commit and rollback

Поиск
Список
Период
Сортировка
От Adrian Klaver
Тема Re: Reg: PL/pgSQL commit and rollback
Дата
Msg-id 55083F8C.5050802@aklaver.com
обсуждение исходный текст
Ответ на Re: Reg: PL/pgSQL commit and rollback  (Medhavi Mahansaria <medhavi.mahansaria@tcs.com>)
Список pgsql-general
On 03/17/2015 07:30 AM, Medhavi Mahansaria wrote:
> 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?

"If no error occurs, this form of block simply executes all the
statements, and then control passes to the next statement after END. But
if an error occurs within the statements, further processing of the
statements is abandoned, and control passes to the EXCEPTION list. The
list is searched for the first condition matching the error that
occurred. If a match is found, the corresponding handler_statements are
executed, and then control passes to the next statement after END. If no
match is found, the error propagates out as though the EXCEPTION clause
were not there at all: the error can be caught by an enclosing block
with EXCEPTION, or if there is none it aborts processing of the function.

I have not looked at your original function in depth, but I am pretty
sure all you have to do is remove the COMMIT and ROLLBACK lines to get
what you want. There are also the RAISE_APPLICATION_ERROR lines to deal
with. Take a look at:

http://www.postgresql.org/docs/9.3/interactive/plpgsql-errors-and-messages.html

Also might want to look at:

http://www.postgresql.org/docs/9.3/interactive/plpgsql-porting.html
--
Adrian Klaver
adrian.klaver@aklaver.com


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

Предыдущее
От: Alban Hertroys
Дата:
Сообщение: Re: Reg: PL/pgSQL commit and rollback
Следующее
От: Israel Brewster
Дата:
Сообщение: Re: Group by range in hour of day