X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 48EB2D1C4B8 for ; Fri, 15 Aug 2003 10:30:51 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 28612-01 for ; Fri, 15 Aug 2003 07:30:43 -0300 (ADT) Received: from frmug.org (frmug-gw.frmug.org [193.56.58.252]) by svr1.postgresql.org (Postfix) with ESMTP id C3EE6D1B539 for ; Fri, 15 Aug 2003 07:30:39 -0300 (ADT) Received: from frmug.org (localhost [127.0.0.1]) by frmug.org (8.12.9/8.11.3/frmug-2.7/nospam) with ESMTP id h7FAUdXd034922 (using TLSv1/SSLv3 with cipher DHE-RSA-AES256-SHA (256 bits) verified NO); Fri, 15 Aug 2003 12:30:40 +0200 (CEST) (envelope-from pgsql-sql@phoe.frmug.org) Received: (from uucp@localhost) by frmug.org (8.12.9/8.12.9/Submit) with UUCP id h7FAUd93034921; Fri, 15 Aug 2003 12:30:39 +0200 (CEST) Received: (from elrond@localhost) by memo.frmug.org (8.11.6/8.11.6) id h7FAUQC08406; Fri, 15 Aug 2003 12:30:26 +0200 (CEST) (envelope-from pgsql-sql@phoe.frmug.org) X-Authentication-Warning: memo.frmug.org: elrond set sender to pgsql-sql@phoe.frmug.org using -f Date: Fri, 15 Aug 2003 12:30:26 +0200 From: Bertrand Petit To: cristi Cc: pgsql-sql@postgresql.org Subject: Re: sequence Message-ID: <20030815123026.A8364@memo.frmug.org> Mail-Followup-To: cristi , pgsql-sql@postgresql.org References: <006601c36310$29da3a20$7201a8c0@dmhi.ct.ro> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i In-Reply-To: <006601c36310$29da3a20$7201a8c0@dmhi.ct.ro>; from cristi@dmhi.ct.ro on Fri, Aug 15, 2003 at 12:32:36PM +0300 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200308/191 X-Sequence-Number: 14807 On Fri, Aug 15, 2003 at 12:32:36PM +0300, cristi wrote: > What is wrong here? > > insert into table_name (field_name) values (select > setval('sequence_name')-1) as currval); This should be better: INSERT INTO table_name (field_name) VALUES (nextval('sequence_name')); -- %!PS 297.6 420.9 translate 90 rotate 0 setgray gsave 0 1 1{pop 0 180 moveto 100 180 170 100 170 -10 curveto 180 -9 180 -9 190 -10 curveto 190 100 100 180 0 180 curveto fill 180 rotate}for grestore/Bookman-LightItalic findfont 240 scalefont setfont -151.536392 -63.7998886 moveto (bp)show showpage