Sie sind auf Seite 1von 2

select distinct

t.menu_id,
t.menu_title,
t.menu_type,
t.menu_parent,
t.program_name,
t.order_level
from
tree2 t
where t.menu_parent = p_menu_parent
and t.enabled_flag = 'Y'
and not exists (select 1 from e_menu_params p where t.menu_id =
p.menu_id and p.param_name = 'PROCESS_ID')
and t.user_id = :parameter.user_id
union
select distinct
t.menu_id,
t.menu_title,
t.menu_type,
t.menu_parent,
t.program_name,
t.order_level
from
tree2 t
where t.menu_parent = p_menu_parent
and t.enabled_flag = 'Y'
and not exists (select 1 from e_menu_params p where t.menu_id =
p.menu_id and p.param_name = 'PROCESS_ID')
and t.user_id in (
select /*+ INDEX(dl ED_EU_FK_I) */
dl.user_id
from e_delegations dl
where dl.user_id_delegate_to = :parameter.user_id
and trunc(sysdate) between dl.start_date and dl.end_date)

union
select /*+ INDEX(SYS_MENU_ITEMS SMI_INDX_1) */ distinct
t.menu_id,
t.menu_title,
t.menu_type,
t.menu_parent,
t.program_name,
t.order_level
from
tree2 t,
e_menu_params p,
e_users u
where 1=1
and t.menu_id+0 = p.menu_id
and p.param_name = 'PROCESS_ID'
and u.user_id = t.user_id
and t.menu_parent = p_menu_parent
and t.enabled_flag||'' = 'Y'
and (
exists (select 1 from e_process_launchers a where a.process_id =
p.default_value and a.all_flag = 'Y' ) or
exists (select 1 from e_process_launchers a where a.process_id =
p.default_value and a.user_id = u.user_id ) or
exists (select 1 from e_process_launchers a where a.process_id =
p.default_value and a.dept_id = u.dept_id and a.desig_id is null ) or
exists (select 1 from e_process_launchers a where a.process_id =
p.default_value and a.dept_id is null and a.desig_id = u.desig_id ) or
exists (select 1 from e_process_launchers a where a.process_id =
p.default_value and a.dept_id = u.dept_id and a.desig_id = u.desig_id)
)
and u.user_id = :parameter.user_id
union
select /*+ INDEX(SYS_MENU_ITEMS SMI_INDX_1) */ distinct
t.menu_id,
t.menu_title,
t.menu_type,
t.menu_parent,
t.program_name,
t.order_level
from
tree2 t,
e_menu_params p,
e_users u
where 1=1
and t.menu_id+0 = p.menu_id
and p.param_name = 'PROCESS_ID'
and u.user_id = t.user_id
and t.menu_parent = p_menu_parent
and t.enabled_flag||'' = 'Y'
and (
exists (select 1 from e_process_launchers a where a.process_id =
p.default_value and a.all_flag = 'Y' ) or
exists (select 1 from e_process_launchers a where a.process_id =
p.default_value and a.user_id = u.user_id ) or
exists (select 1 from e_process_launchers a where a.process_id =
p.default_value and a.dept_id = u.dept_id and a.desig_id is null ) or
exists (select 1 from e_process_launchers a where a.process_id =
p.default_value and a.dept_id is null and a.desig_id = u.desig_id ) or
exists (select 1 from e_process_launchers a where a.process_id =
p.default_value and a.dept_id = u.dept_id and a.desig_id = u.desig_id)
)
and u.user_id in (
select /*+ INDEX(dl ED_EU_FK_I) */ dl.user_id
from e_delegations dl
where dl.user_id_delegate_to = :parameter.user_id
and trunc(sysdate) between dl.start_date and dl.end_date)

order by 6, 2;