pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jacques Lebrun <jlebrun@cplus.org>
To: pgsql-sql@postgresql.org
Subject: Problem with serial counters
Date: Thu, 24 Feb 2011 16:09:04 -0500
Message-ID: <7AD8C28EFB264E22BB784F83949DF0D2@Cplus.int> (raw)

When I install my application, I use a SQL script to create the different tables.
Most of my tables start with a Serial column called RowId.
In my setup script I insert a few records into some tables, providing all fields, including the RowId (1, 2, 3, etc).

The problem I have is that when my user tries to insert a new record without the RowId field,
Postgres complains that it finds a duplicate key.  
I guess when I do an insert with all the fields (including the RowId), Postgres does not increment the serial counter.

I cannot remove the RowId field from the Insert of my setup script because this setup script is also used by customers using MySQL.

What can I do to force PostGres to update the internat serial counter when I do an insert with a specified value for the serial?



Jacques Lebrun
Web Mobile Inc
819-563-0133
JLebrun@cplus.org

view thread (3+ messages)  latest in thread

Message-ID: <7AD8C28EFB264E22BB784F83949DF0D2@Cplus.int>
Permalink:  ../7AD8C28EFB264E22BB784F83949DF0D2@Cplus.int/
Also on:    postgresql.org/message-id/7AD8C28EFB264E22BB784F83949DF0D2@Cplus.int

 · 

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: jlebrun@cplus.org
  Subject: Re: Problem with serial counters
  In-Reply-To: <7AD8C28EFB264E22BB784F83949DF0D2@Cplus.int>

* 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