pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Josh Berkus <josh@agliodbs.com>
To: Rison, Stuart <srison@rvc.ac.uk>
To: pgsql-bugs@postgresql.org
Subject: Cannot assign ROWTYPE, RECORD variables in PL/pgSQL
Date: Wed, 6 Nov 2002 14:27:16 -0800
Message-ID: <200211061427.16554.josh@agliodbs.com> (raw)
In-Reply-To: <6BD8CE460CC6EE40B83DDFCED609F84B964D55@cmnt4008.rvc.ac.uk>
References: <6BD8CE460CC6EE40B83DDFCED609F84B964D55@cmnt4008.rvc.ac.uk>

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:
=======================================
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".

For that matter, any attempt to assign the contents of two ROWTYPE or RECORD 
variables directly to each other will error out:

that_record := 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 
the source table.   While a relatively easy workaround, this behaviour is 
annoying and inconsistent.  It would be nice to fix in 7.3.1 or 7.4.

Thanks for your attention.

-- 
-Josh Berkus
 Aglio Database Solutions
 San Francisco




view thread (4+ messages)  latest in thread

Message-ID: <200211061427.16554.josh@agliodbs.com>
Permalink:  ../200211061427.16554.josh@agliodbs.com/
Also on:    postgresql.org/message-id/200211061427.16554.josh@agliodbs.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: josh@agliodbs.com, srison@rvc.ac.uk, pgsql-bugs@postgresql.org
  Subject: Re: Cannot assign ROWTYPE, RECORD variables in PL/pgSQL
  In-Reply-To: <200211061427.16554.josh@agliodbs.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox