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 6D17FD1B266 for ; Mon, 21 Jun 2004 21:56:51 -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 14378-06 for ; Tue, 22 Jun 2004 00:56:53 +0000 (GMT) Received: from neptune.lunarpages.com (neptune.lunarpages.com [216.193.194.11]) by svr1.postgresql.org (Postfix) with ESMTP id BA680D1B1EC for ; Mon, 21 Jun 2004 21:56:48 -0300 (ADT) Received: from [219.95.194.154] (helo=[10.1.1.2]) by neptune.lunarpages.com with asmtp (TLSv1:AES256-SHA:256) (Exim 4.34) id 1BcZbG-0004gg-7j; Mon, 21 Jun 2004 17:57:22 -0700 Message-ID: <40D783EF.7020706@mozdev.org> Date: Tue, 22 Jun 2004 08:57:19 +0800 From: basic User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7) Gecko/20040616 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Phil Endecott Cc: "Riccardo G. Facchini" , pgsql-sql@postgresql.org Subject: Re: plpgsql - Insert from a record variable? References: <20040619060330.83941.qmail@web13901.mail.yahoo.com> <17840.1087670348@sss.pgh.pa.us> <4357626@chezphil.org> <2179249@chezphil.org> In-Reply-To: <2179249@chezphil.org> X-Enigmail-Version: 0.84.1.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - neptune.lunarpages.com X-AntiAbuse: Original Domain - postgresql.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - mozdev.org X-Source: X-Source-Args: X-Source-Dir: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_RFCI X-Spam-Level: X-Archive-Number: 200406/200 X-Sequence-Number: 18145 Phil Endecott wrote: > !! execute ''column_values := > !! column_values || quote_literal(r.'' || cr.column_name || '')''; I'm guessing you want something like FOR rec IN EXECUTE ''select column_values || quote_literal(r.'' || cr.column_name || '') alias column_values''; LOOP column_values := rec.column_values; END LOOP; another suggestion, rather than do > if not first then > column_names := column_names || '', ''; > column_values := column_values || '', ''; > first := false; > end if; why not use two arrays and append the name/values using array_append() and use array_to_string() to join them after that? -- basic