Extracting data from the view to retrieve the foreign key is not declared

From: nill <nillx87(at)hotmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Extracting data from the view to retrieve the foreign key is not declared
Date: 2014-03-10 17:23:42
Message-ID: 1394472222116-5795408.post@n5.nabble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Given a view, I need to extract tables, the join columns (ON) . I need to do
this analysis because of the view (agreements with the join condition and
where) I can say that there is a foreign key

Example:

CREATE OR REPLACE VIEW x_customer AS
SELECT a.asset_id, a.client_id
FROM asset_d ad, asset a ON asset_id = ad.asset_id

Result:

NAMEVIEW |TABLE1 | COLUMN1 | TABLE2 | COLUMN2
x_customer| asset_d | asset_id | asset | asset_id |
x_customer| asset | - | - | - |

OR

CREATE OR REPLACE VIEW x_customer AS
SELECT a.asset_id, a.client_id, a.org_id, a.isactive, a.created,
a.createdby, a.updated, a.updatedby, a.value, a.name, a.description,
a.ad_user_id, ( SELECT count(*) AS count
FROM asset_d ad
WHERE a.asset_id = ad.asset_id) AS deliverycount
FROM asset a
WHERE a.bpartner_id IS NOT NULL;
Result:

NAMEVIEW |TABLE1 | COLUMN1 | TABLE2 | COLUMN2
x_customer| asset_d | asset_id | asset | asset_id |

Someone can help me?
Thanks

--
View this message in context: http://postgresql.1045698.n5.nabble.com/Extracting-data-from-the-view-to-retrieve-the-foreign-key-is-not-declared-tp5795408.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message bricklen 2014-03-10 17:51:09 Re: Playing with 9.4devel - unnest
Previous Message Tim Kane 2014-03-10 17:16:45 Re: Playing with 9.4devel - unnest