Re: how to get the source table & field name of a view field

From: Christoph Haller <ch(at)rodos(dot)fzk(dot)de>
To: ho(at)optimasoft(dot)com(dot)tw
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: how to get the source table & field name of a view field
Date: 2002-11-08 08:22:10
Message-ID: 3DCB7431.CCEF837@rodos.fzk.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Browse pgsql-sql by date

  From Date Subject
Next Message Tomasz Myrta 2002-11-08 08:44:06 Re: Alter table
Previous Message Huub 2002-11-08 07:41:28 changing numeric into int