Catching errors inside transactions

From: John Taylor <postgres(at)jtresponse(dot)co(dot)uk>
To: pgsql-novice(at)postgresql(dot)org
Subject: Catching errors inside transactions
Date: 2002-05-15 13:25:37
Message-ID: 02051514253701.01476@splash.hq.jtresponse.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice


Hi all,

I'm accessing postgres (7.1) through JDBC.

My application performs a number of UPDATEs, and INSERTs to the database.
If there are any SQL errors, I catch them and deal with them as appropriate
in my code.

However, I now want to put these inside a transaction.

This all works fine, except that if there is an error, postgress automatically
rolls back the transaction, even though I COMMIT at the end.

Is there a way I can stop the errors causing the transaction to fail, or to force
the transaction to commit ?

I don't really want to explicitly check for the existence of a record before an UPDATE/INSERT,
as errors are the exception.

Any ideas ?

Thanks
JohnT

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message gerry.smit 2002-05-15 14:31:08 Trouble with index in 7.1
Previous Message Josh Berkus 2002-05-15 02:28:46 Re: Did I install version 7.2.1?