Rev 2 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
/* User Roles */SELECT qry.*FROM (/* Get all applications to be able to group it */SELECT DISTINCTDECODE ( app.app_id, :APP_ID, '-',DECODE ( :APP_ID, 0, '-', '+')) AS expand,DECODE ( app.app_id, :APP_ID, app.app_id,0) AS order_id,app.app_id,app.application_name,TO_NUMBER(NULL) AS role_id,'-' AS role_name,'-' AS is_role_variation,NULL AS drill_down_imageFROM applications app,roles ro,user_roles urWHERE ur.role_id = ro.role_idAND ro.app_id = app.app_idAND ur.user_id = :USER_IDUNION/* Get applications that have no roles yet */SELECT '-' AS expand,0 AS order_id,app.app_id,app.application_name,TO_NUMBER(NULL) AS role_id,'-' AS role_name,'-' AS is_role_variation,NULL AS drill_down_imageFROM applications app,user_applications uaWHERE ua.user_id = :USER_IDAND app.app_id = ua.app_idAND app.app_id NOT IN(SELECT DISTINCT ua.app_idFROM user_applications ua, user_roles ur, roles roWHERE ur.user_id = ua.user_idAND ur.role_id = ro.role_idAND ro.app_id = ua.app_idAND ua.user_id = :USER_ID)UNION/* Get roles for specific application */SELECT DECODE ( app.app_id, :APP_ID, '-',DECODE ( :APP_ID, 0, '-', '+')) AS expand,DECODE ( app.app_id, :APP_ID, app.app_id,0) AS order_id,app.app_id,app.application_name,ro.role_id,ro.role_name,ro.is_role_variation,DECODE ( ro.is_role_variation, NULL, 'LIMG_DRILL_DOWN',NULL) AS drill_down_imageFROM applications app,roles ro,user_roles urWHERE ur.role_id = ro.role_idAND ro.app_id = app.app_idAND ur.user_ID = :USER_IDAND ( app.app_id = :APP_IDAND :APP_ID != 0)) qryORDER BY qry.order_id DESC, UPPER(qry.application_name), qry.is_role_variation, UPPER(qry.role_name)