SQL 如下:
SELECT 'USER' ASSIGN_TYPE,
CASE
WHEN TRUNC(SYSDATE) BETWEEN FU.START_DATE AND
NVL(FU.END_DATE, TRUNC(SYSDATE)) THEN
FU.USER_NAME
ELSE
EEU.EU_USERNAME
END ASSIGN_TO,
FU.DESCRIPTION ASSIGN_TO_DESCRIPTION,
ED.DOC_NAME REPORT_NAME,
ED.DOC_DESCRIPTION REPORT_DESCRIPTION
FROM EUL10_US.EUL5_EUL_USERS EEU,
EUL10_US.EUL5_ACCESS_PRIVS EAP,
EUL10_US.EUL5_DOCUMENTS ED,
FND_USER FU
WHERE EAP.GD_DOC_ID = ED.DOC_ID
AND EAP.AP_EU_ID = EEU.EU_ID
AND EEU.EU_ROLE_FLAG = 0 --By User
AND TO_CHAR(FU.USER_ID) = SUBSTR(EEU.EU_USERNAME, 2)
UNION ALL
SELECT 'RESPONSIBILITY' ASSIGN_TYPE,
CASE
WHEN TRUNC(SYSDATE) BETWEEN R.START_DATE AND
NVL(R.END_DATE, TRUNC(SYSDATE)) THEN
R.RESPONSIBILITY_NAME
ELSE
EEU.EU_USERNAME
END USER_NAME,
R.DESCRIPTION,
ED.DOC_NAME,
ED.DOC_DESCRIPTION
FROM EUL10_US.EUL5_EUL_USERS EEU,
EUL10_US.EUL5_ACCESS_PRIVS EAP,
EUL10_US.EUL5_DOCUMENTS ED,
FND_RESPONSIBILITY_VL R
WHERE EAP.GD_DOC_ID = ED.DOC_ID
AND EAP.AP_EU_ID = EEU.EU_ID
AND EEU.EU_ROLE_FLAG = 1 --By Responisbility
AND TO_CHAR(R.RESPONSIBILITY_ID) =
SUBSTR(EEU.EU_USERNAME, 2, INSTR(EEU.EU_USERNAME, '#', 1, 2) - 2)
AND TO_CHAR(R.APPLICATION_ID) =
SUBSTR(EEU.EU_USERNAME, INSTR(EEU.EU_USERNAME, '#', 1, 2) + 1);
沒有留言:
張貼留言