pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Christoph Haller <ch@rodos.fzk.de>
To: ho@optimasoft.com.tw
Cc: pgsql-sql@postgresql.org
Subject: Re: how to get the source table & field name of a view field
Date: Fri, 08 Nov 2002 09:22:10 +0100
Message-ID: <3DCB7431.CCEF837@rodos.fzk.de> (raw)

>
> 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




view thread (5+ messages)

Message-ID: <3DCB7431.CCEF837@rodos.fzk.de>
Permalink:  ../3DCB7431.CCEF837@rodos.fzk.de/
Also on:    postgresql.org/message-id/3DCB7431.CCEF837@rodos.fzk.de

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: ch@rodos.fzk.de, ho@optimasoft.com.tw
  Subject: Re: how to get the source table & field name of a view field
  In-Reply-To: <3DCB7431.CCEF837@rodos.fzk.de>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox