The following lines contain the word 'select', 'insert', 'update' or 'delete':
SELECT AW.workorder_name
FROM AHL_WORKORDERS AW
WHERE AW.WORKORDER_ID = p_workorder_id;
SELECT workorder_id
FROM AHL_WORKORDERS AWOS, WIP_DISCRETE_JOBS WIP,
ORG_ORGANIZATION_DEFINITIONS ORG
WHERE AWOS.WIP_ENTITY_ID = WIP.WIP_ENTITY_ID
AND AWOS.WORKORDER_NAME = p_workorder_name
AND WIP.ORGANIZATION_ID = ORG.ORGANIZATION_ID
AND ORG.ORGANIZATION_CODE = p_org_code;
SELECT AWO.STATUS_CODE
FROM AHL_WORKORDER_OPERATIONS AWO
WHERE AWO.WORKORDER_ID = p_workorder_id
AND AWO.operation_sequence_num = p_operation_seq_num
FOR UPDATE OF AWO.object_version_number;
SELECT AOR.OPERATION_RESOURCE_ID, WOR.start_date, WOR.completion_date,
(select wo1.department_id from wip_operations wo1
where wo1.wip_entity_id = aw.wip_entity_id
and wo1.operation_seq_num = p_operation_seq_num) department_id,
WOR.resource_seq_num
FROM WIP_OPERATION_RESOURCES WOR,
AHL_OPERATION_RESOURCES AOR, AHL_WORKORDER_OPERATIONS AWO, AHL_WORKORDERS AW,
BOM_RESOURCES BRS
WHERE AW.workorder_id = AWO.workorder_id
AND WOR.wip_entity_id = AW.wip_entity_id
AND WOR.RESOURCE_SEQ_NUM = AOR.RESOURCE_SEQUENCE_NUM
AND WOR.OPERATION_SEQ_NUM = AWO.OPERATION_SEQUENCE_NUM
AND AWO.operation_sequence_num = p_operation_seq_num
AND AWO.workorder_operation_id = AOR.workorder_operation_id
AND WOR.organization_id = BRS.organization_id
AND WOR.resource_id = AOR.resource_id
AND WOR.resource_id = BRS.resource_id
--AND WOR.operation_seq_num = p_operation_seq_num
AND BRS.resource_type = 2 -- person.
AND AW.workorder_id = p_workorder_id
AND WOR.resource_id = nvl(p_resource_id, WOR.resource_id)
AND WOR.resource_seq_num = nvl(p_resource_seq_num, WOR.resource_seq_num)
-- qualified.
AND EXISTS (SELECT 'x'
FROM mtl_employees_current_view pf,
bom_resource_employees bre,
bom_dept_res_instances bdri,
wip_operations wo,
bom_department_resources bdr
WHERE WO.wip_entity_id = AW.wip_entity_id
AND WO.operation_seq_num = AWO.operation_sequence_num
-- AND WO.department_id = bdri.department_id
AND nvl(bdr.share_from_dept_id,WO.department_id) = bdri.department_id
AND bdr.department_id = wo.department_id
AND bdr.resource_id = WOR.RESOURCE_ID
AND WOR.RESOURCE_ID= bdri.resource_id
AND bre.instance_id = bdri.instance_id
AND bre.resource_id = bdri.resource_id
AND bre.organization_id = WOR.organization_id
AND bre.person_id = pf.employee_id
AND pf.organization_id = bre.organization_id
AND bre.person_id = p_employee_id);
SELECT AWAS.Assignment_id, AWAS.object_version_number
FROM AHL_WORK_ASSIGNMENTS AWAS
WHERE AWAS.operation_resource_id = p_operation_resource_id
AND AWAS.employee_id = p_employee_id;
'Inserting into ahl_work_login_times.');
insert into ahl_work_login_times(
work_login_time_id,
workorder_id,
operation_seq_num,
resource_seq_num,
operation_resource_id,
employee_id,
login_date,
object_version_number,
login_level,
LAST_UPDATE_DATE,
LAST_UPDATED_BY,
CREATION_DATE,
CREATED_BY,
LAST_UPDATE_LOGIN)
values (
ahl_work_login_times_s.nextval,
p_workorder_id,
p_operation_seq_num,
p_resource_seq_num,
l_operation_resource_id,
p_employee_id,
sysdate,
1,
'R',
sysdate,
fnd_global.user_id,
sysdate,
fnd_global.user_id,
fnd_global.login_id
);
SELECT AWO.STATUS_CODE
FROM AHL_WORKORDER_OPERATIONS AWO
WHERE AWO.WORKORDER_ID = p_workorder_id
AND AWO.operation_sequence_num = p_operation_seq_num
FOR UPDATE OF AWO.object_version_number;
SELECT AOR.OPERATION_RESOURCE_ID, WOR.resource_seq_num, WOR.resource_id,
WOR.start_date, WOR.completion_date,
(select wo1.department_id from wip_operations wo1
where wo1.wip_entity_id = aw.wip_entity_id
and wo1.operation_seq_num = p_operation_seq_num) department_id
FROM WIP_OPERATION_RESOURCES WOR,
AHL_OPERATION_RESOURCES AOR, AHL_WORKORDER_OPERATIONS AWO, AHL_WORKORDERS AW,
BOM_RESOURCES BRS
WHERE AW.workorder_id = AWO.workorder_id
AND AWO.operation_sequence_num = p_operation_seq_num
AND WOR.wip_entity_id = AW.wip_entity_id
AND WOR.RESOURCE_SEQ_NUM = AOR.RESOURCE_SEQUENCE_NUM
AND WOR.OPERATION_SEQ_NUM = AWO.OPERATION_SEQUENCE_NUM
AND AWO.workorder_operation_id = AOR.workorder_operation_id
AND WOR.organization_id = BRS.organization_id
AND WOR.resource_id = AOR.resource_id
AND WOR.resource_id = BRS.resource_id
--AND WOR.operation_seq_num = p_operation_seq_num
AND BRS.resource_type = 2 -- person.
AND AW.workorder_id = p_workorder_id
-- qualified.
AND EXISTS (SELECT 'x'
FROM mtl_employees_current_view pf,
bom_resource_employees bre,
bom_dept_res_instances bdri,
wip_operations wo,
bom_department_resources bdr
WHERE WO.wip_entity_id = AW.wip_entity_id
AND WO.operation_seq_num = AWO.operation_sequence_num
--AND WO.department_id = bdri.department_id
AND nvl(bdr.share_from_dept_id,WO.department_id) = bdri.department_id
AND bdr.department_id = wo.department_id
AND bdr.resource_id = WOR.RESOURCE_ID
AND WOR.RESOURCE_ID= bdri.resource_id
AND bre.instance_id = bdri.instance_id
AND bre.resource_id = bdri.resource_id
AND bre.organization_id = WOR.organization_id
AND bre.person_id = pf.employee_id
AND pf.organization_id = bre.organization_id
AND bre.person_id = p_employee_id);
SELECT AWAS.Assignment_id, AWAS.object_version_number
FROM AHL_WORK_ASSIGNMENTS AWAS
WHERE AWAS.operation_resource_id = p_operation_resource_id
AND AWAS.employee_id = p_employee_id;
'Before inserting into ahl_work_login_times');
insert into ahl_work_login_times(
work_login_time_id,
workorder_id,
operation_seq_num,
resource_seq_num,
operation_resource_id,
employee_id,
login_date,
login_level,
object_version_number,
LAST_UPDATE_DATE,
LAST_UPDATED_BY,
CREATION_DATE,
CREATED_BY,
LAST_UPDATE_LOGIN)
values (
ahl_work_login_times_s.nextval,
p_workorder_id,
p_operation_seq_num,
null,
null,
p_employee_id,
sysdate,
1,
'O',
sysdate,
fnd_global.user_id,
sysdate,
fnd_global.user_id,
fnd_global.login_id);
SELECT AW.STATUS_CODE
FROM AHL_WORKORDERS AW
WHERE AW.WORKORDER_ID = p_workorder_id
FOR UPDATE OF AW.object_version_number;
SELECT AWO.STATUS_CODE
FROM AHL_WORKORDER_OPERATIONS AWO
WHERE AWO.WORKORDER_ID = p_workorder_id
FOR UPDATE OF AWO.object_version_number;
SELECT AOR.OPERATION_RESOURCE_ID, WOR.operation_seq_num, WOR.resource_id,
WOR.resource_seq_num, WOR.start_date, WOR.completion_date,
(select wo1.department_id from wip_operations wo1
where wo1.wip_entity_id = aw.wip_entity_id
and wo1.operation_seq_num = AWO.operation_sequence_num) department_id
FROM WIP_OPERATION_RESOURCES WOR,
AHL_OPERATION_RESOURCES AOR, AHL_WORKORDER_OPERATIONS AWO, AHL_WORKORDERS AW,
BOM_RESOURCES BRS
WHERE AW.workorder_id = AWO.workorder_id
AND WOR.wip_entity_id = AW.wip_entity_id
AND WOR.RESOURCE_SEQ_NUM = AOR.RESOURCE_SEQUENCE_NUM
AND WOR.OPERATION_SEQ_NUM = AWO.OPERATION_SEQUENCE_NUM
AND AWO.workorder_operation_id = AOR.workorder_operation_id
AND WOR.resource_id = AOR.resource_id
AND WOR.organization_id = BRS.organization_id
AND WOR.resource_id = BRS.resource_id
AND BRS.resource_type = 2 -- person.
AND AW.workorder_id = p_workorder_id
-- qualified.
AND EXISTS (SELECT 'x'
FROM mtl_employees_current_view pf,
bom_resource_employees bre,
bom_dept_res_instances bdri,
wip_operations wo,
bom_department_resources bdr
WHERE WO.wip_entity_id = AW.wip_entity_id
AND WO.operation_seq_num = AWO.operation_sequence_num
--AND WO.department_id = bdri.department_id
AND nvl(bdr.share_from_dept_id,WO.department_id) = bdri.department_id
AND bdr.department_id = wo.department_id
AND bdr.resource_id = WOR.RESOURCE_ID
AND WOR.RESOURCE_ID= bdri.resource_id
AND bre.instance_id = bdri.instance_id
AND bre.resource_id = bdri.resource_id
AND bre.organization_id = WOR.organization_id
AND bre.person_id = pf.employee_id
AND pf.organization_id = bre.organization_id
AND bre.person_id = p_employee_id);
SELECT AWAS.Assignment_id, AWAS.object_version_number
FROM AHL_WORK_ASSIGNMENTS AWAS
WHERE AWAS.operation_resource_id = p_operation_resource_id
AND AWAS.employee_id = p_employee_id;
'Before inserting into ahl_work_login_times');
insert into ahl_work_login_times(
work_login_time_id,
workorder_id,
operation_seq_num,
resource_seq_num,
operation_resource_id,
employee_id,
login_date,
object_version_number,
login_level,
LAST_UPDATE_DATE,
LAST_UPDATED_BY,
CREATION_DATE,
CREATED_BY,
LAST_UPDATE_LOGIN)
values (
ahl_work_login_times_s.nextval,
p_workorder_id,
null,
null,
null,
p_employee_id,
sysdate,
1,
'W',
sysdate,
fnd_global.user_id,
sysdate,
fnd_global.user_id,
fnd_global.login_id);
SELECT WLGN.workorder_id,
AW.workorder_name,
AW.wip_entity_id,
WLGN.operation_seq_num,
AOR.resource_id,
WLGN.resource_seq_num,
WLGN.login_level,
WLGN.login_date,
WLGN.work_login_time_id,
WLGN.object_version_number
FROM AHL_Operation_Resources AOR, AHL_WORKORDERS AW,
AHL_WORK_LOGIN_TIMES WLGN
WHERE WLGN.workorder_id(+) = AW.workorder_id
AND WLGN.operation_resource_id = AOR.operation_resource_id(+)
AND WLGN.employee_id(+) = c_employee_id
AND WLGN.login_date(+) IS NOT NULL
AND WLGN.logout_date(+) IS NULL -- employee logged in.
AND AW.workorder_id = c_workorder_id
FOR UPDATE OF WLGN.logout_date NOWAIT;
SELECT AW.STATUS_CODE, AW.workorder_name
FROM AHL_WORKORDERS AW
WHERE AW.WORKORDER_ID = p_workorder_id
FOR UPDATE OF AW.object_version_number;
SELECT AWO.STATUS_CODE
FROM AHL_WORKORDER_OPERATIONS AWO
WHERE AWO.WORKORDER_ID = p_workorder_id
FOR UPDATE OF AWO.object_version_number;
SELECT AWO.STATUS_CODE
FROM AHL_WORKORDER_OPERATIONS AWO
WHERE AWO.WORKORDER_ID = p_workorder_id
AND AWO.operation_sequence_num = p_operation_seq_num
FOR UPDATE OF AWO.object_version_number;
SELECT WOR.operation_seq_num, WOR.resource_id,
WOR.resource_seq_num, BRS.unit_of_measure uom_code,
WO.organization_id, WO.department_id
FROM wip_operations wo,
wip_operation_resources WOR,
bom_resources BRS
WHERE wo.wip_entity_id = WOR.wip_entity_id
AND wo.operation_seq_num = WOR.operation_seq_num
AND WOR.resource_id = BRS.resource_id
AND BRS.resource_type = 2 -- person.
AND wo.wip_entity_id = p_wip_entity_id
AND exists ( SELECT 'x'
FROM bom_resource_employees bre,
bom_dept_res_instances bdri,
bom_department_resources bdr
WHERE --WO.department_id = bdri.department_id
nvl(bdr.share_from_dept_id, WO.department_id) = bdri.department_id
AND bdr.department_id = WO.department_id
AND bdr.resource_id = WOR.RESOURCE_ID
AND bre.resource_id = WOR.RESOURCE_ID
AND bre.instance_id = bdri.instance_id
AND bre.resource_id = bdri.resource_id
AND bre.person_id = p_employee_id);
SELECT WOR.operation_seq_num, WOR.resource_id,
WOR.resource_seq_num, BRS.unit_of_measure uom_code,
WO.organization_id, WO.department_id
FROM wip_operations wo,
wip_operation_resources WOR,
bom_resources BRS
WHERE wo.wip_entity_id = WOR.wip_entity_id
AND wo.operation_seq_num = WOR.operation_seq_num
AND WOR.resource_id = BRS.resource_id
AND BRS.resource_type = 2 -- person.
AND wo.wip_entity_id = p_wip_entity_id
AND wo.operation_seq_num = p_operation_seq_num
AND exists ( SELECT 'x'
FROM bom_resource_employees bre,
bom_dept_res_instances bdri,
bom_department_resources bdr
WHERE --WO.department_id = bdri.department_id
nvl(bdr.share_from_dept_id, WO.department_id) = bdri.department_id
AND bdr.department_id = WO.department_id
AND bdr.resource_id = WOR.RESOURCE_ID
AND bre.resource_id = WOR.RESOURCE_ID
AND bre.instance_id = bdri.instance_id
AND bre.resource_id = bdri.resource_id
AND bre.person_id = p_employee_id);
SELECT WOR.operation_seq_num, WOR.resource_id,
WOR.resource_seq_num, BRS.unit_of_measure uom_code,
WO.organization_id, WO.department_id
FROM wip_operations wo,
wip_operation_resources WOR,
bom_resources BRS
WHERE wo.wip_entity_id = WOR.wip_entity_id
AND wo.operation_seq_num = WOR.operation_seq_num
AND WOR.resource_id = BRS.resource_id
AND BRS.resource_type = 2 -- person.
AND wo.wip_entity_id = p_wip_entity_id
AND wo.operation_seq_num = p_operation_seq_num
AND WOR.resource_seq_num = p_resource_seq_num
AND exists ( SELECT 'x'
FROM bom_resource_employees bre,
bom_dept_res_instances bdri,
bom_department_resources bdr
WHERE --WO.department_id = bdri.department_id
nvl(bdr.share_from_dept_id, WO.department_id) = bdri.department_id
AND bdr.department_id = WO.department_id
AND bdr.resource_id = WOR.RESOURCE_ID
AND bre.resource_id = WOR.RESOURCE_ID
AND bre.instance_id = bdri.instance_id
AND bre.resource_id = bdri.resource_id
AND bre.person_id = p_employee_id);
SELECT WOR.operation_seq_num, WOR.resource_id,
WOR.resource_seq_num, BRS.unit_of_measure uom_code
FROM wip_operations wo,
wip_operation_resources WOR,
bom_resources BRS
WHERE wo.wip_entity_id = WOR.wip_entity_id
AND wo.operation_seq_num = WOR.operation_seq_num
AND WOR.resource_id = BRS.resource_id
AND BRS.resource_type = 2 -- person.
AND wo.wip_entity_id = p_wip_entity_id;
SELECT WOR.operation_seq_num, WOR.resource_id,
WOR.resource_seq_num, BRS.unit_of_measure uom_code
FROM wip_operations wo,
wip_operation_resources WOR,
bom_resources BRS
WHERE wo.wip_entity_id = WOR.wip_entity_id
AND wo.operation_seq_num = WOR.operation_seq_num
AND WOR.resource_id = BRS.resource_id
AND BRS.resource_type = 2 -- person.
AND wo.wip_entity_id = p_wip_entity_id
AND wo.operation_seq_num = p_operation_seq_num;
SELECT WOR.operation_seq_num, WOR.resource_id,
WOR.resource_seq_num, BRS.unit_of_measure uom_code
FROM wip_operations wo,
wip_operation_resources WOR,
bom_resources BRS
WHERE wo.wip_entity_id = WOR.wip_entity_id
AND wo.operation_seq_num = WOR.operation_seq_num
AND WOR.resource_id = BRS.resource_id
AND BRS.resource_type = 2 -- person.
AND wo.wip_entity_id = p_wip_entity_id
AND wo.operation_seq_num = p_operation_seq_num
AND WOR.resource_seq_num = p_resource_seq_num;
SELECT WOR.resource_seq_num
FROM WIP_OPERATION_RESOURCES WOR
WHERE WOR.wip_entity_id = p_wip_entity_id
AND WOR.operation_seq_num = p_operation_seq_num
AND WOR.resource_id = p_resource_id;
UPDATE ahl_work_login_times
SET logout_date = sysdate,
object_version_number = l_object_version_number + 1
WHERE work_login_time_id = l_work_login_time_id;
SELECT employee_id
FROM FND_USER
WHERE USER_ID = p_user_id;
SELECT employee_id
FROM MTL_EMPLOYEES_CURRENT_VIEW
WHERE employee_num = p_employee_number
AND rownum < 2;
SELECT WLGN.workorder_id,
AW.workorder_name,
WLGN.operation_seq_num,
AOR.resource_id,
WLGN.resource_seq_num
FROM AHL_Operation_Resources AOR, AHL_WORKORDERS AW,
AHL_WORK_LOGIN_TIMES WLGN
WHERE WLGN.workorder_id = AW.workorder_id
AND WLGN.operation_resource_id = AOR.operation_resource_id(+)
AND WLGN.employee_id = c_employee_id
AND WLGN.logout_date IS NULL; -- employee logged in.
SELECT full_name
FROM MTL_EMPLOYEES_CURRENT_VIEW
WHERE employee_id = p_employee_id
AND rownum < 2;
SELECT wo.STATUS_CODE, wo.workorder_name, wo.wip_entity_id, we.organization_id
FROM AHL_WORKORDERS WO, WIP_ENTITIES WE
WHERE WO.wip_entity_id = we.wip_entity_id
AND WORKORDER_ID = p_workorder_id;
SELECT pf.employee_id
FROM mtl_employees_current_view pf
WHERE pf.employee_id = p_employee_id
AND pf.organization_id = p_org_id;
SELECT 'x'
FROM wip_operations wo
WHERE wo.wip_entity_id = p_wip_entity_id
AND not exists ( SELECT 'x'
FROM wip_operation_resources WOR,
bom_resources BRS,
bom_resource_employees bre,
bom_dept_res_instances bdri
WHERE wo.operation_seq_num = WOR.operation_seq_num
AND WOR.resource_id = BRS.resource_id
AND BRS.resource_type = 2 -- person.
AND WO.department_id = bdri.department_id
AND WOR.RESOURCE_ID= bdri.resource_id
AND bre.instance_id = bdri.instance_id
AND bre.resource_id = bdri.resource_id
AND bre.person_id = p_employee_id);
SELECT 'x'
FROM WIP_OPERATIONS WO
WHERE wip_entity_id = p_wip_entity_id
AND exists ( SELECT 'x'
FROM WIP_OPERATION_RESOURCES WOR, BOM_RESOURCES BRS
WHERE WOR.wip_entity_id = WO.wip_entity_id
AND WOR.operation_seq_num = WO.operation_seq_num
AND WOR.resource_id = BRS.resource_id
AND BRS.resource_type = 2 -- person.
);
SELECT 'x'
FROM wip_operations wo,
wip_operation_resources WOR,
bom_resources BRS
WHERE wo.wip_entity_id = WOR.wip_entity_id
AND wo.operation_seq_num = WOR.operation_seq_num
AND WOR.resource_id = BRS.resource_id
AND BRS.resource_type = 2 -- person.
AND wo.wip_entity_id = p_wip_entity_id
AND exists ( SELECT 'x'
FROM bom_resource_employees bre,
bom_dept_res_instances bdri
WHERE WO.department_id = bdri.department_id
AND WOR.RESOURCE_ID= bdri.resource_id
AND bre.instance_id = bdri.instance_id
AND bre.resource_id = bdri.resource_id
AND bre.person_id = p_employee_id)
GROUP BY WO.wip_entity_id, WO.Operation_seq_num
HAVING count(WOR.resource_seq_num) > 1;
SELECT 'x'
FROM wip_operations wo,
wip_operation_resources WOR,
bom_resources BRS
WHERE wo.wip_entity_id = WOR.wip_entity_id
AND wo.operation_seq_num = WOR.operation_seq_num
AND WOR.resource_id = BRS.resource_id
AND BRS.resource_type = 2 -- person.
AND wo.wip_entity_id = p_wip_entity_id
AND wo.operation_seq_num = p_operation_seq_num
AND exists ( SELECT 'x'
FROM bom_resource_employees bre,
bom_dept_res_instances bdri
WHERE WO.department_id = bdri.department_id
AND WOR.RESOURCE_ID= bdri.resource_id
AND bre.instance_id = bdri.instance_id
AND bre.resource_id = bdri.resource_id
AND bre.person_id = p_employee_id)
GROUP BY WO.wip_entity_id, WO.Operation_seq_num
HAVING count(WOR.resource_seq_num) > 1;
SELECT 'x' -- status_code
FROM AHL_WORKORDER_OPERATIONS
WHERE WORKORDER_ID = p_workorder_id
AND OPERATION_SEQUENCE_NUM = p_op_seq_num
AND status_code = 2 -- uncomplete
AND exists ( SELECT 'x'
FROM wip_operation_resources WOR, bom_resources BRS
WHERE WOR.wip_entity_id = p_wip_entity_id
AND WOR.operation_seq_num = p_op_seq_num
AND WOR.resource_id = BRS.resource_id
AND BRS.resource_type = 2 -- person.
);
SELECT 'x'
FROM wip_operations wo
WHERE wo.wip_entity_id = p_wip_entity_id
and wo.operation_seq_num = p_operation_seq_num
AND exists ( SELECT 'x'
FROM wip_operation_resources WOR,
bom_resources BRS,
bom_resource_employees bre,
bom_dept_res_instances bdri,
bom_department_resources bdr
WHERE WOR.operation_seq_num = wo.operation_seq_num
AND WOR.wip_entity_id = wo.wip_entity_id
AND WOR.resource_id = BRS.resource_id
AND wor.organization_id = brs.organization_id
AND BRS.resource_type = 2 -- person.
AND brs.resource_id = bre.resource_id
AND brs.organization_id = bre.organization_id
--AND WO.department_id = bdri.department_id
AND nvl(bdr.share_from_dept_id, WO.department_id) = bdri.department_id
AND bdr.department_id = WO.department_id
AND bdr.resource_id = WOR.RESOURCE_ID
AND WOR.RESOURCE_ID= bdri.resource_id
AND bre.instance_id = bdri.instance_id
AND bre.resource_id = bdri.resource_id
AND bre.person_id = p_employee_id);
SELECT 'x'
FROM wip_operations wo,
wip_operation_resources WOR
WHERE wo.wip_entity_id = WOR.wip_entity_id
AND wo.operation_seq_num = WOR.operation_seq_num
AND wo.wip_entity_id = p_wip_entity_id
AND WOR.operation_seq_num = p_operation_seq_num
AND WOR.resource_id = p_resource_id
AND not exists ( SELECT 'x'
FROM bom_resource_employees bre,
bom_dept_res_instances bdri,
bom_department_resources bdr
WHERE bre.resource_id = wor.resource_id
AND bre.organization_id = wor.organization_id
--AND WO.department_id = bdri.department_id
AND nvl(bdr.share_from_dept_id, WO.department_id) = bdri.department_id
AND bdr.department_id = WO.department_id
AND bdr.resource_id = WOR.resource_id
AND WOR.RESOURCE_ID= bdri.resource_id
AND bre.instance_id = bdri.instance_id
AND bre.resource_id = bdri.resource_id
AND bre.person_id = p_employee_id);
SELECT resource_id
FROM WIP_OPERATION_RESOURCES WOR
WHERE WOR.wip_entity_id = p_wip_entity_id
AND WOR.operation_seq_num = p_operation_seq_num
AND WOR.resource_seq_num = p_resource_seq_num;
SELECT resource_code
FROM BOM_RESOURCES
WHERE RESOURCE_ID = p_resource_id
AND organization_id = p_org_id
AND resource_type = 2;
SELECT 'x'
FROM AHL_WORKORDER_OPERATIONS
WHERE workorder_id = p_workorder_id
AND STATUS_CODE = '1' -- complete.
AND rownum < 2;
SELECT operation_seq_num
FROM WIP_OPERATIONS
WHERE wip_entity_id = p_wip_entity_id;
SELECT wo.STATUS_CODE, wo.workorder_name, wo.wip_entity_id, we.organization_id
FROM AHL_WORKORDERS WO, WIP_ENTITIES WE
WHERE WO.wip_entity_id = we.wip_entity_id
AND WORKORDER_ID = p_workorder_id;
SELECT 'x'
FROM WIP_OPERATIONS WO
WHERE wip_entity_id = p_wip_entity_id
AND exists ( SELECT 'x'
FROM WIP_OPERATION_RESOURCES WOR, BOM_RESOURCES BRS
WHERE WOR.wip_entity_id = WO.wip_entity_id
AND WOR.operation_seq_num = WO.operation_seq_num
AND WOR.resource_id = BRS.resource_id
AND BRS.resource_type = 2 -- person.
);
SELECT 'x' -- status_code
FROM AHL_WORKORDER_OPERATIONS
WHERE WORKORDER_ID = p_workorder_id
AND OPERATION_SEQUENCE_NUM = p_op_seq_num
AND status_code = 2 -- uncomplete
AND exists ( SELECT 'x'
FROM wip_operation_resources WOR, bom_resources BRS
WHERE WOR.wip_entity_id = p_wip_entity_id
AND WOR.operation_seq_num = p_op_seq_num
AND WOR.resource_id = BRS.resource_id
AND BRS.resource_type = 2 -- person.
);
SELECT 'x'
FROM wip_operations wo
WHERE wo.wip_entity_id = p_wip_entity_id
and wo.operation_seq_num = p_operation_seq_num
AND exists ( SELECT 'x'
FROM wip_operation_resources WOR,
bom_resources BRS,
bom_resource_employees bre,
bom_dept_res_instances bdri,
bom_department_resources bdr
WHERE WOR.operation_seq_num = wo.operation_seq_num
AND WOR.wip_entity_id = wo.wip_entity_id
AND WOR.resource_id = BRS.resource_id
AND wor.organization_id = brs.organization_id
AND BRS.resource_type = 2 -- person.
AND brs.resource_id = bre.resource_id
AND brs.organization_id = bre.organization_id
--AND WO.department_id = bdri.department_id
AND nvl(bdr.share_from_dept_id, WO.department_id) = bdri.department_id
AND bdr.department_id = WO.department_id
AND bdr.resource_id = WOR.RESOURCE_ID
AND WOR.RESOURCE_ID= bdri.resource_id
AND bre.instance_id = bdri.instance_id
AND bre.resource_id = bdri.resource_id
AND bre.person_id = p_employee_id);
SELECT 'x'
FROM wip_operations wo,
wip_operation_resources WOR
WHERE wo.wip_entity_id = WOR.wip_entity_id
AND wo.operation_seq_num = WOR.operation_seq_num
AND wo.wip_entity_id = p_wip_entity_id
AND WOR.operation_seq_num = p_operation_seq_num
AND WOR.resource_id = p_resource_id
AND not exists ( SELECT 'x'
FROM bom_resource_employees bre,
bom_dept_res_instances bdri,
bom_department_resources bdr
WHERE bre.resource_id = wor.resource_id
AND bre.organization_id = wor.organization_id
--AND WO.department_id = bdri.department_id
AND nvl(bdr.share_from_dept_id, WO.department_id) = bdri.department_id
AND bdr.department_id = WO.department_id
AND bdr.resource_id = WOR.resource_id
AND WOR.RESOURCE_ID= bdri.resource_id
AND bre.instance_id = bdri.instance_id
AND bre.resource_id = bdri.resource_id
AND bre.person_id = p_employee_id);
SELECT resource_id
FROM WIP_OPERATION_RESOURCES WOR
WHERE WOR.wip_entity_id = p_wip_entity_id
AND WOR.operation_seq_num = p_operation_seq_num
AND WOR.resource_seq_num = p_resource_seq_num;
SELECT resource_code
FROM BOM_RESOURCES
WHERE RESOURCE_ID = p_resource_id
AND organization_id = p_org_id
AND resource_type = 2;
SELECT 'x'
FROM AHL_WORKORDER_OPERATIONS
WHERE workorder_id = p_workorder_id
AND STATUS_CODE = '1' -- complete.
AND rownum < 2;
SELECT operation_seq_num
FROM WIP_OPERATIONS
WHERE wip_entity_id = p_wip_entity_id;
SELECT WLGN.workorder_id,
WLGN.operation_seq_num,
AOR.resource_id,
WLGN.resource_seq_num
FROM AHL_Operation_Resources AOR, AHL_WORK_LOGIN_TIMES WLGN
WHERE WLGN.operation_resource_id = AOR.operation_resource_id(+)
AND WLGN.employee_id = c_employee_id
AND WLGN.logout_date IS NULL;
SELECT WLGN.workorder_id,
WLGN.operation_seq_num,
AOR.resource_id,
WLGN.resource_seq_num
FROM AHL_Operation_Resources AOR, AHL_WORK_LOGIN_TIMES WLGN
WHERE WLGN.operation_resource_id = AOR.operation_resource_id(+)
AND WLGN.employee_id = c_employee_id
AND WLGN.logout_date IS NULL; -- employee logged in.