Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 216C7B5DC09 for ; Thu, 26 May 2011 18:19:16 -0300 (ADT) 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 61628-03 for ; Thu, 26 May 2011 21:19:04 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from tempest.mainecoon.com (tempest.mainecoon.com [69.12.217.123]) by mail.postgresql.org (Postfix) with ESMTP id 658B0B5DD02 for ; Thu, 26 May 2011 18:18:42 -0300 (ADT) Received: from [10.1.1.2] (fw.boscorama.com [75.101.8.88]) by tempest.mainecoon.com (Postfix) with ESMTPSA id C5F856EA0A3; Thu, 26 May 2011 14:18:41 -0700 (PDT) Message-ID: <4DDEC3B1.2050008@boscorama.com> Date: Thu, 26 May 2011 14:18:41 -0700 From: Bosco Rama User-Agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); en-US; rv:1.9.1.19) Gecko/20110420 SeaMonkey/2.0.14 Like Firefox/3.6 MIME-Version: 1.0 To: "Gauthier, Dave" CC: "pgsql-general@postgresql.org" Subject: Re: copy record? References: <482E80323A35A54498B8B70FF2B87980049413B5EB@azsmsx504.amr.corp.intel.com> <482E80323A35A54498B8B70FF2B87980049413B673@azsmsx504.amr.corp.intel.com> In-Reply-To: <482E80323A35A54498B8B70FF2B87980049413B673@azsmsx504.amr.corp.intel.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-5 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201105/842 X-Sequence-Number: 176274 Gauthier, Dave wrote: > Well, I found a better way, but still open to suggestions. > > This is what I have so far... > > create temporary table foo as select * from maintable where 1-0; -- Credit 4 this goes to a post in the PG archives > insert into foo (select * from maintable where primcol=123); > update foo, set primcol=456; > insert into maintable (select * from foo); This alleviates the need to trick the back-end using 'where 1-0' and also does the insert, all in one go. select * into temp table foo from maintable where primcol=123; update foo set primcol = 456; insert into maintable select * from foo; You also may need this is if you intend to use the same sequence of calls on within the same session: drop table foo; HTH Bosco.