Re: #Personal#: Reg: Multiple queries in a transaction
| От | Andrew Sullivan |
|---|---|
| Тема | Re: #Personal#: Reg: Multiple queries in a transaction |
| Дата | |
| Msg-id | 20150219110904.GA9974@crankycanuck.ca обсуждение исходный текст |
| Ответ на | Re: #Personal#: Reg: Multiple queries in a transaction (Medhavi Mahansaria <medhavi.mahansaria@tcs.com>) |
| Список | pgsql-general |
On Thu, Feb 19, 2015 at 11:11:59AM +0530, Medhavi Mahansaria wrote:
>
> But savepoint concept will not work for me as desired.
I don't see why not.
>
> Case 1: When Q2 fails (we delete the error), i want to continue to Q3 and commit changes done by Q1 and Q3 once Q3
hasexecuted successfully.
>
So,
Q1;
SAVEPOINT foo;
Q2;
if error then
ROLLBACK TO SAVEPOINT FOO;
Q3;
COMMIT or ROLLBACK;
else
COMMIT;
> Case 2: When Q2 fails, I want it to throw an error. and rollback the changes made by Q1 and not proceed to Q3 at all.
>
Q1;
SAVEPOINT foo;
Q2;
if error then
ROLLBACK;
These both work. The problem is, I think, that you have different
rules for "when Q2 fails", and without knowing your exact
circumstances I suspect we can't say much more. Indeed, however, it
sounds to me like you think these are in the same workflow, but
they're not.
A
--
Andrew Sullivan
ajs@crankycanuck.ca
В списке pgsql-general по дате отправления: