Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id DE2F54764F9 for ; Thu, 7 Nov 2002 11:35:48 -0500 (EST) Received: from beamish.nsd.ca (unknown [205.150.156.194]) by postgresql.org (Postfix) with ESMTP id 52074476D4D for ; Thu, 7 Nov 2002 11:28:41 -0500 (EST) Received: (from smap@localhost) by beamish.nsd.ca (8.9.3/8.9.3) id LAA24085; Thu, 7 Nov 2002 11:28:22 -0500 X-Authentication-Warning: beamish.nsd.ca: smap set sender to using -f Received: from reddog.nsd.ca(192.168.101.30) by beamish.nsd.ca via smap (V2.1/2.1+anti-relay+anti-spam) id xma024081; Thu, 7 Nov 02 11:28:18 -0500 Received: from nsd.ca (jllachan-linux.nsd.ca [192.168.101.148]) by reddog.nsd.ca (8.8.7/8.8.7) with ESMTP id LAA30570; Thu, 7 Nov 2002 11:27:30 -0500 Message-ID: <3DCA94C7.4EA02207@nsd.ca> Date: Thu, 07 Nov 2002 11:28:55 -0500 From: Jean-Luc Lachance X-Mailer: Mozilla 4.77 [en] (X11; U; Linux 2.4.9-31 i686) X-Accept-Language: en MIME-Version: 1.0 To: "Rison, Stuart" Cc: "''pgsql-sql@postgresql.org' '" , "'Josh Berkus '" Subject: Re: Copying a rowtype variable. References: <6BD8CE460CC6EE40B83DDFCED609F84B964D55@cmnt4008.rvc.ac.uk> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/110 X-Sequence-Number: 10252 I would personnaly like this feature (assigning a composite from another similar composite) to be added to PLPGSQL. Another nice feature would be to able to insert a composite into a table without have to name all atributes. Just my $.02 "Rison, Stuart" wrote: > > >> 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: > >> > > > > I haven't tried this. One thing I notice above is that you're using > > the equality operator "=" instead of the assignment operator ":=" . > > Usually Postgres lets you slack on this, but it would be worth trying > > to see whether that has an effect on the problem. > > > > Fair point. But "previous_row := current_row" doesn't work either. > > > Another thing to try is, instead of a simple variable assignment > > > > SELECT current_row INTO previous_row; > > > > ... and see if that works. > > Well, I had high hopes for that one... but it didn't work either! > > > I'll tinker later today; there has to be a way to do it. > > I'd definitely appreciate further suggestions, but thanks all the same for > you help. I have a feeling that you might have to write a PL function to > perform the operation... but I haven't really thought about it! > > Stuart. > > ---------------------------(end of broadcast)--------------------------- > TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org