The following lines contain the word 'select', 'insert', 'update' or 'delete':
SELECT enable_workflow
INTO l_workflow_enabled
FROM EAM_ENABLE_WORKFLOW
WHERE MAINTENANCE_OBJECT_SOURCE =p_maint_obj_source;
SELECT eam_wo_workflow_enabled
INTO l_workflow_enabled
FROM WIP_EAM_PARAMETERS
WHERE organization_id =p_organization_id;
l_last_update_date DATE;
l_last_updated_by NUMBER;
l_last_update_login NUMBER;
select
wo.organization_id,
wo.department_id,
wdj.asset_number,
wdj.asset_group_id,
wdj.primary_item_id ,
wo.shutdown_type,
wdj.maintenance_object_type,
wdj.maintenance_object_id,
wdj.maintenance_object_source,
ewod.workflow_type,
wo.last_unit_completion_date,
we.wip_entity_name
from
wip_operations wo,
wip_discrete_jobs wdj,
eam_work_order_details ewod,
wip_entities we
where
wdj.wip_entity_id = p_wip_entity_id AND
wdj.wip_entity_id = wo.wip_entity_id AND
wo.operation_seq_num = p_operation_seq_num
AND wdj.wip_entity_id = ewod.wip_entity_id(+)
AND wdj.wip_entity_id = we.wip_entity_id;
select count(won.prior_operation)
from wip_operation_networks won
where
won.wip_entity_id = p_wip_entity_id and
won.next_operation = p_operation_seq_num and
exists (
select 1 from wip_operations
where
wip_entity_id = p_wip_entity_id and
operation_seq_num = won.prior_operation and
nvl(operation_completed,'N') <> 'Y'
);
select count(won.next_operation)
from wip_operation_networks won
where
won.wip_entity_id = p_wip_entity_id and
won.prior_operation = p_operation_seq_num and
exists (
select 1 from wip_operations
where
wip_entity_id = p_wip_entity_id and
operation_seq_num = won.next_operation and
operation_completed = 'Y'
);
select nvl(max(actual_end_date),sysdate-20000)
from eam_op_completion_txns eoct,wip_operation_networks won
where eoct.wip_entity_id = p_wip_entity_id
and eoct.operation_seq_num=won.prior_operation
and won.wip_entity_id=eoct.wip_entity_id
and won.next_operation=p_operation_seq_num
and transaction_type=1
and transaction_id = (select max(transaction_id)
from eam_op_completion_txns
where wip_entity_id = p_wip_entity_id
and operation_seq_num = eoct.operation_seq_num
);
select transaction_id from eam_op_completion_txns
where transaction_id = l_transaction_id;
select asset_status_id from eam_asset_status_history
where asset_status_id = l_status_id;
select status_type
into l_job_status
from wip_discrete_jobs
where wip_entity_id = p_wip_entity_id;
l_last_updated_by := FND_GLOBAL.USER_ID;
l_last_update_login := FND_GLOBAL.LOGIN_ID;
l_last_update_date := sysdate;
UPDATE wip_operations
SET
operation_completed = l_op_completed,
quantity_completed = 1,
last_updated_by = l_last_updated_by,
last_update_date = l_last_update_date,
last_update_login = l_last_update_login
WHERE
wip_entity_id = p_wip_entity_id AND
operation_seq_num = p_operation_seq_num;
select eam_op_completion_txns_s.nextval into l_transaction_id from dual;
INSERT INTO EAM_OP_COMPLETION_TXNS(
TRANSACTION_ID,
TRANSACTION_DATE,
TRANSACTION_TYPE,
WIP_ENTITY_ID,
ORGANIZATION_ID,
OPERATION_SEQ_NUM,
ACCT_PERIOD_ID,
QA_COLLECTION_ID,
REFERENCE,
RECONCILIATION_CODE,
DEPARTMENT_ID,
---ASSET_GROUP_ID,
--ASSET_NUMBER,
ASSET_ACTIVITY_ID,
ACTUAL_START_DATE,
ACTUAL_END_DATE,
ACTUAL_DURATION,
VENDOR_ID,
VENDOR_SITE_ID,
VENDOR_CONTACT_ID,
REASON_ID,
TRANSACTION_REFERENCE,
CREATED_BY,
CREATION_DATE,
LAST_UPDATED_BY,
LAST_UPDATE_DATE,
LAST_UPDATE_LOGIN,
attribute_category,
attribute1,
attribute2,
attribute3,
attribute4,
attribute5,
attribute6,
attribute7,
attribute8,
attribute9,
attribute10,
attribute11,
attribute12,
attribute13,
attribute14,
attribute15
) VALUES (
l_transaction_id,
p_transaction_date,
p_transaction_type,
p_wip_entity_id,
l_organization_id,
p_operation_seq_num,
NULL,
p_qa_collection_id,
NULL,
p_reconciliation_code,
l_department_id,
--l_asset_group_id,
--l_asset_number,
l_asset_activity_id,
decode(p_transaction_type,1,p_actual_start_date,2,null),
decode(p_transaction_type,1,p_actual_end_date,2,null),
decode(p_transaction_type,1,p_actual_duration,2,null),
p_vendor_id,
p_vendor_site_id,
p_vendor_contact_id,
p_reason_id,
p_reference,
l_last_updated_by,
l_last_update_date,
l_last_updated_by,
l_last_update_date,
l_last_update_login,
p_attribute_category,
p_attribute1,
p_attribute2,
p_attribute3,
p_attribute4,
p_attribute5,
p_attribute6,
p_attribute7,
p_attribute8,
p_attribute9,
p_attribute10,
p_attribute11,
p_attribute12,
p_attribute13,
p_attribute14,
p_attribute15
);
UPDATE eam_asset_status_history
SET enable_flag = 'N'
, last_update_date = SYSDATE
, last_updated_by = FND_GLOBAL.user_id
, last_update_login = FND_GLOBAL.login_id
WHERE organization_id = l_organization_id
AND wip_entity_id = p_wip_entity_id
AND operation_seq_num = p_operation_seq_num
AND enable_flag = 'Y' OR enable_flag IS NULL;
select eam_asset_status_history_s.nextval into l_status_id from dual;
INSERT INTO EAM_ASSET_STATUS_HISTORY(
ASSET_STATUS_ID,
ASSET_GROUP_ID,
ASSET_NUMBER,
ORGANIZATION_ID,
START_DATE,
END_DATE,
WIP_ENTITY_ID,
OPERATION_SEQ_NUM,
CREATED_BY,
CREATION_DATE,
LAST_UPDATED_BY,
LAST_UPDATE_DATE,
LAST_UPDATE_LOGIN,
attribute_category,
attribute1,
attribute2,
attribute3,
attribute4,
attribute5,
attribute6,
attribute7,
attribute8,
attribute9,
attribute10,
attribute11,
attribute12,
attribute13,
attribute14,
attribute15
,MAINTENANCE_OBJECT_TYPE
,MAINTENANCE_OBJECT_ID
,enable_flag -- Enhancemnet Bug 3852846
) VALUES (
l_status_id,
l_asset_group_id,
l_asset_number,
l_organization_id,
p_shutdown_start_date,
p_shutdown_end_date,
p_wip_entity_id,
p_operation_seq_num,
l_last_updated_by,
l_last_update_date,
l_last_updated_by,
l_last_update_date,
l_last_update_login,
p_attribute_category,
p_attribute1,
p_attribute2,
p_attribute3,
p_attribute4,
p_attribute5,
p_attribute6,
p_attribute7,
p_attribute8,
p_attribute9,
p_attribute10,
p_attribute11,
p_attribute12,
p_attribute13,
p_attribute14,
p_attribute15
,l_maintenance_object_type
,l_maintenance_object_id
,'Y' -- Enhancemnet Bug 3852846
);
end if; -- history insert
select DECODE(count(won.next_operation),0,'Y','N')
INTO l_is_last_operation
from wip_operation_networks won
where won.wip_entity_id = p_wip_entity_id and
won.prior_operation =p_operation_seq_num;
SELECT EAM_WORKFLOW_EVENT_S.NEXTVAL
INTO l_wf_event_seq
FROM DUAL;
l_parameter_list.DELETE;
select first_unit_start_date,last_unit_completion_date
into l_scheduled_start_date,l_scheduled_end_date
from wip_operations
where wip_entity_id=p_wip_entity_id
and operation_seq_num=p_operation_seq_num;
select max(actual_end_date)
into l_max_prior_end_date
from eam_op_completion_txns eoct,wip_operation_networks won
where eoct.wip_entity_id = p_wip_entity_id
and eoct.operation_seq_num=won.prior_operation
and won.wip_entity_id=eoct.wip_entity_id
and won.next_operation=p_operation_seq_num
and transaction_type=1
and transaction_id = (select max(transaction_id)
from eam_op_completion_txns
where wip_entity_id = p_wip_entity_id
and operation_seq_num = eoct.operation_seq_num
);