pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Neil Conway <neilc@samurai.com>
To: josh@agliodbs.com
Cc: Rison, Stuart <srison@rvc.ac.uk>
Cc: pgsql-bugs@postgresql.org
Subject: Re: Cannot assign ROWTYPE, RECORD variables in PL/pgSQL
Date: 07 Nov 2002 16:56:35 -0500
Message-ID: <87u1itcacs.fsf@mailbox.samurai.com> (raw)
In-Reply-To: <200211061427.16554.josh@agliodbs.com>
References: <6BD8CE460CC6EE40B83DDFCED609F84B964D55@cmnt4008.rvc.ac.uk>
	<200211061427.16554.josh@agliodbs.com>

Josh Berkus <josh@agliodbs.com> 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 <neilc@samurai.com> || PGP Key ID: DB3C29FC




view thread (4+ messages)  latest in thread

Message-ID: <87u1itcacs.fsf@mailbox.samurai.com>
Permalink:  ../87u1itcacs.fsf@mailbox.samurai.com/
Also on:    postgresql.org/message-id/87u1itcacs.fsf@mailbox.samurai.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: neilc@samurai.com, josh@agliodbs.com, srison@rvc.ac.uk, pgsql-bugs@postgresql.org
  Subject: Re: Cannot assign ROWTYPE, RECORD variables in PL/pgSQL
  In-Reply-To: <87u1itcacs.fsf@mailbox.samurai.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