Joern,

This is really how transactions are supposed to work -- to maintain
database integrity, in a transaction either everything should go through
or nothing.  It would work the same way in Oracle and other databases
with transaction control.  One solution would seem be to do checking
before the insert to make sure you are not inserting duplicate keys.  Or
you could perhaps break the transaction into smaller parts and then just
ignore the errors if you don't care about them.  In any event PostgreSQL
seems to be doing what it should be doing here.

Rob

----------------------------------------------------------
Hi,

my PostgreSQL journey goes on... ;)

This does not work (sql pseudo code):

  autocommit off;
  -> ok

  insert into TABLE values (42, 'foo');
  -> Cannot insert a duplicate key into unique index pk_TABLE

  insert into TABLE values (43, 'foo');
  -> NOTICE:  current transaction is aborted, queries ignored
              until end of transaction block

How can I prevent PostgreSQL from aborting my transaction, if a simple
SQL error occured? Otherwise one can't do senseful exception handling
with PostgreSQL.

Thanks in advance,

Joern


Reply via email to