You are on page 1of 3

/***********************************************************************/

--Queries for Validation before the Conversion Program has been executed
/***********************************************************************/
-----------------------------------------------------------------------Query to Check if the HRMS employee record for salesreps is inactive
---------------------------------------------------------------------SELECT papf.employee_number,
papf.full_name,
papf.effective_start_date,
papf.effective_end_date,
ppt.person_type_id,
ppt.user_person_type
FROM cci_custom.cci_cnext104_salesreps stg,
per_all_people_f
papf,
per_person_types
ppt
WHERE stg.salesrep_number
= papf.employee_number
AND papf.person_type_id
= ppt.person_type_id
AND ppt.person_type_id
= 9 --Indicates EX_EMP
AND SYSDATE BETWEEN papf.effective_start_date
AND papf.effective_end_date;
---------------------------------------------------Get the List of Salesreps/old org in Stg Table
--who are not present in system(jtf_Rs_salesreps)
-------------------------------------------------SELECT DISTINCT salesrep_number,
old_org_id
FROM cci_custom.cci_cnext104_salesreps stg
WHERE NOT EXISTS(SELECT 1
FROM jtf_rs_salesreps
WHERE salesrep_number = stg.salesrep_number
AND org_id
= stg.old_org_id);
------------------------------------------------------Get the list of Old Role Name in Stage Table
--not present in System
----------------------------------------------------SELECT DISTINCT old_role_name
FROM cci_custom.cci_cnext104_salesreps stg
WHERE NOT EXISTS(SELECT 1
FROM jtf_rs_roles_tl
WHERE role_name =stg.old_role_name);
------------------------------------------------------------Get the list of Old Groups in Stage table that are
--not present in system
----------------------------------------------------------SELECT DISTINCT old_group_name
FROM cci_custom.cci_cnext104_salesreps stg
WHERE NOT EXISTS(SELECT 1
FROM jtf_rs_groups_tl
WHERE group_name = stg.old_group_name);
---------------------------------------------------------------Get the list of New Role Names in Stage table
--that are not present in System
-------------------------------------------------------------SELECT DISTINCT new_role_name

FROM cci_custom.cci_cnext104_salesreps stg


WHERE NOT EXISTS(SELECT 1
FROM jtf_rs_roles_tl
WHERE role_name = stg.new_role_name);
----------------------------------------------------------------Get the list of New Group Names in Stage table that are
--not present in system
--------------------------------------------------------------SELECT DISTINCT new_group_name
FROM cci_custom.cci_cnext104_salesreps stg
WHERE NOT EXISTS(SELECT 1
FROM jtf_rs_groups_tl
WHERE group_name = stg.new_group_name);
-------------------------------------------------------------------Check if the salesrep has active Groups assigned other than the
--old groups specified in Flat File.
-----------------------------------------------------------------SELECT DISTINCT stg.salesrep_number,
jrgt.group_name,
stg.old_group_name,
jrrr.start_Date_Active,
jrrr.end_Date_active,
stg.old_role_res_end_date
FROM cci_custom.cci_cnext104_salesreps
stg,
jtf_rs_salesreps
jrs,
jtf_rs_role_relations
jrrr,
jtf_rs_groups_b
jrgb,
jtf_rs_groups_tl
jrgt,
jtf_rs_group_members
jrgm
WHERE stg.salesrep_number
= jrs.salesrep_number
AND jrs.org_id
= stg.old_org_id
AND jrs.resource_id
= jrgm.resource_id
AND jrgt.group_id
= jrgb.group_id
AND jrgt.group_id
= jrgm.group_id
AND jrgm.group_member_id
= jrrr.role_resource_id
AND NVL(jrrr.end_date_active,'31-DEC-4712') > NVL(stg.old_role_res_end_date,'
31-DEC-4712')
AND NVL(jrrr.delete_flag,'N')
= 'N'
AND jrgt.group_name
<> stg.old_group_name
ORDER BY stg.salesrep_number;
/***********************************************************************/
--Queries for Validation after the Conversion Program has been executed
/***********************************************************************/
-----------------------------------------------------------------Query to check if correct CCI roles are assigned to salesreps
---------------------------------------------------------------SELECT jrs.salesrep_number,
jrrt.role_name,
jrrr.start_date_Active,
jrrr.end_Date_Active
FROM cci_custom.cci_cnext104_salesreps
stg,
jtf_rs_salesreps
jrs,
jtf_rs_role_relations
jrrr,
jtf_rs_roles_b
jrrb,

jtf_rs_roles_tl
jrrt
WHERE stg.salesrep_number
= jrs.salesrep_number
AND jrs.org_id
= 221
AND jrs.resource_id
= jrrr.role_resource_id
AND jrrr.role_id
= jrrt.role_id
AND jrrt.role_id
= jrrb.role_id
AND jrrt.role_name
= stg.new_role_name
AND jrrr.start_date_active
= stg.new_role_res_start_date
AND NVL(jrrr.end_date_Active,'31-DEC-4712')= NVL(stg.new_role_Res_end_date,'31
-DEC-4712')
AND stg.status
='PROCESSED';
-----------------------------------------------------------------Query to Check if Correct CCI Groups are assigned to salesreps
---------------------------------------------------------------SELECT jrs.salesrep_number,
jrgt.group_name,
jrrr.start_date_Active,
jrrr.end_Date_Active
FROM cci_custom.cci_cnext104_salesreps
stg,
jtf_rs_salesreps
jrs,
jtf_rs_role_relations
jrrr,
jtf_rs_groups_b
jrgb,
jtf_rs_groups_tl
jrgt,
jtf_rs_group_members
jrgm
WHERE stg.salesrep_number
= jrs.salesrep_number
AND jrs.org_id
= 221
AND jrs.resource_id
= jrgm.resource_id
AND jrgt.group_id
= jrgb.group_id
AND jrgt.group_id
= jrgm.group_id
AND jrgm.group_member_id
= jrrr.role_resource_id
AND jrrr.start_date_active
= stg.new_grp_member_role_start_
date
AND NVL(jrrr.end_date_active,'31-DEC-4712') = NVL(stg.new_grp_member_role_en
d_date,'31-DEC-4712')
AND stg.status
= 'PROCESSED';