From: | Andrew Sullivan <ajs(at)crankycanuck(dot)ca> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: #Personal#: Reg: Multiple queries in a transaction |
Date: | 2015-02-19 11:09:04 |
Message-ID: | 20150219110904.GA9974@crankycanuck.ca |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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 has executed 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(at)crankycanuck(dot)ca
From | Date | Subject | |
---|---|---|---|
Next Message | Bill Moran | 2015-02-19 11:45:46 | Re: #Personal#: Reg: Multiple queries in a transaction |
Previous Message | Daniel LaMotte | 2015-02-19 09:46:28 | Re: Issue dumping schema using readonly user |