The following lines contain the word 'select', 'insert', 'update' or 'delete':
select access_id from as_accesses_all a
where customer_id= c_from_fk_id
and exists (select null from as_accesses_all b
where customer_id =c_to_fk_id
and (b.lead_id = a.lead_id or
(b.lead_id is null and a.lead_id is null))
and (b.org_id =a.org_id or
(b.org_id is null and a.org_id is null))
and (b.salesforce_id =a.salesforce_id or
(b.salesforce_id is null and a.salesforce_id is null))
and (b.sales_lead_id =a.sales_lead_id or
(b.sales_lead_id is null and a.sales_lead_id is null))
and (b.sales_group_id = a.sales_group_id or
(b.sales_group_id is null and a.sales_group_id is null)));
select access_id
from as_accesses_all b
where b.address_id = c_from_fk_id
and b.customer_id in
(select customer_id
from as_accesses_all c
where (c.address_id = c_to_fk_id or
(b.address_id is null and c.address_id is null))
and (b.lead_id = c.lead_id or
(b.lead_id is null and c.lead_id is null))
and (b.org_id =c.org_id or
(b.org_id is null and c.org_id is null))
and (b.salesforce_id =c.salesforce_id or
(b.salesforce_id is null and c.salesforce_id is null))
and (b.sales_lead_id =c.sales_lead_id or
(b.sales_lead_id is null and c.sales_lead_id is null))
and (b.sales_group_id = c.sales_group_id or
(b.sales_group_id is null and c.sales_group_id is null)));
select merge_reason_code into l_merge_reason_code
from HZ_MERGE_BATCH
where batch_id = p_batch_id;
DELETE FROM as_territory_accesses
WHERE access_id = I.access_id;
DELETE FROM as_accesses_all
WHERE access_id = I.access_id;
UPDATE AS_ACCESSES_ALL
set object_version_number = nvl(object_version_number,0) + 1,
customer_id = p_to_fk_id,
last_update_date = hz_utility_pub.last_update_date,
last_updated_by = hz_utility_pub.user_id,
last_update_login = hz_utility_pub.last_update_login,
program_application_id=hz_utility_pub.program_application_id,
program_id = hz_utility_pub.program_id,
program_update_date = sysdate
where customer_id = p_from_fk_id;
UPDATE AS_ACCESSES_ALL
set partner_customer_id = p_to_fk_id,
salesforce_id=( select resource_id
from jtf_rs_resource_extns
where category = 'PARTNER'
and source_id = p_to_fk_id),
last_update_date = hz_utility_pub.last_update_date,
last_updated_by = hz_utility_pub.user_id,
last_update_login = hz_utility_pub.last_update_login,
program_application_id=hz_utility_pub.program_application_id,
program_id = hz_utility_pub.program_id,
program_update_date = sysdate
where partner_customer_id = p_from_fk_id;
UPDATE AS_ACCESSES_ALL
set partner_customer_id = p_to_fk_id,
last_update_date = hz_utility_pub.last_update_date,
last_updated_by = hz_utility_pub.user_id,
last_update_login = hz_utility_pub.last_update_login,
program_application_id=hz_utility_pub.program_application_id,
program_id = hz_utility_pub.program_id,
program_update_date = sysdate
where partner_customer_id = p_from_fk_id;
UPDATE AS_ACCESSES_ALL
set partner_cont_party_id = p_to_fk_id,
last_update_date = hz_utility_pub.last_update_date,
last_updated_by = hz_utility_pub.user_id,
last_update_login = hz_utility_pub.last_update_login,
program_application_id=hz_utility_pub.program_application_id,
program_id = hz_utility_pub.program_id,
program_update_date = sysdate
where partner_cont_party_id = p_from_fk_id;
DELETE FROM as_territory_accesses
WHERE access_id = I.access_id;
DELETE FROM as_accesses_all
WHERE access_id = I.access_id;
UPDATE AS_ACCESSES_ALL
set object_version_number = nvl(object_version_number,0) + 1,
address_id = p_to_fk_id,
last_update_date = hz_utility_pub.last_update_date,
last_updated_by = hz_utility_pub.user_id,
last_update_login = hz_utility_pub.last_update_login,
program_application_id=hz_utility_pub.program_application_id,
program_id = hz_utility_pub.program_id,
program_update_date = sysdate
where address_id = p_from_fk_id;
UPDATE AS_ACCESSES_ALL
set partner_address_id = p_to_fk_id,
last_update_date = hz_utility_pub.last_update_date,
last_updated_by = hz_utility_pub.user_id,
last_update_login = hz_utility_pub.last_update_login,
program_application_id=hz_utility_pub.program_application_id,
program_id = hz_utility_pub.program_id,
program_update_date = sysdate
where partner_address_id = p_from_fk_id;
select merge_reason_code into l_merge_reason_code
from HZ_MERGE_BATCH
where batch_id = p_batch_id;
delete from as_changed_accounts_all
where customer_id = p_to_fk_id;
UPDATE AS_CHANGED_ACCOUNTS_ALL
set object_version_number = nvl(object_version_number,0) + 1,
customer_id = p_to_fk_id,
last_update_date = hz_utility_pub.last_update_date,
last_updated_by = hz_utility_pub.user_id,
last_update_login = hz_utility_pub.last_update_login,
program_application_id = hz_utility_pub.program_application_id,
program_id = hz_utility_pub.program_id,
program_update_date = sysdate
where customer_id = p_from_fk_id;
delete from as_changed_accounts_all b
where b.address_id=p_from_fk_id
and b.customer_id in
(select customer_id
from as_changed_accounts_all c
where c.address_id=p_to_fk_id) ;
UPDATE AS_CHANGED_ACCOUNTS_ALL
set object_version_number = nvl(object_version_number,0) + 1,
address_id = p_to_fk_id,
last_update_date = hz_utility_pub.last_update_date,
last_updated_by = hz_utility_pub.user_id,
last_update_login = hz_utility_pub.last_update_login,
program_application_id = hz_utility_pub.program_application_id,
program_id = hz_utility_pub.program_id,
program_update_date = sysdate
where address_id = p_from_fk_id
and customer_id not in(select customer_id from as_changed_accounts_all
where address_id=p_to_fk_id) ;