SELECT PA.AGENT_ID,
PAPF.FULL_NAME COMPRADOR,
PA.START_DATE_ACTIVE FECHA_INICIO,
PA.END_DATE_ACTIVE FECHA_FIN,
FU.USER_NAME USUARIO,
HAOUT.NAME ORGANIZACION_HR,
PAPF.EMAIL_ADDRESS CORREO,
PAPF.HONORS PUESTO
FROM PO.PO_AGENTS
PA,
HR.PER_ALL_PEOPLE_F PAPF,
APPLSYS.FND_USER FU,
HR.HR_ALL_ORGANIZATION_UNITS_TL HAOUT,
HR.PER_ALL_ASSIGNMENTS_F PAAF
WHERE PA.AGENT_ID = PAPF.PERSON_ID
AND FU.EMPLOYEE_ID(+) = PAPF.PERSON_ID
AND PAPF.PERSON_ID = PAAF.PERSON_ID(+)
AND HAOUT.LANGUAGE='ESA'
AND PAAF.ORGANIZATION_ID = HAOUT.ORGANIZATION_ID(+)
AND SYSDATE BETWEEN PAPF.EFFECTIVE_START_DATE AND
PAPF.EFFECTIVE_END_DATE
AND SYSDATE BETWEEN PAAF.EFFECTIVE_START_DATE AND
PAAF.EFFECTIVE_END_DATE
AND PAAF.ASSIGNMENT_TYPE = 'E'
AND PAAF.PRIMARY_FLAG = 'Y'
AND PAPF.FULL_NAME = '&COMPRADOR'
AND PA.END_DATE_ACTIVE IS NULL;