DECLARE
CURSOR stage
IS
SELECT *
FROM staging_meter_assoc_table
WHERE flag IS NULL;
l_stat VARCHAR2 (10);
l_count NUMBER;
l_data VARCHAR2 (100);
v_stat VARCHAR2 (1) := 'S';
BEGIN
FOR i IN stage
LOOP
eam_meterassoc_pub.insert_assetmeterassoc
(p_api_version => 1.0,
x_return_status => l_stat,
x_msg_count => l_count,
x_msg_data => l_data,
p_meter_id => i.meter_id,
p_organization_id => i.organization_id,
p_asset_group_id => i.asset_group_id,
p_asset_number => i.asset_number
);
--DBMS_OUTPUT.put_line (l_stat || ' - ' || i.meter_id);
UPDATE staging_meter_assoc_table
SET flag = l_stat
WHERE meter_id = i.meter_id;
COMMIT;
IF l_stat <> 'S'
THEN
v_stat := 'E';
ROLLBACK;
EXIT;
END IF;
END LOOP;
IF v_stat <> 'E'
THEN
COMMIT;
END IF;
END;
No comments:
Post a Comment