SELECT DISTINCT OPR.OPRID , TMPL.AGC_TEMPLATE_ID , LST.PTAI_LIST_ID , LST.PTAI_PARENT_TMPL , LST.PTAI_LABEL FROM PS_AGC_TMPL_TBL TMPL , PSOPRDEFN OPR , PS_PTAI_LIST LST WHERE TMPL.AGC_TEMPLATE_ID = %Substring(LST.PTAI_PARENT_TMPL,1,7) AND (EXISTS ( SELECT 'X' FROM PS_PTAI_LIST_PRIV PRIV WHERE PRIV.PTAI_LIST_ID = LST.PTAI_LIST_ID AND PRIV.PTAI_PRIVSET_ID ='PTAI_CONTRIBUTOR' AND EXISTS ( SELECT 'X' FROM PSROLEUSER ROL WHERE ROL.ROLEUSER = OPR.OPRID AND ((PRIV.PTAI_MBR_TYPE = 'USER' AND PRIV.PTAI_MBR_NAME = ROL.ROLEUSER) OR (PRIV.PTAI_MBR_TYPE = 'ROLE' AND PRIV.PTAI_MBR_NAME = ROL.ROLENAME)))))
|