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

Поиск
Список
Период
Сортировка
От Christoph Haller
Тема Re: how to get the source table & field name of a view field
Дата
Msg-id 3DCB7431.CCEF837@rodos.fzk.de
обсуждение исходный текст
Ответ на how to get the source table & field name of a view field  ("Prime Ho" <ho@optimasoft.com.tw>)
Список 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 по дате отправления:

Предыдущее
От: Huub
Дата:
Сообщение: changing numeric into int
Следующее
От: Tomasz Myrta
Дата:
Сообщение: Re: Alter table