Re: Transaction Questions

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Transaction Questions
Дата
Msg-id 4395.1140802990@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Transaction Questions  (Richard Kut <rkut@intelerad.com>)
Ответы Re: Transaction Questions  (Richard Kut <rkut@intelerad.com>)
Список pgsql-novice
Richard Kut <rkut@intelerad.com> writes:
> BEGIN
>   INSERT
>     OR UPDATE
>   INSERT
>      OR UPDATE
> COMMIT

>     Suppose the second INSERT fails with a duplicate key,  we cannot do the
> update (or get the previous INSERT) because the ROLLBACK is mandatory.

No it isn't.  You say SAVEPOINT, then do the INSERT, then say either
RELEASE SAVEPOINT if the insert succeeded, or ROLLBACK TO SAVEPOINT
if the insert failed.  (RELEASE is actually optional here, but might
make things a bit more transparent.)  Then you go on with your
transaction.  The problem is that you are using transaction-ending
commands where you should be using savepoint-ending commands.

            regards, tom lane

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

Предыдущее
От: Richard Kut
Дата:
Сообщение: Re: Transaction Questions
Следующее
От: "Keith Worthington"
Дата:
Сообщение: Copy data from one table to another