SELECT rep.*
  FROM (
        SELECT pkg.pkg_name, pv.pkg_version, pv.pv_id, pv.dlocked, crel.*
          FROM
               (
                SELECT rt.rtag_id, 
                       vt.vtree_id,
                       proj.proj_name, 
                       vt.vtree_name, 
                       rt.rtag_name,
                       vt.hide
                  FROM release_tags rt,
                       vtrees vt,
                       projects proj
                  WHERE rt.vtree_id = vt.vtree_id
                   AND vt.proj_id = proj.proj_id
                ) crel,
                release_content rc,
                packages pkg,
                package_versions pv
         WHERE rc.rtag_id = crel.rtag_id(+)
           AND rc.pv_id(+) = pv.pv_id
           AND pv.pkg_id = pkg.pkg_id        
           AND LOWER(pkg.pkg_name) LIKE LOWER('/*PKG_NAME*/')
		   AND NVL(LOWER(pv.v_ext),'LINK_A_NULL') LIKE NVL(LOWER('/*V_EXT*/'),'LINK_A_NULL')
        ) rep
 WHERE rep.hide = 'N' OR rep.hide IS NULL        
ORDER BY UPPER(rep.pkg_name), rep.pv_id, rep.proj_name, rep.vtree_id, rep.rtag_id 

