Search Postgresql Archives

Re: #Personal#: Reg: Multiple queries in a transaction

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxx


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




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux