Received: from localhost (maia-4.hub.org [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id CDBAE9FB849 for ; Mon, 11 Jun 2007 22:26:03 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 72104-03 for ; Mon, 11 Jun 2007 22:25:59 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from oss4u.com (mail.oss4u.com [64.142.76.151]) by postgresql.org (Postfix) with SMTP id 926D89FB455 for ; Mon, 11 Jun 2007 22:25:59 -0300 (ADT) Received: (qmail 24649 invoked by uid 453); 12 Jun 2007 01:25:57 -0000 Received: from ibserver.oss4u.com (HELO tiburon) (192.168.1.4) by oss4u.com (qpsmtpd/0.32) with ESMTP; Mon, 11 Jun 2007 18:25:57 -0700 From: "Uwe C. Schroeder" To: pgsql-admin@postgresql.org Subject: Sequence update function? Date: Mon, 11 Jun 2007 18:25:56 -0700 User-Agent: KMail/1.9.6 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200706111825.56480.uwe@oss4u.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200706/96 X-Sequence-Number: 25764 Hi, just thought I ask before I start doing it myself: Has anyone ever written a stored procedure (or any other means) of syncing the sequence to the max # key in the corresponding tables? I'm running a simple script to update table contents between dev and production system, however the script is flawed in the way that it copied the primary key along (it's a simple pg_dump|pg-restore shellscript). It works fine because all rows that are already there just fail for PK violation. In the end I'm ending up with sequences out of sync. So i though a simple little helper that loops over the sequences (information schema), grabs the according table, does a max(key) on the table and sets the sequence to that will do nicely. Anyone written something like that? Thanks UC -- Open Source Solutions 4U, LLC 1618 Kelly St Phone: +1 707 568 3056 Santa Rosa, CA 95401 Cell: +1 650 302 2405 United States Fax: +1 707 568 6416