X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 7FAFDD1B503 for ; Tue, 22 Jun 2004 11:17:17 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 68515-06 for ; Tue, 22 Jun 2004 14:17:17 +0000 (GMT) Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) by svr1.postgresql.org (Postfix) with ESMTP id 4A89CD1B54D for ; Tue, 22 Jun 2004 11:17:13 -0300 (ADT) Received: from mail231.csoft.net (resin.csoft.net [63.111.22.86]) by svr4.postgresql.org (Postfix) with SMTP id 425E15AF94B for ; Tue, 22 Jun 2004 14:17:15 +0000 (GMT) Received: (qmail 29320 invoked from network); 22 Jun 2004 14:05:20 -0000 Received: from unknown (HELO chezphil.org) (63.111.27.87) by mail231.csoft.net with SMTP; 22 Jun 2004 14:05:20 -0000 Content-Disposition: inline Content-Transfer-Encoding: binary Content-Type: text/plain MIME-Version: 1.0 X-Mailer: MIME::Lite 3.01 (F2.72; A1.17; B2.21; Q2.21) From: "Phil Endecott" To: basic , pgsql-sql@postgresql.org Subject: Re: plpgsql - Insert from a record variable? Date: Tue, 22 Jun 2004 10:05:20 -0400 X-Mailer: Phil's WebMail Message-Id: <6249353@chezphil.org> In-Reply-To: <40D783EF.7020706@mozdev.org> References: <20040619060330.83941.qmail@web13901.mail.yahoo.com> <17840.1087670348@sss.pgh.pa.us> <4357626@chezphil.org> <2179249@chezphil.org> <40D783EF.7020706@mozdev.org> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200406/205 X-Sequence-Number: 18150 Phil> execute ''column_values := Phil> column_values || quote_literal(r.'' || cr.column_name || '')''; basic> FOR rec IN EXECUTE basic> ''select column_values || quote_literal(r.'' || basic> cr.column_name || '') alias column_values''; LOOP basic> column_values := rec.column_values; basic> END LOOP; I think your code will try to execute a query like this: select column_values || quote_literal(r.something) alias column_values This will fail because column_values and r are both plpgsql variables, and so are not visible to the SQL interpreter. Any other suggestions? --Phil.