SELECT DISTINCT D.OPRID , A.SCC_TM_LIST_ID , A.SCC_TM_LABEL , A.PORTAL_NAME ,A.SCC_TM_PARENT_TMPL , ITML.SCC_TM_DUE_DATE , A.LAST_UPDATE_DTTM FROM PS_SCC_TM_PTAILIST A , PS_SCC_TM_CONFIG B , PSOPRDEFN D , PS_SCC_TM_PTAIITEM ITML WHERE A.SCC_TM_PARENT_TMPL = B.SCC_TM_TASK_ID AND A.SCC_TM_IS_TMPL='N' AND A.SCC_TM_LIST_STATUS ='CP' AND A.SCC_TM_LIST_ID = ITML.SCC_TM_LIST_ID AND ITML.SCC_TM_PTAI_SEQ = ( SELECT MAX(ITM1.SCC_TM_PTAI_SEQ) FROM PS_SCC_TM_PTAIITEM ITM1 WHERE A.SCC_TM_LIST_ID = ITM1.SCC_TM_LIST_ID ) AND (EXISTS ( SELECT 'X' FROM PS_SCC_TM_PTAILPRV F WHERE F.SCC_TM_LIST_ID = A.SCC_TM_LIST_ID AND EXISTS ( SELECT 'X' FROM PSROLEUSER X WHERE X.ROLEUSER = D.OPRID AND ((F.SCC_TM_PTAIMBRTYPE = 'USER' AND F.SCC_TM_PTAIMBRNAME = X.ROLEUSER) OR (F.SCC_TM_PTAIMBRTYPE = 'ROLE' AND F.SCC_TM_PTAIMBRNAME = X.ROLENAME))))) AND EXISTS ( SELECT 'X' FROM PS_SCC_TM_PTAICNTX cntx WHERE cntx.SCC_TM_LIST_ID =A.SCC_TM_LIST_ID AND cntx.SCC_TM_CTX_KEY='Y' AND cntx.FIELDNAME ='EMPLID' AND %Upper(cntx.SCC_TM_KEY_VALUE) = D.EMPLID)
|