Received: from mail.postgresql.org (webmail.postgresql.org [216.126.85.28]) by mail.postgresql.org (8.11.1/8.11.1) with SMTP id f0OE2Aq07674 for ; Wed, 24 Jan 2001 09:02:10 -0500 (EST) (envelope-from pgsql-general-owner@postgresql.org) Received: from news.tht.net (news.hub.org [216.126.91.242]) by mail.postgresql.org (8.11.1/8.11.1) with ESMTP id f0NKTW099647; Tue, 23 Jan 2001 15:29:32 -0500 (EST) (envelope-from news@news.tht.net) Received: (from news@localhost) by news.tht.net (8.11.1/8.11.1) id f0NK8Aj62095; Tue, 23 Jan 2001 15:08:10 -0500 (EST) (envelope-from news) From: Keith Perry X-Newsgroups: comp.databases.postgresql.general,comp.databases.postgresql.sql Subject: Inserting and incrementing with MAX aggregate Date: Tue, 23 Jan 2001 15:01:24 -0500 Organization: Hub.Org Networking Services (http://www.hub.org) Lines: 18 Message-ID: <3A6DE314.A85DEEB0@vcsn.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Complaints-To: scrappy@hub.org X-Mailer: Mozilla 4.76 [en] (Win95; U) X-Accept-Language: en To: pgsql-general@postgresql.org.pgsql-sql@postgresql.org X-Archive-Number: 200101/1160 X-Sequence-Number: 3421 I was wondering if this statement was still supported in 7.0.x versions of pgSQL. I upgraded from a 6.x version where say: insert into events (eid,name) values (max(eid)+1,'server down'); works but not in the 7.x variants. I know that I could use the serial type for that column but in the interest not having to rewrite the code (or dump, drop and recreate the tables/data), I wanted to know if there was a more stand way to incrementing a field automatically that would be fairly portable. Any help would be appreciated. Keith Perry VCSN Inc. keith@vcsn.com http://vcsn.com