SQL Query

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

select r.rule_id, r.

display_rule_name RULE, decode(ALWAYS_APPLY_FLAG,'Y','Always


apply', r.conditions_string) CONDITION,
( select LISTAGG( decode(action_code,'AUTOMATIC', decode(SET_OUTCOME_TO_CODE,
'APPROVED','Auto Approve','Auto Reject'),ac.MEANING)||' '||
decode(action_code,'AUTOMATIC',null, ro.MEANING )||' '||
decode(action_code,'AUTOMATIC',null,
decode(a.ROUTE_USING_CODE, 'APPROVAL_GROUP',''''||
a.APPROVAL_GROUP_NAME||'''',
'SUPERVISORY_HIERARCHY','Chain of '||
decode(a.SUP_CHAIN_OF_CODE,'WORKER',n1.list_name,ch.MEANING)||' Start with '||
decode(a.START_WITH_CODE,'WORKER',n1.list_name,st.MEANING||st1.MEANING)||' level
'||a.NUMBER_OF_APPROVAL_LEVELS,
'JOB_LEVEL','Chain of '||
decode(a.SUP_CHAIN_OF_CODE,'WORKER',n1.list_name,ch.MEANING)||' Start with '||
decode(a.START_WITH_CODE,'WORKER',n1.list_name,st.MEANING||st1.MEANING)||' level
'||a.MINIMUM_JOB_LEVEL||' Include '||inc.MEANING,
'POSITION_HIERARCHY','Tree '|| TRL.TREE_NAME||' Chain of '||
decode(pos.MEANING,null,pos1.MEANING,pos.MEANING)||' Start with '||
decode(pos2.MEANING,null,pos3.MEANING,pos2.MEANING)||' level '||
a.MINIMUM_JOB_LEVEL||' Include '||inc.MEANING,

'SINGLE_APPROVER',decode(a.user_type_code,'WORKER',n1.list_name,sin.MEANING),
null))
, ' And ')
WITHIN GROUP (ORDER BY ACTION_NUMBER) from fusion.por_amx_actions a,
fusion.fnd_lookups ac, fusion.por_amx_tasks t, fusion.fnd_lookups ro,
fusion.fnd_lookups ch, fusion.fnd_lookups st, fusion.fnd_lookups st1,
fusion.per_person_names_f n1, fusion.fnd_lookups inc,
fusion.fnd_lookups pos, fusion.fnd_lookups pos1, fusion.fnd_lookups pos2,
fusion.fnd_lookups pos3, fusion.fnd_lookups sin,
fusion.FND_TREE_TL TRL, fusion.FND_TREE TRB
where a.task_id=t.task_id and a.action_code=ac.lookup_code (+) and ac.lookup_type
(+)='POR_AMX_ACTION'
and t.ROUTE_TO_LOOKUP=ro.lookup_type (+) and ro.lookup_code (+) =a.ROUTE_USING_CODE
and t.SUP_CHAIN_OF_LOOKUP = ch.lookup_type (+) and ch.lookup_code
(+)=a.SUP_CHAIN_OF_CODE
and st.lookup_type (+) ='POR_AMX_START_WITH' and st.lookup_code
(+)=a.START_WITH_CODE
and st1.lookup_type (+) = t.SUP_CHAIN_OF_LOOKUP and st1.lookup_code
(+)=a.START_WITH_CODE
and a.POSITION_CHAIN_OF_CODE = pos.lookup_code (+) and pos.lookup_type
(+)='POR_AMX_CHAIN_OF'
and a.POSITION_CHAIN_OF_CODE = pos1.lookup_code (+) and pos1.lookup_type
(+)='PO_AMX_CHAIN_OF'
and a.POSITION_START_WITH_CODE = pos2.lookup_code (+) and pos2.lookup_type (+)
='POR_AMX_START_WITH'
and a.POSITION_START_WITH_CODE = pos3.lookup_code (+) and pos3.lookup_type
(+)='POR_AMX_CHAIN_OF'
and t.SINGLE_APPROVER_LOOKUP = sin.lookup_type (+) and a.user_type_code =
sin.lookup_code (+)
and TRB.TREE_STRUCTURE_CODE (+) = 'PER_POS_TREE_STRUCTURE' AND TRB.TREE_CODE (+)=
TRL.TREE_CODE
and trl.tree_code (+) =a.position_hierarchy and TRL.LANGUAGE (+)= USERENV('LANG')
and a.worker_id= n1.person_id (+) and n1.name_type (+) ='GLOBAL'
and inc.lookup_type (+)='POR_AMX_INCLUDE' and inc.lookup_code (+)=a.include_code
and a.sandbox_flag='Y' and a.rule_id=r.rule_id ) ACTION,r.ACTIVE_FLAG ISACTIVE,
tl.meaning TASK,sl.meaning STAGE, pl.meaning PARTICIPANT
from fusion.por_amx_rules r, fusion.por_amx_tasks t,fusion.fnd_lookups tl,
fusion.por_amx_participants p,
fusion.fnd_lookups pl, fusion.por_amx_stages s, fusion.fnd_lookups sl
where r.sandbox_flag='Y' and r.task_id=t.task_id and tl.lookup_type=t.task_lookup
and tl.lookup_code=t.lookup_code and
r.participant_id=p.participant_id and t.participant_lookup=pl.lookup_type and
pl.lookup_code=p.lookup_code and s.stage_id=p.stage_id
and t.stage_lookup=sl.lookup_type and s.lookup_code=sl.lookup_code
and t.task_key=:bindTaskKey order by s.stage_id, p.participant_id desc

You might also like