--Workflow Item Type And Workflow Item Key Wise Approval History Find SQL
SELECT ROWNUM h_sequence, h_notification_id, h_from_role, h_from_user,
h_to_role, h_to_user, h_action, h_comment, h_action_date,
activity_status, activity_result_code,item_type,item_key
FROM (SELECT h_notification_id, h_from_role, h_from_user, h_to_role,
h_to_user, h_action, h_comment, h_action_date,
activity_status, activity_result_code,item_type,item_key
FROM (SELECT 99999999 h_sequence,
ias.notification_id h_notification_id,
ias.assigned_user h_from_role,
wf_directory.getroledisplayname2
(ias.assigned_user)
h_from_user,
'WF_SYSTEM' h_to_role,
wf_core.TRANSLATE ('WF_SYSTEM') h_to_user,
wf_core.activity_result
(a.result_type,
ias.activity_result_code
) h_action,
(SELECT text_value
FROM wf_notification_attributes
WHERE notification_id =
ias.notification_id
AND NAME = 'WF_NOTE') h_comment,
NVL (to_char(ias.end_date,'DD-MON-YYYY'), to_char(ias.begin_date,'DD-MON-YYYY')) h_action_date,
ias.activity_status, ias.activity_result_code,ias.item_type,ias.item_key
FROM wf_item_activity_statuses ias,
wf_activities a,
wf_process_activities pa,
wf_items i
WHERE ias.item_type LIKE '%'||:P_ITEM_TYPE||'%'-- 'XXSUPREQ'--'XXMPRFWF' --item_type
AND ias.item_key LIKE '%'||:P_ITEM_KEY||'%' --:1--tem_key
--AND ias.process_activity = :process_activity
AND ias.notification_id IS NOT NULL --added
AND ias.item_type = i.item_type
AND ias.item_key = i.item_key
AND ias.activity_result_code IS NOT NULL
AND ias.activity_result_code NOT IN
('#EXCEPTION',
'#FORCE',
'#MAIL',
'#NULL',
'#STUCK',
'#TIMEOUT'
)
AND i.begin_date BETWEEN a.begin_date
AND NVL (a.end_date, i.begin_date)
AND ias.process_activity = pa.instance_id
AND pa.activity_name = a.NAME
AND pa.activity_item_type = a.item_type
UNION ALL
SELECT 99999999 h_sequence,
ias.notification_id h_notification_id,
ias.assigned_user h_from_role,
wf_directory.getroledisplayname2
(ias.assigned_user)
h_from_user,
'WF_SYSTEM' h_to_role,
wf_core.TRANSLATE ('WF_SYSTEM') h_to_user,
wf_core.activity_result
(a.result_type,
ias.activity_result_code
) h_action,
(SELECT text_value
FROM wf_notification_attributes
WHERE notification_id =
ias.notification_id
AND NAME = 'WF_NOTE') h_comment,
NVL (to_char(ias.end_date,'DD-MON-YYYY'), to_char(ias.begin_date,'DD-MON-YYYY')) h_action_date,
ias.activity_status, ias.activity_result_code,ias.item_type,ias.item_key
FROM wf_item_activity_statuses_h ias,
wf_activities a,
wf_process_activities pa,
wf_items i
WHERE ias.item_type like '%'||:P_ITEM_TYPE||'%'--'XXSUPREQ'--'XXMPRFWF' --item_type
AND ias.item_key LIKE '%'||:P_ITEM_KEY||'%' --:1 --item_key
--AND ias.process_activity = :process_activity
AND ias.notification_id IS NOT NULL --added
AND ias.item_type = i.item_type
AND ias.item_key = i.item_key
AND ias.activity_result_code IS NOT NULL
AND ias.activity_result_code NOT IN
('#EXCEPTION',
'#FORCE',
'#MAIL',
'#NULL',
'#STUCK',
'#TIMEOUT'
)
AND i.begin_date BETWEEN a.begin_date
AND NVL (a.end_date, i.begin_date)
AND ias.process_activity = pa.instance_id
AND pa.activity_name = a.NAME
AND pa.activity_item_type = a.item_type
UNION ALL
SELECT c.SEQUENCE h_sequence,
c.notification_id h_notification_id,
c.from_role h_from_role, c.from_user h_from_user,
c.to_role h_to_role, c.to_user h_to_user,
wf_core.TRANSLATE (c.action) h_action,
c.user_comment h_comment,
to_char(c.comment_date,'DD-MON-YYYY') h_action_date, ias.activity_status,
ias.activity_result_code,ias.item_type,ias.item_key
FROM wf_item_activity_statuses ias, wf_comments c
WHERE ias.item_type like '%'||:P_ITEM_TYPE||'%'--'XXSUPREQ'-- 'XXMPRFWF' --item_type
AND ias.item_key LIKE '%'||:P_ITEM_KEY||'%' --:1 --item_key
--AND ias.process_activity = :process_activity
AND ias.notification_id IS NOT NULL --added
AND ias.notification_id = c.notification_id
AND c.action NOT IN
('RESPOND', 'RESPOND_WA', 'RESPOND_RULE', 'SEND')
UNION ALL
SELECT c.SEQUENCE h_sequence,
c.notification_id h_notification_id,
c.from_role h_from_role, c.from_user h_from_user,
c.to_role h_to_role, c.to_user h_to_user,
wf_core.TRANSLATE (c.action) h_action,
c.user_comment h_comment,
to_char(c.comment_date,'DD-MON-YYYY') h_action_date, ias.activity_status,
ias.activity_result_code,ias.item_type,ias.item_key
FROM wf_item_activity_statuses_h ias, wf_comments c
WHERE ias.item_type like '%'||:P_ITEM_TYPE||'%'--'XXSUPREQ'--'XXMPRFWF' --item_type
AND ias.item_key LIKE '%'||:P_ITEM_KEY||'%' --:1 --item_key
--AND ias.process_activity = :process_activity
AND ias.notification_id IS NOT NULL --added
AND ias.notification_id = c.notification_id
AND c.action NOT IN
('RESPOND', 'RESPOND_WA', 'RESPOND_RULE', 'SEND'))
ORDER BY h_notification_id, h_sequence)
WHERE h_action NOT IN ('Yes', 'No', 'Cancel')
AND NVL (activity_result_code, 'X') NOT LIKE '%NULL%'