Sunteți pe pagina 1din 5

Create Table mmcl_qa_collection_plan

(RECORD_ID NUMBER,

P_USER_NAME VARCHAR2(30) not null,

P_ORGANIZATION_CODE VARCHAR2(30) not null,

P_PLAN_NAME VARCHAR2(30) not null,

P_PLAN_TYPE VARCHAR2(150) not null,

P_DESCRIPTION VARCHAR2(150) not null,

P_EFFECTIVE_FROM date,

P_ELEMENT_NAME VARCHAR2(30) not null,

P_PROMPT_SEQUENCE number,

P_MANDATORY_FLAG VARCHAR2(10) not null,

P_RESULT_COLUMN_NAME VARCHAR2(30) not null,

RECORD_STATUS_PLAN VARCHAR2(30) not null,

ERROR_MSG_PLAN VARCHAR2(100) not null,

RECORD_STATUS_ELEMENT VARCHAR2(30) not null,

ERROR_MSG_ELEMENT VARCHAR2(100) not null)

-----------------------------------------------------------------------------------
-----------------

CREATE OR REPLACE PROCEDURE mmcl_qa_collection_plan_load IS

l_return_status VARCHAR2(240);

l_msg_count NUMBER;

l_msg_data VARCHAR2(1000);
-- l_end_date VARCHAR2 (240);

l_plan_id NUMBER;

l_error VARCHAR2(1000);

--p_user_name varchar2(100);

--p_organization_code varchar2(20);

CURSOR C1 IS

SELECT DISTINCT cp.p_user_name,

cp.p_organization_code,

cp.p_Plan_name,

cp.p_Plan_type,

cp.p_description,

cp.p_effective_from,

cp.RECORD_STATUS_plan,

cp.error_msg_plan

FROM mmcl_qa_collection_plan cp

WHERE NVL(RECORD_STATUS_plan, 'N') = 'N';

BEGIN

FOR i IN C1 LOOP

BEGIN

l_error := NULL;

QA_PLANS_PUB.CREATE_COLLECTION_PLAN(p_api_version => 1,

x_return_status => l_return_status,

x_msg_count => l_msg_count,

x_msg_data => l_msg_data,

p_user_name => i.p_user_name,

p_plan_name => i.p_plan_name,

p_organization_code =>
i.p_organization_code,
p_plan_type => i.p_plan_type,

p_description => i.p_description,

p_effective_from =>
i.p_effective_from,

--p_effective_to => NULL,

p_spec_assignment_type =>
qa_plans_pub.g_spec_type_none,

p_multirow_flag => 2,

x_plan_id => l_plan_id);

UPDATE mmcl_qa_collection_plan

SET RECORD_STATUS_plan = 'P'

WHERE p_plan_name = i.p_plan_name;

DBMS_OUTPUT.PUT_LINE(I.p_plan_name || ' Inserted' || l_msg_data);

EXCEPTION

WHEN OTHERS THEN

DBMS_OUTPUT.put_line(i.p_plan_name || 'Plan Error is ' ||

SUBSTR(SQLERRM, 1, 1000) || l_msg_data);

l_error := SQLERRM;

UPDATE mmcl_qa_collection_plan

SET RECORD_STATUS_plan = 'E', error_msg_plan = l_error

WHERE p_plan_name = i.p_plan_name;

END;

END LOOP;

COMMIT;

-----------------------------------------------------------------------------------
----
FOR j IN (SELECT *

FROM mmcl_qa_collection_plan

WHERE record_status_plan = 'P'

AND NVL(record_status_element, 'N') = 'N'

ORDER BY record_id) LOOP

BEGIN

l_error := NULL;

QA_PLANS_PUB.add_plan_element(p_api_version => 1,

x_return_status => l_return_status,

x_msg_count => l_msg_count,

x_msg_data => l_msg_data,

p_user_name => j.p_user_name,

p_plan_name => j.p_plan_name,

p_organization_code => j.p_organization_code,

p_element_name => j.p_element_name,

p_prompt_sequence => j.p_prompt_sequence, --


IN NUMBER := NULL,

p_prompt => QA_PLANS_PUB.g_inherit,

p_default_value => QA_PLANS_PUB.g_inherit,

p_enabled_flag => fnd_api.g_true,

p_mandatory_flag => j.p_mandatory_flag,

p_displayed_flag => fnd_api.g_true,

p_read_only_flag => QA_PLANS_PUB.g_inherit,

--p_ss_poplist_flag IN
VARCHAR2 := NULL,

--p_information_flag IN
VARCHAR2 := NULL,

p_result_column_name => j.p_result_column_name


--IN VARCHAR2 := NULL

);
UPDATE mmcl_qa_collection_plan

SET RECORD_STATUS_element = 'P'

WHERE record_id = j.record_id;

DBMS_OUTPUT.PUT_LINE(j.RECORD_ID || ' Inserted');

EXCEPTION

WHEN OTHERS THEN

DBMS_OUTPUT.put_line(j.record_id || ' Error is ' ||

SUBSTR(SQLERRM, 1, 1000));

l_error := SQLERRM;

UPDATE mmcl_qa_collection_plan

SET RECORD_STATUS_element = 'E', error_msg_element = l_error

WHERE record_id = j.record_id;

END;

END LOOP;

COMMIT;

END;