Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id F0A3F476383 for ; Thu, 7 Nov 2002 16:56:38 -0500 (EST) Received: from bob.samurai.com (bob.samurai.com [205.207.28.75]) by postgresql.org (Postfix) with ESMTP id 849534762A4 for ; Thu, 7 Nov 2002 16:56:38 -0500 (EST) Received: from tokyo.samurai.com (DU150.N224.ResNet.QueensU.CA [130.15.224.150]) by bob.samurai.com (Postfix) with ESMTP id 7614A1DC2; Thu, 7 Nov 2002 16:56:38 -0500 (EST) To: josh@agliodbs.com Cc: "Rison, Stuart" , Subject: Re: Cannot assign ROWTYPE, RECORD variables in PL/pgSQL References: <6BD8CE460CC6EE40B83DDFCED609F84B964D55@cmnt4008.rvc.ac.uk> <200211061427.16554.josh@agliodbs.com> From: Neil Conway In-Reply-To: <200211061427.16554.josh@agliodbs.com> Date: 07 Nov 2002 16:56:35 -0500 Message-ID: <87u1itcacs.fsf@mailbox.samurai.com> Lines: 39 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/29 X-Sequence-Number: 4811 Josh Berkus writes: > create or replace function rowtype_test () > returns text as ' > declare this_row candidates%rowtype; > that_row candidates%rowtype; > begin > select * into this_row > from candidates; > > that_row := this_row; > > return that_row.first_name; > > end;' > language 'plpgsql'; > ======================================= > > ... it will error out at the assignment "that_row := this_row". So we'd want a deep copy, right? > The only way to populate that_row with a copy of this_row is by re-querying > the source table. Well, you can also iterate through the fields of this_row and assign them to that_row manually -- of course, that's not much better. > While a relatively easy workaround, this behaviour is annoying and > inconsistent. It would be nice to fix in 7.3.1 or 7.4. Unless anyone sees a problem with this, I'll work on this. I definately think it's inappropriate for 7.3.1 though. Cheers, Neil -- Neil Conway || PGP Key ID: DB3C29FC