Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 11FB61337B61 for ; Fri, 25 Feb 2011 06:02:46 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 70090-08 for ; Fri, 25 Feb 2011 10:02:38 +0000 (UTC) X-Greylist: delayed 12:53:17.533219 by SQLgrey-1.7.6 Received: from toroondcbmts06-srv.bellnexxia.net (toroondcbmts06-srv.bellnexxia.net [207.236.237.40]) by mail.postgresql.org (Postfix) with ESMTP id F1D921337B4F for ; Fri, 25 Feb 2011 06:02:37 -0400 (AST) Received: from toip58-bus.srvr.bell.ca ([67.69.240.185]) by toroondcbmts06-srv.bellnexxia.net (InterMail vM.8.00.01.00 201-2244-105-20090324) with ESMTP id <20110224210918.KOJU27160.toroondcbmts06-srv.bellnexxia.net@toip58-bus.srvr.bell.ca> for ; Thu, 24 Feb 2011 16:09:18 -0500 Received: from toip35-bus.srvr.bell.ca ([67.69.240.36]) by toip58-bus.srvr.bell.ca with ESMTP; 24 Feb 2011 16:09:06 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AlYHAL5QZk1Fn/tO/2dsb2JhbACJcooCA4Qljwi+Hg2DC4JIBIUQhww Received: from shbkpq40-1168112462.sdsl.bell.ca (HELO vserver) ([69.159.251.78]) by toip35-bus.srvr.bell.ca with SMTP; 24 Feb 2011 16:09:05 -0500 Message-ID: <7AD8C28EFB264E22BB784F83949DF0D2@Cplus.int> From: "Jacques Lebrun" To: Subject: Problem with serial counters Date: Thu, 24 Feb 2011 16:09:04 -0500 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_000D_01CBD43D.280BB2E0" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.5931 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5994 X-Antivirus: avast! (VPS 110224-0, 24/02/2011), Outbound message X-Antivirus-Status: Clean X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.899 tagged_above=-5 required=5 tests=BAYES_00=-1.9, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001 X-Spam-Level: X-Archive-Number: 201102/121 X-Sequence-Number: 35197 This is a multi-part message in MIME format. ------=_NextPart_000_000D_01CBD43D.280BB2E0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable 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. =20 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 ------=_NextPart_000_000D_01CBD43D.280BB2E0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
When I install my application, I use a = SQL script=20 to create the different tables.
Most of my tables start with a Serial = column called=20 RowId.
In my setup script I insert a few = records into some=20 tables, providing all fields, including the RowId (1, 2, 3, = etc).
 
The problem I have is that when my user = tries to=20 insert a new record without the RowId field,
Postgres complains that it finds a = duplicate=20 key. 
I guess when I do an insert with all = the fields=20 (including the RowId), Postgres does not increment the serial=20 counter.
 
I cannot remove the RowId field from = the Insert of=20 my setup script because this setup script is also used by customers = using=20 MySQL.
 
What can I do to force PostGres to = update the=20 internat serial counter when I do an insert with a specified value for = the=20 serial?
 
 
 
Jacques Lebrun
Web Mobile=20 Inc
819-563-0133
JLebrun@cplus.org
------=_NextPart_000_000D_01CBD43D.280BB2E0--