From: Richard Huxton <dev@archonet.com>
To: Bruno Wolff III <bruno@wolff.to>
Cc: Matthew Nuzum <matt@followers.net>
Cc: pgsql-sql@postgresql.org
Subject: Re: matching rows differing only by fkey,pkey
Date: Tue, 22 Jun 2004 20:47:57 +0100
Message-ID: <40D88CED.50903@archonet.com> (raw)
In-Reply-To: <20040622181649.GB20086@wolff.to>
References: <20040622172704.GA19163@wolff.to>
<200406221740.i5MHe6nb015623@ms-smtp-02.tampabay.rr.com>
<20040622181649.GB20086@wolff.to>
Bruno Wolff III wrote:
> On Tue, Jun 22, 2004 at 13:40:03 -0400,
> Matthew Nuzum <matt@followers.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
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: dev@archonet.com, bruno@wolff.to, matt@followers.net
Subject: Re: matching rows differing only by fkey,pkey
In-Reply-To: <40D88CED.50903@archonet.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