Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 6B02247683F; Tue, 5 Nov 2002 08:35:25 -0500 (EST) Received: from cmnt4011.rvc.ac.uk (cmnt4011.rvc.ac.uk [195.195.217.13]) by postgresql.org (Postfix) with ESMTP id DDDD94766FB; Tue, 5 Nov 2002 08:33:48 -0500 (EST) Received: by cmnt4011.rvc.ac.uk with Internet Mail Service (5.5.2653.19) id ; Tue, 5 Nov 2002 13:33:28 -0000 Message-ID: <6BD8CE460CC6EE40B83DDFCED609F84B964D33@cmnt4008.rvc.ac.uk> From: "Rison, Stuart" To: "'pgsql-general@postgresql.org'" , "'pgsql-sql@postgresql.org'" Subject: Copying a rowtype variable. Date: Tue, 5 Nov 2002 13:33:32 -0000 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2653.19) Content-Type: text/plain; charset="iso-8859-1" X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/161 X-Sequence-Number: 32582 Hello, 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? My second question is: 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: previous_row.pid = current_row.pid; previous_row.start = current_row.start; -- and so on so forth for all current_row variables But this is inconvenient of the row has many fields and impossible if you want a flexible function which can accomodate rowtypes for which the fields are not known "a priori". Any clever workarounds? Cheers, Stuart. PS. I started using PGSQL five years ago... then I had to leave it alone for a while... I can't believe how much it's grown and developed. AMAZING, congrats to all developers. ---------------------------------------------------------------------------- -- Stuart C. G. Rison Department of Pathology and Infectious Diseases Royal Veterinary College London. United Kingdom. "That's bioinformatics... and we don't want to be doing bioinformatics, we want to do real science.", Sydney Brenner, UCL Pfizer Lecture, 8 May 2001 ---------------------------------------------------------------------------- --