Re: how to get the source table & field name of a view field - Mailing list pgsql-sql

From Christoph Haller
Subject Re: how to get the source table & field name of a view field
Date
Msg-id 3DCB7431.CCEF837@rodos.fzk.de
Whole thread Raw
In response to how to get the source table & field name of a view field  ("Prime Ho" <ho@optimasoft.com.tw>)
List pgsql-sql
>
> if I want to write a function for getting the view.field's source
> table.field
> how could I achieve it?
>
This sounds like a real challange.
Throughout the years I've had to learn it's always a pain to
retrieve system catalog information - no matter which
DBMS is in use.
On the other hand, you have to face the fact that
view.field's sources are not necessarily directly derived
from a table.field.
A view.field's source may be any expression including aggregates.

So, the only way I can think of achieving that is

SELECT definition from pg_views where viewname='<your view name>';

and then your function has to parse the result. Good luck.

Regards, Christoph



pgsql-sql by date:

Previous
From: Huub
Date:
Subject: changing numeric into int
Next
From: Tomasz Myrta
Date:
Subject: Re: Alter table