On Tue, May 24, 2011 at 12:14:16PM +0000, Julian Einwag - rockenstein AG wrote: > > I just came across the query "visible_to_system" in SystemGroup_queries.xml: > > SELECT MAX(DECODE(VSGM.server_id, :sid, 1, 0)) is_system_member, > VSGM.GROUP_ID id, > VSGM.GROUP_NAME, > VSGM.GROUP_TYPE, > VSGM.CURRENT_MEMBERS, > VSGM.MAX_MEMBERS, > DECODE(USGP.server_group_id,VSGM.group_id,1,0) AS > USER_PERMITTED_ACCESS > FROM rhnVisServerGroupMembership VSGM, rhnUserServerGroupPerms USGP > WHERE VSGM.ORG_ID = :org_id > AND :user_id = USGP.user_id (+) > AND VSGM.group_id = USGP.server_group_id (+) > GROUP BY VSGM.group_id, VSGM.group_name, VSGM.group_type, > VSGM.current_members, VSGM.max_members, USGP.server_group_id > ORDER BY UPPER(VSGM.group_name), VSGM.group_id > > While I do understand that (+) is the old fashioned Oracle syntax for outer > joins, I'm having trouble understanding what the (+) does in the condition > ':user_id = USGP.user_id (+)', since it's not join-related. I did some quick > tests on an Oracle installation but I couldn't make sense of it. > > Any help would be appreciated.
Think of it as if you had ( select :user_id from dual ) and an outer join of this subselect with that USGP. The AND :user_id = USGP.user_id (+) matches where the USGP.user_id is the same as :user_id, or where the USGP's columns have NULL value due to the records not being present at all. You can try select web_customer.id, web_contact.id from web_customer, web_contact where web_customer.id = web_contact.id (+) and 1 = web_contact.id (+) to see something similar -- on my system it returns ID ID ---------- ---------- 1 1 2 3 4 5 25 26 46 66 -- Jan Pazdziora Principal Software Engineer, Satellite Engineering, Red Hat _______________________________________________ Spacewalk-devel mailing list Spacewalk-devel@redhat.com https://www.redhat.com/mailman/listinfo/spacewalk-devel