Re: Conditional INSERT: if not exists - Mailing list pgsql-novice

From Don Morrison
Subject Re: Conditional INSERT: if not exists
Date
Msg-id aee6519f0608231525r1cbb2918kb8bb251f300724fc@mail.gmail.com
Whole thread Raw
In response to Re: Conditional INSERT: if not exists  ("Don Morrison" <donmorrison@gmail.com>)
List pgsql-novice
> > isn't a problem.  If you need to do this in a transaction, you can
> > simply set savepoints and roll back to the savepoint if an insert fails
> > (and you expected that it could).
>
> Unfortunately, for some reason it does a rollback of the entire outer
> transaction too, not just the nested one. :(  Anybody know why?
>
> If I use stored procedures will it be easier?
>

When I try to insert a duplicate row, this generates an IntegrityError
on my unique index, which rolls back my entire transaction, when I
really want it to generate a ROLLBACK TO SAVEPOINT for the most recent
savepoint, so only that insert is ignored.  Does anyone know a
configuration trick to get it to do this, or do I have to write a
stored procedure where I explicitly call ROLLBACK TO SAVEPOINT?

pgsql-novice by date:

Previous
From: "Don Morrison"
Date:
Subject: Re: Conditional INSERT: if not exists
Next
From: "Jasbinder Bali"
Date:
Subject: Shared Objects (Dynamic loading)