3240:
3241: BEGIN
3242: select 1
3243: into l_dummy
3244: from wsm_split_merge_transactions wsmt,
3245: wsm_sm_resulting_jobs wrj,
3246: wip_entities we
3247: where wrj.wip_entity_id = p_wip_entity_id
3248: and wrj.transaction_id = wsmt.transaction_id
4045: and we.entity_type = 5) -- check only LBJs
4046: and (exists (
4047: select 1
4048: from wsm_sm_starting_jobs sj,
4049: wsm_split_merge_transactions wmt
4050: --Bug 4744794: join based on wip_entity_id is replaced with
4051: -- join based on wip_entity_name so that index is used.
4052: --where sj.wip_entity_id = wt.wip_entity_id
4053: where sj.wip_entity_name = wt.wip_entity_name
4056: and (wmt.status <> 4 or nvl(wmt.costed,1) <> 4))
4057: or exists (
4058: select 1
4059: from wsm_sm_resulting_jobs rj,
4060: wsm_split_merge_transactions wmt
4061: --Bug 4744794: join based on wip_entity_id is replaced with
4062: -- join based on wip_entity_name so that index is used.
4063: --where rj.wip_entity_id = wt.wip_entity_id
4064: where rj.wip_entity_name = wt.wip_entity_name
4970: INTO l_sj_rowcount
4971: FROM dual
4972: WHERE exists (select 'Unprocessed WSMT Record exists'
4973: FROM WSM_SM_STARTING_JOBS WSSJ,
4974: WSM_SPLIT_MERGE_TRANSACTIONS WSMT
4975: WHERE
4976: WSSJ.wip_entity_id = p_wip_entity_id
4977: AND WSMT.transaction_id = WSSJ.transaction_id
4978: AND WSMT.status IN (WIP_CONSTANTS.PENDING,
4996: INTO l_sj_rowcount
4997: FROM dual
4998: WHERE exists (select 'Unprocessed WSSJ/WSMT Record exists'
4999: FROM WSM_SM_STARTING_JOBS WSSJ,
5000: WSM_SPLIT_MERGE_TRANSACTIONS WSMT
5001: WHERE
5002: WSSJ.wip_entity_id = p_wip_entity_id
5003: AND WSMT.transaction_id = WSSJ.transaction_id
5004: AND WSMT.status IN (WIP_CONSTANTS.PENDING,
5033: INTO l_rj_rowcount
5034: FROM dual
5035: WHERE exists (select 'Unprocessed WSRJ/WSMT Record exists'
5036: FROM WSM_SM_RESULTING_JOBS WSRJ,
5037: WSM_SPLIT_MERGE_TRANSACTIONS WSMT
5038: WHERE
5039: WSRJ.wip_entity_id = p_wip_entity_id
5040: AND WSMT.transaction_id = WSRJ.transaction_id
5041: AND WSMT.status IN (WIP_CONSTANTS.PENDING,
5058: INTO l_rj_rowcount
5059: FROM dual
5060: WHERE exists (select 'Unprocessed WSRJ/WSMT Record exists'
5061: FROM WSM_SM_RESULTING_JOBS WSRJ,
5062: WSM_SPLIT_MERGE_TRANSACTIONS WSMT
5063: WHERE
5064: WSRJ.wip_entity_id = p_wip_entity_id
5065: AND WSMT.transaction_id = WSRJ.transaction_id
5066: AND WSMT.status IN (WIP_CONSTANTS.PENDING,
5100: INTO l_rj_rowcount
5101: FROM dual
5102: WHERE exists (select 'Unprocessed WSRJ/WSMT Record exists'
5103: FROM WSM_SM_RESULTING_JOBS WSRJ,
5104: WSM_SPLIT_MERGE_TRANSACTIONS WSMT
5105: WHERE
5106: WSRJ.wip_entity_name = p_wip_entity_name
5107: AND WSMT.organization_id = decode(p_organization_id,
5108: 0, WSMT.organization_id, p_organization_id)
5128: INTO l_rj_rowcount
5129: FROM dual
5130: WHERE exists (select 'Unprocessed WSRJ/WSMT Record exists'
5131: FROM WSM_SM_RESULTING_JOBS WSRJ,
5132: WSM_SPLIT_MERGE_TRANSACTIONS WSMT
5133: WHERE
5134: WSRJ.wip_entity_name = p_wip_entity_name
5135: AND WSMT.organization_id = decode(p_organization_id,
5136: 0, WSMT.organization_id, p_organization_id)