COGNOiSe.com - The IBM Cognos Community

IBM Cognos Analytics Platform => Cognos Analytics => Administration and Security => Topic started by: CraigFSindorf on 13 Sep 2022 04:04:28 PM

Title: List of all Packages and the path to the package
Post by: CraigFSindorf on 13 Sep 2022 04:04:28 PM
I found this to list all packages:
SELECT cmobjnames.cmid,
cmstoreids.storeid,
cmobjects.pcmid,
cmobjnames.name,
cmobjnames.mapdlocaleid,
cmobjnames.localeid,
cmlocales.locale,
cmclasses.name as type
FROM cmobjects, cmobjnames, cmclasses, cmstoreids, cmlocales
WHERE
cmobjects.cmid = cmobjnames.cmid
AND cmobjects.classid = cmclasses.classid
AND cmobjects.cmid = cmstoreids.cmid
AND cmclasses.name ='package'
AND cmobjnames.localeid = cmlocales.localeid and cmlocales.locale in ('en')
order by name

what would i alter to get the path to the packages?
Title: Re: List of all Packages and the path to the package
Post by: dougp on 13 Sep 2022 08:19:36 PM
All of it.

You'll need a recursive common table expression.

This site doesn't like code.  Good luck.
Title: Re: List of all Packages and the path to the package
Post by: Spyhop on 23 Nov 2022 03:26:07 PM
I created a function to get the path info and called it in the query showed

CREATE OR REPLACE FUNCTION getpath(p_pcmid IN NUMBER) RETURN NVARCHAR2 IS
    l_parentname NVARCHAR2(100);
    l_pcmid      NUMBER;
BEGIN
    IF p_pcmid = 0 THEN
        RETURN 'root';
    ELSE
        SELECT n.name object_name
              ,o.pcmid
        INTO   l_parentname
              ,l_pcmid
        FROM   rnr_tbls.cmobjnames n
              ,rnr_tbls.cmobjects  o
        WHERE  o.cmid = n.cmid
        AND    o.cmid = p_pcmid
        AND    isdefault = 1;
    END IF;
    RETURN getpath(l_pcmid) || '\' || l_parentname;
EXCEPTION
    WHEN OTHERS THEN
        RETURN SQLERRM;
END getpath;
Title: Re: List of all Packages and the path to the package
Post by: dougp on 29 Nov 2022 01:16:20 PM
Since I'm currently working with this...

https://pastebin.com/zPn7rmje