Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 569E9B5D944 for ; Fri, 27 May 2011 02:00:32 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 46315-05 for ; Fri, 27 May 2011 05:00:25 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from lo.gmane.org (lo.gmane.org [80.91.229.12]) by mail.postgresql.org (Postfix) with ESMTP id DEC34B5DBF8 for ; Fri, 27 May 2011 02:00:24 -0300 (ADT) Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1QPp9p-0000GZ-0e for pgsql-general@postgresql.org; Fri, 27 May 2011 07:00:21 +0200 Received: from ip-118-90-142-85.xdsl.xnet.co.nz ([118.90.142.85]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 27 May 2011 07:00:21 +0200 Received: from jasen by ip-118-90-142-85.xdsl.xnet.co.nz with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 27 May 2011 07:00:21 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-general@postgresql.org From: Jasen Betts Subject: Re: copy record? Date: 27 May 2011 04:45:47 GMT Organization: Dis (not Dat) Organisation Lines: 24 Message-ID: References: <482E80323A35A54498B8B70FF2B87980049413B5EB@azsmsx504.amr.corp.intel.com> <482E80323A35A54498B8B70FF2B87980049413B673@azsmsx504.amr.corp.intel.com> <4DDEC3B1.2050008@boscorama.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: ip-118-90-142-85.xdsl.xnet.co.nz X-Face: ?)Aw4rXwN5u0~$nqKj`xPz>xHCwgi^q+^?Ri*+R(&uv2=E1Q0Zk(>h!~o2ID@6{uf8s; a +M[5[U[QT7xFN%^gR"=tuJw%TXXR'Fp~W; (T"1(739R%m0Yyyv*gkGoPA.$b,D.w:z+<'"=-lVT?6 {T?=R^:W5g|E2#EhjKCa+nt":4b}dU7GYB*HBxn&Td$@f%.kl^:7X8rQWd[NTc"P"u6nkisze/Q; 8 "9Z{peQF,w)7UjV$c|RO/mQW/NMgWfr5*$-Z%u46"/00mx-,\R'fLPe.)^ User-Agent: slrn/pre1.0.0-18 (Linux) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-5 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201105/852 X-Sequence-Number: 176284 On 2011-05-26, Bosco Rama wrote: > 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; Yet another way to do the same thing: begin; create temportary table foo on commit drop as select * from maintable where primcol=123; update foo, set primcol=456; insert into maintable select * from foo; commit; -- ⚂⚃ 100% natural