From: | Nathan Clemons <nathan(at)windsofstorm(dot)net> |
---|---|
To: | J C Lawrence <claw(at)kanga(dot)nu> |
Cc: | <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: COMMIT after an ERROR? |
Date: | 2001-10-12 19:01:12 |
Message-ID: | Pine.LNX.4.33L2.0110121455290.28356-100000@sunrise.windsofstorm.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Fri, 12 Oct 2001, J C Lawrence wrote:
>
> Does an error during a transaction invalidate the transaction?
>
> eg
>
> BEGIN
> SomeQueryThatSucceeds
> SomeQueryThatFails
> SomeOtherQueryThatSucceeds
> COMMIT
>
> Will the transaction successfully COMMIT, or will the COMMIT fail?
>
> Translation: Do I need to monitor for error conditions during a
> transaction and manually do the ROLLBACK in those cases?
>
>
Hey JC...
What will happen is:
BEGIN WORK;
--> BEGIN
SELECT * FROM sometable;
--> (select results)
INSERT INTO sometable VALUES (blah);
--> insert fails, gives error
UPDATE sometable SET somefield=somedata WHERE somecondition=somepattern;
--> NOTICE: transaction is in error, will not continue
If you COMMIT WORK or ABORT WORK, either way it will close the transaction
which is in an errored state and automatically rollback the changes.
--Nathan
From | Date | Subject | |
---|---|---|---|
Next Message | David Link | 2001-10-12 19:03:08 | Re: Understanding explain costs |
Previous Message | Mihai Gheorghiu | 2001-10-12 18:57:08 | Error messages |