SELECT *
  FROM (
  		/* Base Views collapsed */
        SELECT DISTINCT vi.view_id, vi.view_name, TO_NUMBER(NULL) AS pkg_state, TO_NUMBER(NULL) AS pv_id, NULL AS pkg_name, NULL AS pkg_version, NULL AS dlocked, NULL AS pv_description
          FROM release_content rel,
               views vi
         WHERE rel.base_view_id = vi.view_id
           AND rtag_id = :RTAG_ID
           AND rel.base_view_id NOT IN ( /*SHOW_VIEWS*/ )
        UNION
		/* Base Views expanded */
        SELECT vi.view_id, vi.view_name, rel.pkg_state, pv.pv_id, pkg.pkg_name, pv.pkg_version, pv.dlocked, pv.pv_description
          FROM release_content rel,
               packages pkg,
               package_versions pv,
               views vi
         WHERE pv.pkg_id = pkg.pkg_id
           AND rel.pv_id = pv.pv_id
           AND rel.base_view_id = vi.view_id
           AND rel.base_view_id IN ( /*SHOW_VIEWS*/ )
           AND rtag_id = :RTAG_ID
        ) ord
ORDER BY UPPER(ord.view_name), UPPER(ord.pkg_name)