From: Scott Marlowe <scott.marlowe@gmail.com>
To: Achilleas Mantzios <achill@matrix.gatewaynet.com>
Cc: pgsql-sql@postgresql.org, "Franklin Haut" <franklin.haut@gmail.com>
Subject: Re: Update PK Violation
Date: Wed, 16 Jan 2008 10:15:48 -0600
Message-ID: <dcc563d10801160815m12db2b6ep1b398d3b019b8f1d@mail.gmail.com> (raw)
In-Reply-To: <200801161630.15623.achill@matrix.gatewaynet.com>
References: <478D1FB5.2070003@gmail.com>
<200801161630.15623.achill@matrix.gatewaynet.com>
On Jan 16, 2008 8:30 AM, Achilleas Mantzios
<achill@matrix.gatewaynet.com> wrote:
> Óôéò Tuesday 15 January 2008 23:03:49 ï/ç Franklin Haut Ýãñáøå:
> > Hi all,
> >
> > i have a problem with one update sentence sql.
> >
>
> A simple way i use:
>
> foodb=# update temp set num = num*1000 where num >= 5;
> foodb=# insert into temp values (5, 'NOT');
> foodb=# update temp set num = 1 + num/1000 where num >= 6;
That's still open to possible collisions. Another method that avoids
them is to use negative numbers. i.e.
update temp set num = -1*num where num >=5;
insert into temp values (5,'NOT';);
update temp set num = (-1*num) + 1 where num < 0;
Assuming you don't use negative numbers in your setup, works a charm.
However, this kind of activity screams "bad design"... Not that I've
never found myself right smack dab in the middle of such a thing
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: scott.marlowe@gmail.com, achill@matrix.gatewaynet.com, franklin.haut@gmail.com
Subject: Re: Update PK Violation
In-Reply-To: <dcc563d10801160815m12db2b6ep1b398d3b019b8f1d@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox