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 A0CF1D1B533 for ; Fri, 12 Sep 2003 03:20:33 +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 74429-09 for ; Fri, 12 Sep 2003 00:20:23 -0300 (ADT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id 9DB0DD1B4E2 for ; Fri, 12 Sep 2003 00:20:22 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.9/8.12.9) with ESMTP id h8C3K7An006096; Thu, 11 Sep 2003 23:20:08 -0400 (EDT) To: "Richard Sydney-Smith" Cc: "Stephan Szabo" , pgsql-sql@postgresql.org Subject: Re: How do I replace select ... into commands? In-reply-to: <001d01c378d9$d8a8bfc0$df6c32d2@athlon2000> References: <20030911194512.Q47864-100000@megazone.bigpanda.com> <001d01c378d9$d8a8bfc0$df6c32d2@athlon2000> Comments: In-reply-to "Richard Sydney-Smith" message dated "Fri, 12 Sep 2003 10:59:08 +0800" Date: Thu, 11 Sep 2003 23:20:07 -0400 Message-ID: <6095.1063336807@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200309/92 X-Sequence-Number: 15070 "Richard Sydney-Smith" writes: > execute ''select max('' || seq_fld || '') into mx from '' || tbl; You can't use INTO in an EXECUTE'd select (basically because the string to be executed is not processed by plpgsql at all, merely sent down to the SQL engine, which does not know the output variable mx). The way to get results out of an executed select is to use FOR ... IN EXECUTE. Which is a kluge, but it holds the fort until someone gets around to redesigning this code. See the manual. regards, tom lane