Skip site navigation (1) Skip section navigation (2)

Re: Conditional INSERT: if not exists

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: Don Morrison <donmorrison(at)gmail(dot)com>
Cc: Franck Routier <franck(dot)routier(at)axege(dot)com>, pgsql-novice(at)postgresql(dot)org
Subject: Re: Conditional INSERT: if not exists
Date: 2006-08-23 20:57:44
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-novice
On Wed, Aug 23, 2006 at 12:48:53 -0700,
  Don Morrison <donmorrison(at)gmail(dot)com> wrote:
> My problem: if the insert fails because the value already exists, then
> this starts a rollback of my entire transaction.  The solution I'm

If you know there won't be concurrent inserts or deletes affecting the
row of interest there is a way to do this in the INSERT statement.

> transaction...I'm not sure the nested transaction is necessary...maybe
> just the savepoint. Example:

Using save points creates nested transactions, so you have that overhead by
whatever name it is called.

In response to


pgsql-novice by date

Next:From: Don MorrisonDate: 2006-08-23 21:05:55
Subject: Re: Conditional INSERT: if not exists
Previous:From: Richard Broersma JrDate: 2006-08-23 20:04:51
Subject: Re: Passing parameters to postgreSQL from MS Access 2000

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group