Search Postgresql Archives

Re: which view is used another views

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Guys

The query in this function returns the dependency for level one. However, I need the dependency for all level. I am still new with plpgsql so; how can I use recursive function to return all dependency for all levels

CREATE OR REPLACE FUNCTION dependon (var text) RETURNS SETOF text AS
$BODY$
DECLARE
    node record;
BEGIN

    FOR node IN SELECT relname FROM pg_class WHERE OID in (
        SELECT ev_class FROM pg_rewrite, pg_depend
        WHERE pg_depend.objid = pg_rewrite.oid
        AND deptype ='n'
        AND refobjsubid = 1
        AND refobjid::regclass::text = $1)
    LOOP
        IF node.relname IS NOT NULL THEN
               
            RETURN NEXT depend(node.relname);   
            RETURN NEXT node.relname;
           
        END IF;
       
    END LOOP;
END
$BODY$
LANGUAGE 'plpgsql';


Regards


From: Raymond O'Donnell <rod@xxxxxx>
To: salah jubeh <s_jubeh@xxxxxxxxx>
Cc: pgsql <pgsql-general@xxxxxxxxxxxxxx>
Sent: Thu, March 24, 2011 6:18:16 PM
Subject: Re: which view is used another views

On 24/03/2011 16:06, salah jubeh wrote:
> Hello,
>
> How can I determine the views which are using a certain view.

If you're using pgAdmin, there's a "Dependants" tab which shows you the objects depending on another object.

Otherwise, I think you can query the pg_catalog.pg_depend table, but I don't know how you go about that.

Ray.

-- Raymond O'Donnell :: Galway :: Ireland
rod@xxxxxx

-- Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux