Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id AC826476078 for ; Fri, 8 Nov 2002 03:22:40 -0500 (EST) Received: from fzkmail2.fzk.de (fzkmail2.fzk.de [141.52.27.52]) by postgresql.org (Postfix) with SMTP id 8CA4C476075 for ; Fri, 8 Nov 2002 03:22:39 -0500 (EST) Received: FROM resy5.fzk.de BY fzkmail2.fzk.de ; Fri Nov 08 09:22:11 2002 +0100 Received: œby rodos.fzk.de with ESMTP (8.8.6 (PHNE_17135)/8.7.1) id JAA07187; Fri, 8 Nov 2002 09:22:10 +0100 (MET) Message-ID: <3DCB7431.CCEF837@rodos.fzk.de> Date: Fri, 08 Nov 2002 09:22:10 +0100 From: Christoph Haller X-Mailer: Mozilla 4.06 [en] (X11; I; HP-UX B.10.20 9000/780) MIME-Version: 1.0 To: ho@optimasoft.com.tw Cc: pgsql-sql@postgresql.org Subject: Re: how to get the source table & field name of a view field Content-Type: text/plain; charset=iso-8859-2 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/129 X-Sequence-Number: 10271 > > 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=''; and then your function has to parse the result. Good luck. Regards, Christoph