The following lines contain the word 'select', 'insert', 'update' or 'delete':
SELECT cii.inventory_item_id,
cii.serial_number
INTO
l_asset_group_id,
l_asset_number
FROM
csi_item_instances cii
WHERE
cii.instance_id = p_work_order_rec.maintenance_object_id;
SELECT instance_id into l_gen_object_id
FROM csi_item_instances
WHERE inventory_item_id = p_work_order_rec.asset_group_id and serial_number = p_work_order_rec.asset_number and last_vld_organization_id =p_work_order_rec.organization_id ;
select instance_id into l_gen_object_id
from csi_item_instances
where inventory_item_id = p_work_order_rec.rebuild_item_id and serial_number = p_work_order_rec.rebuild_serial_number and last_vld_organization_id =p_work_order_rec.organization_id;
SELECT inventory_item_id into l_gen_object_id
FROM mtl_system_items
WHERE inventory_item_id = p_work_order_rec.rebuild_item_id and organization_id =p_work_order_rec.organization_id;
SELECT department_id into l_dept_id
FROM bom_departments
WHERE department_code = p_work_order_rec.owning_department_code and organization_id= p_work_order_rec.organization_id;
SELECT MEAA.activity_cause_code
INTO x_activity_cause_code
FROM MTL_EAM_ASSET_ACTIVITIES MEAA
WHERE MEAA.organization_id = p_organization_id
AND MEAA.asset_activity_id = p_primary_item_id
AND MEAA.maintenance_object_id = p_maintenance_object_id
AND MEAA.maintenance_object_type = p_maintenance_object_type
AND NVL(MEAA.tmpl_flag,'N') = 'N';
SELECT MEAA.activity_cause_code
INTO x_activity_cause_code
FROM MTL_EAM_ASSET_ACTIVITIES MEAA
WHERE MEAA.organization_id = p_organization_id
AND MEAA.asset_activity_id = p_primary_item_id
AND MEAA.maintenance_object_id = p_rebuild_item_id
AND MEAA.maintenance_object_type = 2 ;-- 'MSI'
SELECT MSI.eam_activity_cause_code
INTO x_activity_cause_code
FROM MTL_SYSTEM_ITEMS MSI
WHERE MSI.inventory_item_id = p_primary_item_id
AND MSI.organization_id = p_organization_id;
SELECT value
INTO l_full_path
FROM v$parameter
WHERE name = 'utl_file_dir';
SELECT trim(substr(l_full_path, 1, decode(instr(l_full_path,',')-1,
-1, length(l_full_path),
instr(l_full_path, ',')-1
)
)
)
INTO l_file_dir
FROM dual;
SELECT MEAA.activity_type_code
INTO x_activity_type_code
FROM MTL_EAM_ASSET_ACTIVITIES MEAA
WHERE MEAA.organization_id = p_organization_id
AND MEAA.asset_activity_id = p_primary_item_id
AND MEAA.maintenance_object_id = p_maintenance_object_id
AND MEAA.maintenance_object_type = p_maintenance_object_type
AND NVL(MEAA.tmpl_flag,'N') = 'N';
SELECT MEAA.activity_type_code
INTO x_activity_type_code
FROM MTL_EAM_ASSET_ACTIVITIES MEAA
WHERE MEAA.organization_id = p_organization_id
AND MEAA.asset_activity_id = p_primary_item_id
AND MEAA.maintenance_object_id = p_rebuild_item_id
AND MEAA.maintenance_object_type = 2 ;-- 'MSI'
SELECT MSI.eam_activity_type_code
INTO x_activity_type_code
FROM MTL_SYSTEM_ITEMS MSI
WHERE MSI.inventory_item_id = p_primary_item_id
AND MSI.organization_id = p_organization_id;
SELECT MEAA.activity_source_code
INTO x_activity_source_code
FROM MTL_EAM_ASSET_ACTIVITIES MEAA
WHERE MEAA.organization_id = p_organization_id
AND MEAA.asset_activity_id = p_primary_item_id
AND MEAA.maintenance_object_id = p_maintenance_object_id
AND MEAA.maintenance_object_type = p_maintenance_object_type
AND NVL(MEAA.tmpl_flag,'N') = 'N';
SELECT MEAA.activity_source_code
INTO x_activity_source_code
FROM MTL_EAM_ASSET_ACTIVITIES MEAA
WHERE MEAA.organization_id = p_organization_id
AND MEAA.asset_activity_id = p_primary_item_id
AND MEAA.maintenance_object_id = p_rebuild_item_id
AND MEAA.maintenance_object_type = 2 ;-- 'MSI'
SELECT MSI.eam_activity_source_code
INTO x_activity_source_code
FROM MTL_SYSTEM_ITEMS MSI
WHERE MSI.inventory_item_id = p_primary_item_id
AND MSI.organization_id = p_organization_id;
SELECT MEAA.shutdown_type_code
INTO x_shutdown_type_code
FROM MTL_EAM_ASSET_ACTIVITIES MEAA
WHERE MEAA.organization_id = p_organization_id
AND MEAA.asset_activity_id = p_primary_item_id
AND MEAA.maintenance_object_id = p_maintenance_object_id
AND MEAA.maintenance_object_type = p_maintenance_object_type
AND NVL(MEAA.tmpl_flag,'N') = 'N';
SELECT MEAA.shutdown_type_code
INTO x_shutdown_type_code
FROM MTL_EAM_ASSET_ACTIVITIES MEAA
WHERE MEAA.organization_id = p_organization_id
AND MEAA.asset_activity_id = p_primary_item_id
AND MEAA.maintenance_object_id = p_rebuild_item_id
AND MEAA.maintenance_object_type = 2 ;-- 'MSI'
SELECT MSI.eam_act_shutdown_status
INTO x_shutdown_type_code
FROM MTL_SYSTEM_ITEMS MSI
WHERE MSI.inventory_item_id = p_primary_item_id
AND MSI.organization_id = p_organization_id;
SELECT MEAA.notification_required
INTO x_notification_flag
FROM MTL_EAM_ASSET_ACTIVITIES MEAA
WHERE MEAA.organization_id = p_organization_id
AND MEAA.asset_activity_id = p_primary_item_id
AND MEAA.maintenance_object_id = p_maintenance_object_id
AND MEAA.maintenance_object_type = p_maintenance_object_type
AND NVL(MEAA.tmpl_flag,'N') = 'N';
SELECT MEAA.notification_required
INTO x_notification_flag
FROM MTL_EAM_ASSET_ACTIVITIES MEAA
WHERE MEAA.organization_id = p_organization_id
AND MEAA.asset_activity_id = p_primary_item_id
AND MEAA.maintenance_object_id = p_rebuild_item_id
AND MEAA.maintenance_object_type = 2 ;-- 'MSI'
SELECT MSI.eam_act_notification_flag
INTO x_notification_flag
FROM MTL_SYSTEM_ITEMS MSI
WHERE MSI.inventory_item_id = p_primary_item_id
AND MSI.organization_id = p_organization_id;
SELECT MEAA.tagging_required_flag
INTO x_tagout_required
FROM MTL_EAM_ASSET_ACTIVITIES MEAA
WHERE MEAA.organization_id = p_organization_id
AND MEAA.asset_activity_id = p_primary_item_id
AND MEAA.maintenance_object_id = p_maintenance_object_id
AND MEAA.maintenance_object_type = p_maintenance_object_type
AND NVL(MEAA.tmpl_flag,'N') = 'N';
SELECT MEAA.tagging_required_flag
INTO x_tagout_required
FROM MTL_EAM_ASSET_ACTIVITIES MEAA
WHERE MEAA.organization_id = p_organization_id
AND MEAA.asset_activity_id = p_primary_item_id
AND MEAA.maintenance_object_id = p_rebuild_item_id
AND MEAA.maintenance_object_type = 2 ;-- 'MSI'
SELECT MEAA.owning_department_id
INTO x_owning_department_id
FROM MTL_EAM_ASSET_ACTIVITIES MEAA
WHERE MEAA.asset_activity_id = p_primary_item_id
AND MEAA.maintenance_object_id = p_maintenance_object_id
AND MEAA.maintenance_object_type = p_maintenance_object_type
AND NVL(MEAA.tmpl_flag,'N') = 'N';
SELECT MEAA.activity_association_id
INTO l_act_assoc_id
FROM MTL_EAM_ASSET_ACTIVITIES MEAA
WHERE MEAA.asset_activity_id = p_primary_item_id
AND MEAA.maintenance_object_id = p_maintenance_object_id
AND MEAA.maintenance_object_type = p_maintenance_object_type
AND NVL(MEAA.tmpl_flag,'N') = 'N';
SELECT EOMD.OWNING_DEPARTMENT_ID
INTO x_owning_department_id
FROM EAM_ORG_MAINT_DEFAULTS EOMD
WHERE EOMD.organization_id = p_organization_id
AND EOMD.OBJECT_ID = l_act_assoc_id
AND EOMD.OBJECT_TYPE IN (40,60) ;
SELECT EOMD.OWNING_DEPARTMENT_ID
INTO x_owning_department_id
FROM EAM_ORG_MAINT_DEFAULTS EOMD
WHERE EOMD.organization_id = p_organization_id
AND EOMD.OBJECT_ID = p_maintenance_object_id
AND EOMD.OBJECT_TYPE = 50 ;
SELECT WEP.default_department_id
INTO x_owning_department_id
FROM WIP_EAM_PARAMETERS WEP
WHERE WEP.organization_id = p_organization_id;