Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 3B142475A1E; Tue, 5 Nov 2002 11:52:43 -0500 (EST) Received: from davinci.ethosmedia.com (davinci.ethosmedia.com [209.10.40.250]) by postgresql.org (Postfix) with ESMTP id 7A96247580B; Tue, 5 Nov 2002 11:52:42 -0500 (EST) Received: from [63.195.55.98] (account ) by davinci.ethosmedia.com (CommuniGate Pro WebUser 3.5.9) with HTTP id 1813013; Tue, 05 Nov 2002 08:55:27 -0800 From: "Josh Berkus" Subject: Re: [SQL] Copying a rowtype variable. To: "Rison, Stuart" , "'pgsql-general@postgresql.org'" , "'pgsql-sql@postgresql.org'" X-Mailer: CommuniGate Pro Web Mailer v.3.5.9 Date: Tue, 05 Nov 2002 08:55:27 -0800 Message-ID: In-Reply-To: <6BD8CE460CC6EE40B83DDFCED609F84B964D33@cmnt4008.rvc.ac.uk> MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/250 X-Sequence-Number: 32671 Stuart, > Just doing a bit of PL/PGSQL so my first question is: > > 1) should PL/PGSQL questions be posted to the general mailing list, > the sql > mailing list or both? The SQL list is the best place. > 2) I am looking for an elegant way of copying a rowtype variable: > > eg. > > DECLARE > current_row orf%ROWTYPE; > previous_row orf%ROWTYPE; > BEGIN > > LOOP > -- use cursors or FOR SELECT to get values into current_row > -- now try this: > > previous_row = current_row; > END LOOP; > END; > > Now, as I anticipated, this fails because a rowtype variable is a > composite > variable. One working alternative is to do: I haven't tried this. One thing I notice above is that you're using the equality operator "=" instead of the assignment operator ":=" . Usually Postgres lets you slack on this, but it would be worth trying to see whether that has an effect on the problem. Another thing to try is, instead of a simple variable assignment, SELECT current_row INTO previous_row; ... and see if that works. I'll tinker later today; there has to be a way to do it. -Josh Berkus