From: "news" <x@y.com>
Newsgroups: comp.databases.oracle
References: <f99e10b9.0204040539.1ac112e8@posting.google.com>
Subject: Re: data extraction based on primary key/foreign key constraints
Lines: 40
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.50.4522.1200
X-MIMEOLE: Produced By Microsoft MimeOLE V5.50.4522.1200
Message-ID: <2e%q8.138016$u77.31597115@news02.optonline.net>
Date: Thu, 04 Apr 2002 16:31:58 GMT
NNTP-Posting-Host: 216.2.193.1
X-Trace: news02.optonline.net 1017937918 216.2.193.1 (Thu, 04 Apr 2002 11:31:58 EST)
NNTP-Posting-Date: Thu, 04 Apr 2002 11:31:58 EST
Organization: Optimum Online


I am not sure I completely understand your question, but I will give it a
shot.  I am  not sure what you mean by extract.  I am going with the
assumption that you mean query and not export. If this is the case, you are
looking at a join condition in a query.  What you would do is say the
following:

select a. value1, a.value2, b.value1, b.value2...
from primary_table a, foriegn_table b
where a.pk = b.fk;

Of course, replace primary_table with the name of your table containing the
primary key and foriegn_table with the table containing the foriegn key.
Replace pk with the actual field name of the primary key and fk with the
field name of the foriegn key.  You could easily put this into a view and
just say select * from view.  You would create the view by executing the
following code:

CREATE OR REPLACE VIEW view_name as
select a. value1, a.value2, b.value1, b.value2...
from primary_table a, foriegn_table b
where a.pk = b.fk;

This would make it seem as though your data is stored within a single data,
thus making it much simpler for querying (extracting).  I hope this answered
your question.  If not, please repost.

John

"Chris Baugh" <chrislbaugh@hotmail.com> wrote in message
news:f99e10b9.0204040539.1ac112e8@posting.google.com...
> Does anyone know a way of extracting data from tables based on primary
> key/foreign key constraints.
>
> ie. for a given table, and set of values within that table, is there a
> way of extracting data from tables linked to that table by way of
> primary key/foregin key constraints, so that any parent tables data,
> and all child tables data, for tables hierarchically linked to the
> orignal table, can be extracted.



