From: | David G Johnston <david(dot)g(dot)johnston(at)gmail(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: #Personal#: Reg: Multiple queries in a transaction |
Date: | 2015-02-19 08:00:28 |
Message-ID: | 1424332828934-5838540.post@n5.nabble.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
David G Johnston wrote
>
> Medhavi Mahansaria wrote
>> Hi Bill,
>>
>> Thanks!
>>
>> But savepoint concept will not work for me as desired.
>>
>> Is there any other way apart from SAVEPOINT that can be incorporated.
>>
>> I am not using a script. I am writing a c++ program.
>>
>> My problem is that I have 2 cases:
>>
>> 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.
>>
>> 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.
>>
>> Note: This is just a small example. I need a solution for an entire
>> application which follows the same concept across multiple queries.
>>
>> How can I incorporate this?
> Forgo transactions or use savepoints. Those are your tools. If you
> cannot find a way to solve your problem with those tools you either need
> to choose, or build, a different toolbox or explain your actual problem in
> greater detail so that others can see if there are solutions you are
> overlooking.
>
> Or redefine your problem.
>
> David J.
You might be able to write the code in pl/pgsql and just call it from your
application. You have a bit more options for flow control in that compared
to pure SQL.
http://www.postgresql.org/docs/9.3/static/plpgsql-control-structures.html#PLPGSQL-ERROR-TRAPPING
David J.
--
View this message in context: http://postgresql.nabble.com/Personal-Reg-Multiple-queries-in-a-transaction-tp5838427p5838540.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.
From | Date | Subject | |
---|---|---|---|
Next Message | Daniel LaMotte | 2015-02-19 09:46:28 | Re: Issue dumping schema using readonly user |
Previous Message | David G Johnston | 2015-02-19 07:56:04 | Re: #Personal#: Reg: Multiple queries in a transaction |