pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Richard Huxton <dev@archonet.com>
To: Muhyiddin A.M Hayat <middink@indo.net.id>
To: pgsql-sql@postgresql.org
Subject: Re: auto_increment
Date: Sat, 20 Sep 2003 11:05:30 +0100
Message-ID: <200309201105.30370.dev@archonet.com> (raw)
In-Reply-To: <002201c37f54$29608e40$1f00a8c0@middinkcomp>
References: <001d01c37f3e$983ed3a0$2363a8c0@ckeskin>
	<002201c37f54$29608e40$1f00a8c0@middinkcomp>

On Saturday 20 September 2003 09:43, Muhyiddin A.M Hayat wrote:
> Ok, but if i do rollback, the auto_increment don't roolback.

It's not supposed to.

> How to use nextval(), currval() and setval() functions.

Something like:
  INSERT INTO my_table(nextval('my_sequence_name'),'aaa',1);
But you'll get the same problem.

What are you trying to do with the auto-increment? If you want to guarantee 
that the numbers go up in sequence and have no gaps (e.g. 1,2,3,4,5 NOT 
1,2,4,6) then you'll need to do some more work.

Think about what you want to have happen when three clients insert rows at the 
same time and one rolls back. Once you've decided what you want, ask again if 
you need some help.

-- 
  Richard Huxton
  Archonet Ltd



view thread (27+ messages)  latest in thread

Message-ID: <200309201105.30370.dev@archonet.com>
Permalink:  ../200309201105.30370.dev@archonet.com/
Also on:    postgresql.org/message-id/200309201105.30370.dev@archonet.com

 · 

reply

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: dev@archonet.com, middink@indo.net.id
  Subject: Re: auto_increment
  In-Reply-To: <200309201105.30370.dev@archonet.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