Re: matching rows differing only by fkey,pkey

From: Richard Huxton <dev(at)archonet(dot)com>
To: Bruno Wolff III <bruno(at)wolff(dot)to>
Cc: Matthew Nuzum <matt(at)followers(dot)net>, pgsql-sql(at)postgresql(dot)org
Subject: Re: matching rows differing only by fkey,pkey
Date: 2004-06-22 19:47:57
Message-ID: 40D88CED.50903@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Bruno Wolff III wrote:
> On Tue, Jun 22, 2004 at 13:40:03 -0400,
> Matthew Nuzum <matt(at)followers(dot)net> wrote:
>
>> The end result is to duplicate the data for a particular record in table
>> "a" so that all of it's related data in tables "b" and "c" is duplicated.
>>Where "b" is the middle table in a many to many relationship. For example,
>>
>>- a ---- - b ---- - c ----
>> aid <--+ bid <--+ cid
>> data1 +-->aid +-->bid
>> data2 field1 info1
>> date3 field2 info2
>>
>>SELECT a.*,b.*,c.* from a,b,c where b.aid = a.aid and c.bid = b.bid;
>>
>>So, the goal is to duplicate an object that is made up of the data stored
>>across these three tables.
[snip]
> Offhand I can't think of a way to avoid using a procedural language to walk
> through the b table so that you can easily keep track of which new bid
> corresponds to which old bid. However, writing a perl script or plsql
> function to do this for you shouldn't be difficult.

Screams out plpgsql to me - it's good at automating what is basically
cut & paste of values.

--
Richard Huxton
Archonet Ltd

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message sad 2004-06-23 09:55:50 feature request ?
Previous Message Bruno Wolff III 2004-06-22 18:16:49 Re: matching rows differing only by fkey,pkey