SELECT FU.USER_NAME,
PAPF.FULL_NAME,
PPD.SEGMENT1,
PPD.SEGMENT2,
SSSS.SEGMENT1,
SSSS.SEGMENT2,
SSSS.START_DATE_ACTIVE,
SSSS.END_DATE_ACTIVE,
FU.EMPLOYEE_ID,
SSSS.USER_ID
FROM
secom.oa_SECOM_SRP_SBC_SECURITY SSSS,
secom.oa_FND_USER FU,
secom.oa_PER_ALL_PEOPLE_F PAPF,
secom.oa_per_position_definitions ppd,
secom.oa_per_all_assignments_f PAA,
secom.oa_PER_ALL_POSITIONS P
where SSSS.USER_ID = FU.USER_ID AND PAPF.PERSON_ID(+) = FU.EMPLOYEE_ID AND
PAPF.PERSON_ID = PAA.PERSON_ID(+) AND
PAA.POSITION_ID = P.POSITION_ID AND
P.POSITION_DEFINITION_ID =PPD.POSITION_DEFINITION_ID AND
--PAA.POSITION_ID = PPD.POSITION_DEFINITION_ID(+) AND
SYSDATE BETWEEN PAPF.EFFECTIVE_START_DATE(+) AND
PAPF.EFFECTIVE_END_DATE(+) AND PAA.ASSIGNMENT_TYPE(+) = 'E' AND
SYSDATE BETWEEN PAA.EFFECTIVE_START_DATE(+) AND
PAA.EFFECTIVE_END_DATE(+) AND ( PPD.SEGMENT2 IN ('应用工程师','市场经理','技术总监','总监' ))
and (ssss.END_DATE_ACTIVE IS NULL OR ssss.END_DATE_ACTIVE>SYSDATE)
and ssss.segment1 like 'EMC%'
AND ((ssss.segment1='"+Args[0]+"' AND ssss.SEGMENT2='"+Args[1]+"') or
(ssss.segment1='"+Args[0]+"' AND ssss.segment2 is null))