SELECT DISTINCT A.PNLGRPNAME , B.RECNAME , C.RECDESCR ,0 FROM PSPNLGROUP A , PSPNLFIELD B , PSRECDEFN C WHERE B.RECNAME <> ' ' AND B.OCCURSLEVEL = 0 AND B.PNLNAME = A.PNLNAME AND C.RECNAME = B.RECNAME AND C.RECTYPE IN (0, 1) UNION SELECT DISTINCT A.PNLGRPNAME , B.RECNAME , C.RECDESCR , OCCURSLEVEL FROM PSPNLGROUP A , PSPNLFIELD B , PSRECDEFN C WHERE B.RECNAME <> ' ' AND B.OCCURSLEVEL > 0 AND B.PNLNAME = A.PNLNAME AND C.RECNAME = B.RECNAME AND C.RECTYPE IN (0, 1) AND (B.PNLNAME = A.PNLNAME OR EXISTS ( SELECT 'X' FROM pspnlfield f WHERE b.pnlname = f.SUBpnlname AND f.pnlname = a.pnlname AND f.subpnlname <> ' ') )
|