declare
cursor
c_orders_to_retry is
SELECT
P.INSTANCE_LABEL,
WAS.ITEM_KEY,
H.ORDER_NUMBER,
H.ORG_ID,
was.begin_date
FROM
WF_ITEM_ACTIVITY_STATUSES WAS,
WF_PROCESS_ACTIVITIES P,
OE_ORDER_HEADERS_ALL H
WHERE
TO_NUMBER (WAS.ITEM_KEY) = H.HEADER_ID
AND
WAS.PROCESS_ACTIVITY = P.INSTANCE_ID
AND
P.ACTIVITY_ITEM_TYPE = 'OEOH'
AND
P.ACTIVITY_NAME = 'CLOSE_WAIT_FOR_L'
AND
WAS.ACTIVITY_STATUS = 'NOTIFIED'
AND
WAS.ITEM_TYPE = 'OEOH'
AND NOT EXISTS
(SELECT /*+ NO_UNNEST */
1
FROM
OE_ORDER_LINES_ALL
WHERE
HEADER_ID = TO_NUMBER (WAS.ITEM_KEY)
AND
OPEN_FLAG = 'Y')
--and h.order_number = '4214653'
;
l_update_flag varchar2(1) := 'N';
begin
dbms_output.put_line('Update Flag : '||l_update_flag);
for o in c_orders_to_retry
loop
if
l_update_flag = 'Y' then
MO_GLOBAL.set_policy_context ('S', o.org_id);
WF_ENGINE.HANDLEERROR('OEOH', o.ITEM_KEY, o.INSTANCE_LABEL, 'RETRY',NULL);
end if;
dbms_output.put_line('Order : '||o.order_number);
end loop;
--commit;
exception
when others then
dbms_output.put_line('Error : '||sqlerrm);
end;
No comments:
Post a Comment