SELECT R.APPLICATION_ID,
       R.RESPONSIBILITY_ID,
       S.SECURITY_GROUP_ID,
       R.RESPONSIBILITY_NAME,
       S.SECURITY_GROUP_NAME
  FROM FND_RESPONSIBILITY_VL  R,
       FND_USER_RESP_GROUPS   U,
       FND_SECURITY_GROUPS_VL S
 WHERE U.USER_ID = :A00
   AND SYSDATE BETWEEN U.START_DATE AND NVL(U.END_DATE, SYSDATE)
   AND R.VERSION IN ('4', 'W')
   AND R.APPLICATION_ID = U.RESPONSIBILITY_APPLICATION_ID
   AND R.RESPONSIBILITY_ID = U.RESPONSIBILITY_ID
   AND SYSDATE BETWEEN R.START_DATE AND NVL(R.END_DATE, SYSDATE)
   AND U.SECURITY_GROUP_ID = S.SECURITY_GROUP_ID
   AND S.SECURITY_GROUP_ID >= 0
   AND S.SECURITY_GROUP_KEY = NVL(:A01, S.SECURITY_GROUP_KEY)
   AND R.RESPONSIBILITY_KEY = NVL(:A02, R.RESPONSIBILITY_KEY)
   AND R.APPLICATION_ID = NVL(:A03, R.APPLICATION_ID)
   AND NVL(FND_PROFILE.VALUE('NODE_TRUST_LEVEL'), 1) <=
       NVL(FND_PROFILE.VALUE_SPECIFIC('APPL_SERVER_TRUST_LEVEL',
           U.USER_ID, R.RESPONSIBILITY_ID,R.APPLICATION_ID), 1)
ORDER BY
  R.RESPONSIBILITY_NAME,
  S.SECURITY_GROUP_NAME;
