Received: from uno.tksoft.com (uno.tksoft.com [206.117.169.102]) by hub.org (8.9.3/8.9.3) with ESMTP id PAA67348 for ; Tue, 20 Jul 1999 15:01:45 -0400 (EDT) (envelope-from tk@uno.tksoft.com) Received: (from tk@localhost) by uno.tksoft.com (8.8.8/8.8.8) id MAA02467; Tue, 20 Jul 1999 12:01:35 -0700 From: "tjk@tksoft.com" Message-Id: <199907201901.MAA02467@uno.tksoft.com> Subject: Re: [SQL] Can I prevent my sequence to increment if an insert is rejected? To: frederic.de.leersnijder@pandora.be (Frederic De Leersnijder) Date: Tue, 20 Jul 1999 12:01:34 -0700 (PDT) Cc: pgsql-sql@hub.org In-Reply-To: <3794A9B3.C323DC4A@pandora.be> from "Frederic De Leersnijder" at Jul 20, 99 06:54:11 pm Content-Type: text Frederic, You could (a) do the work inside a transaction, or (b) do the insert after you have retrieved the key and verified it doesn't exist in the table. I.e. get the nextval from the sequence first and then do the insert. P.S. If a record was inserted with a used key, wouldn't you want to skip that sequence value anyway? Troy Troy Korjuslommi Tksoft OY, Inc. tjk@tksoft.com Software Development Open Source Solutions Hosting Services > > Hi, > > when I try to insert a record and it curses with fields with a unique > key on them my sequence I use for my primary key does increment. How can > I prevent this from happening? > > > Thanks > Frederic > >