The following lines contain the word 'select', 'insert', 'update' or 'delete':
OR (p_validation_level = EAM_PROCESS_WO_PVT.G_OPR_UPDATE) then
x_return_status := FND_API.G_RET_STS_SUCCESS;
SELECT enable_workflow
INTO l_workflow_enabled
FROM EAM_ENABLE_WORKFLOW
WHERE MAINTENANCE_OBJECT_SOURCE =p_maint_obj_source;
SELECT EAM_SAFETY_WORKFLOW_ENABLED
INTO l_workflow_enabled
FROM WIP_EAM_PARAMETERS
WHERE organization_id =p_organization_id;
* Purpose : This will process create/update/delete on work permit
************************************************************/
PROCEDURE PROCESS_WORK_PERMIT
( p_bo_identifier IN VARCHAR2 := 'EAM'
, p_api_version_number IN NUMBER := 1.0
, p_init_msg_list IN BOOLEAN := FALSE
, p_commit IN VARCHAR2
, p_work_permit_header_rec IN EAM_PROCESS_SAFETY_PUB.eam_wp_header_rec_type
, p_permit_wo_association_tbl IN EAM_PROCESS_SAFETY_PUB.eam_safety_assoc_tbl_type
, p_permit_clearance_asso_tbl IN EAM_PROCESS_SAFETY_PUB.eam_safety_assoc_tbl_type
, x_work_permit_header_rec OUT NOCOPY EAM_PROCESS_SAFETY_PUB.eam_wp_header_rec_type
, x_return_status OUT NOCOPY VARCHAR2
, x_msg_count OUT NOCOPY NUMBER
, p_debug IN VARCHAR2
, p_output_dir IN VARCHAR2
, p_debug_filename IN VARCHAR2
, p_debug_file_mode IN VARCHAR2
)IS
l_api_name CONSTANT VARCHAR2(30) := G_PKG_NAME;
EAM_ERROR_MESSAGE_PVT.Translate_And_Insert_Messages
( p_mesg_token_Tbl => l_out_Mesg_Token_Tbl
, p_error_level => l_error_level
, p_entity_index => l_entity_index
);
EAM_ERROR_MESSAGE_PVT.Translate_And_Insert_Messages
( p_mesg_token_Tbl => l_out_Mesg_Token_Tbl
, p_error_level => l_error_level
, p_entity_index => l_entity_index
);
EAM_ERROR_MESSAGE_PVT.Translate_And_Insert_Messages
( p_mesg_token_Tbl => l_out_Mesg_Token_Tbl
, p_error_level => l_error_level
, p_entity_index => l_entity_index
);
CURSOR C IS SELECT EAM_WORK_PERMIT_S.NEXTVAL FROM SYS.DUAL;
IF (p_validation_level = EAM_PROCESS_WO_PVT.G_OPR_UPDATE) THEN
EAM_PERMIT_DEFAULT_PVT.Populate_NULL_Columns
( p_eam_wp_rec => l_work_permit_header_rec
, p_old_eam_wp_rec => l_old_work_permit_header_rec
, x_eam_wp_rec => l_out_work_permit_header_rec
);
OR (l_work_permit_header_rec.transaction_type=EAM_PROCESS_WO_PVT.G_OPR_UPDATE --workorder updated
AND NVL(l_old_work_permit_header_rec.pending_flag,'N') = 'N' --old status is not pending
--and old status is not same as new status
AND (l_old_work_permit_header_rec.status_type <>l_work_permit_header_rec.status_type)
)
) THEN
IF(WF_EVENT.TEST(l_status_pending_event) <> 'NONE') THEN
IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug ('Calling Wkflow required check API...') ; END IF;
CURSOR C IS SELECT EAM_SAFETY_ASSOCIATIONS_S.NEXTVAL FROM SYS.DUAL;
select status_type
into l_wo_status
from wip_discrete_jobs
where wip_entity_id = p_permit_wo_association_tbl(i).TARGET_REF_ID
and organization_id =p_organization_id;
select status_type
into l_permit_status
from EAM_WORK_PERMITS
where permit_id =p_work_permit_id
and organization_id =p_organization_id;
elsif (p_permit_wo_association_tbl(i).transaction_type = EAM_PROCESS_WO_PVT.G_OPR_UPDATE and
(l_wo_status not in (wip_constants.released, wip_constants.draft) or
l_permit_status not in (wip_constants.released, wip_constants.draft))) then
raise fnd_api.g_exc_unexpected_error;
SELECT EAM_SAFETYWORKFLOW_EVENT_S.NEXTVAL
INTO l_wf_event_seq
FROM DUAL;
INSERT INTO EAM_SAFETY_WORKFLOWS
(OBJECT_ID,TRANSACTION_ID,WORKFLOW_TYPE,LAST_UPDATE_DATE,LAST_UPDATED_BY,
CREATION_DATE,CREATED_BY,LAST_UPDATE_LOGIN)
VALUES
(p_eam_wp_rec.permit_id,l_wf_event_seq,3,SYSDATE,FND_GLOBAL.user_id,
SYSDATE,FND_GLOBAL.user_id,FND_GLOBAL.login_id
);
l_parameter_list.DELETE;
CURSOR C IS SELECT EAM_PERMIT_NAME_S.NEXTVAL FROM SYS.DUAL;
X_last_update_login => '',
X_program_application_id=> '',
X_program_id => '',
X_request_id => ''
);
EAM_ERROR_MESSAGE_PVT.Translate_And_Insert_Messages
( p_mesg_token_Tbl => l_out_Mesg_Token_Tbl
, p_error_level => l_error_level
, p_entity_index => l_entity_index
);