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
a...@crankycanuck.ca


-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Reply via email to