CREATE OR REPLACE PACKAGE xx_delivery_subscription_pkg
AS
FUNCTION subscription(
p_subscription_guid IN RAW
, p_event IN OUT NOCOPY wf_event_t
)
RETURN VARCHAR2;
END xx_delivery_subscription_pkg;
/
CREATE OR REPLACE PACKAGE BODY xx_delivery_subscription_pkg
AS
FUNCTION subscription(
p_subscription_guid IN RAW
, p_event IN OUT NOCOPY wf_event_t
)
RETURN VARCHAR2
IS
l_event_name VARCHAR2(2000);
l_event_key VARCHAR2(2000);
l_err_text VARCHAR2(3000);
l_param_list wf_parameter_list_t;
l_param_name VARCHAR2(240);
l_param_value VARCHAR2(2000);
l_order_number VARCHAR2(50);
BEGIN
l_param_list := p_event.getparameterlist;
l_event_name := p_event.geteventname();
l_event_key := p_event.geteventkey();
IF l_param_list IS NOT NULL
THEN
FOR i IN l_param_list.FIRST .. l_param_list.LAST
LOOP
l_param_name := l_param_list(i).getname;
l_param_value := l_param_list(i).getvalue;
DBMS_OUTPUT.put_line('Parameter Name : ' || l_param_name || 'Parameter Value : ' || l_param_value);
BEGIN
SELECT oh.order_number
INTO l_order_number
FROM wsh_delivery_details wdd
, oe_order_headers_all oh
, wsh_delivery_assignments wda
, wsh_new_deliveries wnd
WHERE wdd.source_header_id = oh.header_id
AND wdd.delivery_detail_id = wda.delivery_detail_id
AND wnd.delivery_id = wda.delivery_id
AND wnd.delivery_id = l_param_value
AND wnd.status_code <> 'OP'
AND wdd.source_code = 'OE'
AND wdd.released_status = 'C';
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line('Unexpected Error : ' || SUBSTR(SQLERRM
, 1
, 250
));
END;
INSERT INTO xx_shiment_notification_stg
VALUES (l_param_value
, l_order_number
);
END LOOP;
COMMIT;
END IF;
RETURN 'SUCCESS';
EXCEPTION
WHEN OTHERS
THEN
RETURN 'ERROR';
END subscription;
END xx_delivery_subscription_pkg;
AS
FUNCTION subscription(
p_subscription_guid IN RAW
, p_event IN OUT NOCOPY wf_event_t
)
RETURN VARCHAR2;
END xx_delivery_subscription_pkg;
/
CREATE OR REPLACE PACKAGE BODY xx_delivery_subscription_pkg
AS
FUNCTION subscription(
p_subscription_guid IN RAW
, p_event IN OUT NOCOPY wf_event_t
)
RETURN VARCHAR2
IS
l_event_name VARCHAR2(2000);
l_event_key VARCHAR2(2000);
l_err_text VARCHAR2(3000);
l_param_list wf_parameter_list_t;
l_param_name VARCHAR2(240);
l_param_value VARCHAR2(2000);
l_order_number VARCHAR2(50);
BEGIN
l_param_list := p_event.getparameterlist;
l_event_name := p_event.geteventname();
l_event_key := p_event.geteventkey();
IF l_param_list IS NOT NULL
THEN
FOR i IN l_param_list.FIRST .. l_param_list.LAST
LOOP
l_param_name := l_param_list(i).getname;
l_param_value := l_param_list(i).getvalue;
DBMS_OUTPUT.put_line('Parameter Name : ' || l_param_name || 'Parameter Value : ' || l_param_value);
BEGIN
SELECT oh.order_number
INTO l_order_number
FROM wsh_delivery_details wdd
, oe_order_headers_all oh
, wsh_delivery_assignments wda
, wsh_new_deliveries wnd
WHERE wdd.source_header_id = oh.header_id
AND wdd.delivery_detail_id = wda.delivery_detail_id
AND wnd.delivery_id = wda.delivery_id
AND wnd.delivery_id = l_param_value
AND wnd.status_code <> 'OP'
AND wdd.source_code = 'OE'
AND wdd.released_status = 'C';
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line('Unexpected Error : ' || SUBSTR(SQLERRM
, 1
, 250
));
END;
INSERT INTO xx_shiment_notification_stg
VALUES (l_param_value
, l_order_number
);
END LOOP;
COMMIT;
END IF;
RETURN 'SUCCESS';
EXCEPTION
WHEN OTHERS
THEN
RETURN 'ERROR';
END subscription;
END xx_delivery_subscription_pkg;
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.