pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Rison, Stuart <srison@rvc.ac.uk>
To: 'pgsql-general@postgresql.org' <pgsql-general@postgresql.org>
To: 'pgsql-sql@postgresql.org' <pgsql-sql@postgresql.org>
Subject: Copying a rowtype variable.
Date: Tue, 5 Nov 2002 13:33:32 -0000
Message-ID: <6BD8CE460CC6EE40B83DDFCED609F84B964D33@cmnt4008.rvc.ac.uk> (raw)

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
----------------------------------------------------------------------------
--



view thread (5+ messages)  latest in thread

Message-ID: <6BD8CE460CC6EE40B83DDFCED609F84B964D33@cmnt4008.rvc.ac.uk>
Permalink:  ../6BD8CE460CC6EE40B83DDFCED609F84B964D33@cmnt4008.rvc.ac.uk/
Also on:    postgresql.org/message-id/6BD8CE460CC6EE40B83DDFCED609F84B964D33@cmnt4008.rvc.ac.uk

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: srison@rvc.ac.uk, pgsql-general@postgresql.org
  Subject: Re: Copying a rowtype variable.
  In-Reply-To: <6BD8CE460CC6EE40B83DDFCED609F84B964D33@cmnt4008.rvc.ac.uk>
  References: <6BD8CE460CC6EE40B83DDFCED609F84B964D33@cmnt4008.rvc.ac.uk>

* 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