Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 094794760CB for ; Wed, 6 Nov 2002 17:27:03 -0500 (EST) Received: from davinci.ethosmedia.com (davinci.ethosmedia.com [209.10.40.250]) by postgresql.org (Postfix) with ESMTP id 6CCEA475E71 for ; Wed, 6 Nov 2002 17:27:02 -0500 (EST) Received: from [66.219.92.2] (HELO chocolate-mousse) by davinci.ethosmedia.com (CommuniGate Pro SMTP 3.5.9) with ESMTP id 1815266; Wed, 06 Nov 2002 14:29:50 -0800 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: "Rison, Stuart" , Subject: Cannot assign ROWTYPE, RECORD variables in PL/pgSQL Date: Wed, 6 Nov 2002 14:27:16 -0800 X-Mailer: KMail [version 1.4] References: <6BD8CE460CC6EE40B83DDFCED609F84B964D55@cmnt4008.rvc.ac.uk> In-Reply-To: <6BD8CE460CC6EE40B83DDFCED609F84B964D55@cmnt4008.rvc.ac.uk> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200211061427.16554.josh@agliodbs.com> X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/24 X-Sequence-Number: 4806 Bug: Cannot assign ROWTYPE, RECORD variables in PL/pgSQL Affects: PL/pgSQL Severity: Annoyance Priority: Minor Enhancement Confirmed On: 7.3beta2, Linux Given the following function: =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D 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 :=3D this_row; return that_row.first_name; end;' language 'plpgsql'; =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D ... it will error out at the assignment "that_row :=3D this_row". For that matter, any attempt to assign the contents of two ROWTYPE or RECOR= D=20 variables directly to each other will error out: that_record :=3D this_record; SELECT this_row INTO that_row; SELECT * INTO that_row FROM this_row; The only way to populate that_row with a copy of this_row is by re-querying= =20 the source table. While a relatively easy workaround, this behaviour is= =20 annoying and inconsistent. It would be nice to fix in 7.3.1 or 7.4. Thanks for your attention. --=20 -Josh Berkus Aglio Database Solutions San Francisco