Outer Join logic

The following code is an example of how to perform an outer join, in this case with ReportQuery (thanks Doug):
        ExpressionBuilder eb = new ExpressionBuilder();
        ReportQuery rq = new ReportQuery(Employee.class, eb);
        rq.addAttribute("firstName");
        rq.addAttribute("lastName");
        rq.addAttribute("areaCode", eb.anyOfAllowingNone("phoneNumbers").get("areaCode"));
        List<ReportQueryResult> results =  (List<ReportQueryResult>) session.executeQuery(rq);My question is about the logic Toplink uses to generate the outer join statement with the "(+)" in the generated sql.
Does Toplink only generate the join statement if the same attribute is chosen in the select statement (in the above example "areaCode")?
Along the same line of questioning, does it matter which attribute was in the get() call? So, in the above example did it have to be areaCode, or could it have been any other attribute of phoneNumber, and it still would have performed the join?
In my case, because the selection attributes are built up dynamicly, should I add all attributes of my child class (my equivalent PhoneNumber class)?

Thanks for your reply Doug.
One last question, hopefully.
I have a parent table with 2 child tables. When attempting an outer join with both, toplink does not attempt to outer join either. I understand why, sort of - as you get an error when attempting this in sqlplus with "(+)" syntax.
I understand that you can outer join > 1 other table to a parent with ansi sql syntax:
    select dept.*,emp.*
    from dept left outer join emp
    on dept.deptno = emp.deptnoWill toplink allow > 1 child table outer join to a parent table?

Similar Messages

  • OBIEE not applying outer join syntax to filters

    (Note: I've already thoroughly searched the forums before posting this. Thanks)
    My problem is the following:
    I'm trying to build a report that is a count from my fact table, grouped by month from my date dimension for a given year, resulting in 12 data points. The problem is that not all months have actual data, but I still need those months to show on the report with a count of zero. Typical simple reporting requirement.
    I have already done the obvious and within my business layer made the join between my fact table and my date dimension an outer join on the fact side, just like you'd do if writing the query by hand. And when tested by hand this includes all dates for the year anyway, and when coupled with the appropriate null test on the count measure I'd get my 12 data points with zeros were appropriate.
    The problem is that there are additional filters I need to apply on the fact data (there are a couple text-based code values that didn't warrant full tables themselves so are just degenerate dimensions directly on the fact table.)
    When these filters are applied at the Answer level, I'm only getting back the months that actually have data, and lose the months where the count should be zero. A check of the session log for the query that was generated shows the problem. While OBI properly generates the outer-join syntax for the join itself between the two tables (my date dim and fact table) it does NOT apply the outer-syntax to the constant-based filter against the fact, effectively negating the outer join.
    Actual query from the log (I simply changed the table aliases from the ugly T##### stuff OBI generates to something more readable for posting here):
    select D.DT_MONTH_NAME as c1,
    D.DT_MONTH_NUM as c2,
    I.INC_TYPE as c3,
    I.INC_EMP_GROUP as c4,
    sum(case when I.INC_KEY is null then 0 else 1 end ) as c5
    from DATE_DIM D, INCIDENT_F I
    where ( D.DATE_KEY = I.DATE_KEY (+) ) and ( D.DT_YEAR = 2010 and I.INC_EMP_GROUP = 'CONTRACTOR' )
    group by D.DT_MONTH_NUM, D.DT_MONTH_NAME, I.INC_TYPE, I.INC_EMP_GROUP
    order by c2
    You can see that the outer syntax (+) is applied to the join, but not to the filter on I.INC_EMP_GROUP. If I take this query and drop it in something like SQL Developer, it only returns the months with data. If I throw the (+) after I.INC_EMP_GROUP like I'd do if writing this by hand, the desired zero-months results pop back in.
    I have already searched the forums and while lots of people seem to have asked this question, the only solutions involve things like trickery in the business layer using dummy fact tables followed by manipulations at the report level etc. Unfortunately I can't rely on these as the system is eventually to be turned over to users who can't be expected to apply various hacks to write reports.
    Anyone ever get to the bottom of getting OBI to apply outer join logic in filters as well, when the filtered table is meant to be outer-joined to?
    Any comments are appreciated.
    John

    I know that this thread is a bit old thought it might be helpful to some one...
    The Issue is, when using Degener@teDimen$ion ( this is !nner joned to FACT tables in BMM) and if any of the dimensions {other than theDegener@teDimen$ion (Let us say Dim X) } have an ()uter join to any of the fact tables, and you were doing your analysis using Degener@teDimen$ion,  Dim X, Measure value you will face the following issues.
    when filtering the analysis on the ()uter join dimension ( Dim X), the IN filter will not work. Reason is that the filter is getting applied to both the Dimension and FACT tables and the values that exist in Dimension Dim X but not in FACT table wont show up.
         The above issue can be fixed by changing the join between the fact and Degener@teDimen$ion from inner to outer. I think this is a bug.. because  it is supposed to filter the fact  table after the entire outer joined result is obtained but not filter the fact table for the Dim X values and do a outer join. I think the BI should be intelligent enough.

  • Need to specify LEFT OUTER JOIN while using data from logical database BRM?

    I'm trying to extract data for external processing using SQVI. The fields required are in tables BKPF (Document Header) and BSEG (document detail) so I'm using logical database BRM. Note: required fields include the SPGR* (blocking reasons) which don't appear to be in BSIS/BSAS/BSID/BSAD/BSIK/BSAK, hence I can't just use a Table Join on any of these but have to use BSEG, hence BRM.
    If the document type is an invoice, I also need to include the PO number from table EKKO (PO header), if present, hence I'd like to add this to the list. However, if I do this, it seems that some records are no longer display, e.g. AB documents.
    The interesting thing is that not all records are suppressed, so it's not a simple case of the logical database using an effective INNER JOIN, but the effect is similar.
    In any event, is there a way to specify that the link to table EKKO should be treated as an effective LEFT OUTER JOIN, i.e. records from BKPF/BSEG should be included irrespective of whether any records from EKKO/EKPO exist or not?
    Alternatively, is there some other way to get the SPGR* fields (for example) from BSEG and still join the BKPF? Of course, one solution is to use multiple queries, but I was hoping to avoid this.

    Thanks for everyone's responses, I know how to work around the problem with sql, I am wanting to see if there is a way to make the outer joins filter go in the join clause instead of the where clause with Crystal Reports standard functionality. 
    We have some Crystal Reports users that are not sql users, i.e. benefit specialists, payroll specialists and compensation analysts who have Crystal Reports.  I was hoping this functionality was available for them.  I just made my example a simple one, but often reports have multiple outer joins with maybe 2 or three of the outer joins needing a filter on them that won't make them into an inner join. 
    Such as
    Select person information
    outer join address record
    outer join email record
    outer join tax record (filter for active state record & filter for code = STATE )
    outer join pay rates record
    outer join phone#s  (filter for home phone#)
    I thought maybe the functionality may be available, that I just don't know how or where to use it.  Maybe it is just not available.
    If it is not available, I will probably need to setup some standard views for them to query, rather than expecting them to pull the tables together themselves.

  • Handling Outer Join for hard coded values in the Logical Table Source

    Has anyone tried to apply an outer join in the Logical Table Source Content Tab?
    I have to add this APPLSYS.FND_LOOKUP_VALUES.LANGUAGE (+)= 'US' but the outer join is not allowed. I get this message.... [nQSError: 27002] Near <(>: Syntax error [nQSError: 26012] .
    Could you tell me please how this should be handled? I have a lot of this cases in my project and without this being set-up affects the expected output of my report.
    Thank you in advance.

    hi Ap,
    Pull only Dim_W_LOV_D_Acty_Src column into answers and check whether u r able to see CUST_SRC_ACT or not .Of course, you need to check sql query too
    Thanks,
    Saichand.v

  • Left Outer Join in Logical Layer

    Dear Gurus,
    I have report like this:
    Absent
    3 31
    Month-Name
    Jan 1 2
    Feb
    March
    I use Master Date as dimension and Transactional Absent as fact
    How if I want to show the date (from 1 to 31) even if there's no transaction?
    How to use driving table and join in the business logical?or there is another alternatif?
    Please help
    Regards
    Maria

    Hi,
    If you want to show all the transactions for the month, even if there is no transactions then you need to use the outer joins present in the BMM layer. Left, right and full outer joins according to your requirement. Driving tables are used when the number of the data is low to pick up the table.
    Hope this helped/ answered.
    Regards
    MuRam

  • Outer join between logical tables

    Hello,
    This question is likely to be asked many times, but I failed to find the proper thread in the forum.
    Assume there are 2 logical tables "Fact" and "Dim".
    "Fact" has 1 LTS which consists of physical tables F, FX1, FX2 which are inner joined.
    "Dim" has 1 LTS which consists of physical tables D, DX1, DX2 which are inner joined.
    F and D tables are also joined together on physical layer.
    I define left outer join between "Fact" and "Dim" on logical layer.
    I create a request in Answers, querying columns from "Fact" and "Dim" which map to physical tables F and D only.
    I expect OBIEE to build SQL query which uses F and D tables only, outer joined.
    Instead of that all the physical tables used for logical tables "Fact" and "Dim" are joined together in a form like:
    SELECT F.col, D.col
    FROM (F inner join FX1 inner join FX2) left outer join (D inner join DX1 inner join DX2)
    Is there any way to avoid this behavior or build data model in different way?
    Thank you!

    Hi Alex,
    In BI Applications you never have a null in a facts foreign key to the dimension. Instead there is always a zero row wi record inserted with 'Unspecified' in all the columns. When the fact table is populated in the ETL, if the fact record doesn't have a corresponding dimension record the WID is poulated with zero.
    This removes the problems with outer joins and helps considerably with performance.
    This could be one practice you take from BI Apps and put into your own ETL's and data model.
    Regards
    Robin

  • Problem with outer join with filter on join column

    Hi,
    In physical layer I have one dimension and two facts, and there's an outer join between the facts.
    dim_DATE ,
    fact_1 ,
    fact_2
    Joins:
    dim_DATE inner join fact_1 on dim_DATE.DATE = fact_1.DATE
    fact_1 left outer join fact_2 on fact_1.DATE = fact_2.DATE and fact_1.SOME_ID = fact_2.SOME_ID
    When I run a report with a date as a filter, OBIEE executes "optimized" physical SQL:
    select fact1.X, fact2.Y
    from
    Fact_1 left outer join on fact_1.DATE = fact_2.DATE and fact_1.SOME_ID = fact_2.SOME_ID
    where Fact_1.DATE = TO_DATE('2009-05-28' , 'YYYY-MM-DD' )
    and  Fact_2.DATE = TO_DATE('2009-05-28' , 'YYYY-MM-DD')
    The filter on Fact_2.DATE effectively replaces outer join with inner.
    Is there a way to disable this "optimization", which is actually very good for inner joins, but doesn't allow outer joins?
    Thanks in advance,
    Alex
    Edited by: AM_1 on Aug 11, 2009 8:20 AM

    If you want to perform a Fact-based partitioning with OBIEE (two fact with the same dimension), you have to :
    * create in your physical layer for each fact table the joins with the dimension
    * create in the Business Model layer ONE star schema with ONE logical fact table containing the columns of your two physical fact table
    In this way when you choose minimal one column of your fact1 and one column of your fact2, OBIEE will perform two query against each fact table/dimension, join them with an OUTER JOIN and your problem will disappear.
    Cheers
    Nico

  • Custom report outer-join display problem

    I have written a custom report for Grid that produces info on database options, combined with info on the hardware of the servers where the databases reside. It is a customer requirement that all output be displayed as one huge table, with duplicate cells where logic dictates... so I've used a couple of nested queries + outer joins.
    My SQL query provides the correct data, however Grid appears to be acting clever, and instead of displaying one big table with duplicate values where required, it is splitting the output into a series of tables.
    It might look neater, but it's not what I've been asked to provide.
    Is there anything I can do to prevent this, and force Grid to display the info as one table?
    Thanks,
    Chris

    Hello Chris,
    did you already try to create a View based on your query and use this view in a Report Element?
    Regards
    Rob
    For more info, tips and tricks on oem gc check: http://oemgc.wordpress.com

  • How do I use OUTER JOIN to email different message than the default

    I have a devotional that goes out daily from a MOBILE table containing:
    mob_id
    calendardate
    title
    scripture
    body
    The same devotional goes out to 3 different churches.
    I have a second TABLE called EDITED that holds an edited version of the daily devotional, containing:
    edit_id
    calendardate
    etitle
    escripture
    ebody
    The query should look in the edited table for a devotional first to see if it matches the current date then send it out. Otherwise it sends out the default devotional  that corresponds with the current date.
    I would like to send out in replacement of the default devotional  to the church that edited the devotional.
    I am using the following outer Join but it doesn’t work. It sends the same devotional to everybody.
    <cfoutput>
    <cfloop query="getClients">
    <!--- determine if there is an edited version of the devotional available for this day --->
    <cfquery name="getDevotional" datasource="#application.dsn#">
    SELECT mobile.mob_id, mobile.display_date, mobile.title, mobile.body, mobile.scripture,edited.edit_id,edited.contact_id,edited.etitle,edited.escripture,edited. ebody
    FROM mobile
    left outer join edited ON mobile.display_date = edited.display_date
    where mobile.display_date = <cfqueryparam value ="#dateformat(now(), "YYYY-MM-DD")#" cfsqltype="cf_sql_date">
    </cfquery>
    What am I missing?

    Yes the getClients grabs all information pertaining to the client and their layout information.
    <cfquery name="getClients" datasource="#application.dsn#">
    select *
    from (subscriber INNER JOIN contacts ON subscriber.contact_id = contacts.contact_id)INNER JOIN layout ON contacts.contact_id = layout.contact_id
    where subscriber.timezone = 3
    </cfquery>
    Below is the logic I used to determine which version to use:
    <cfif getDevotional.edit_id NEQ "">#GetDevotional.etitle#<cfelse>#GetDevotional.title#</cfif>

  • How to use OUTER JOIN in Oracle Answers Filters?

    Hi, I need to have a filter on an 'Oracle Answers' report.
    The query from the NQQuery.log appears as below. (I have simplified the SELECT clause here for easy reading)
    SELECT t692.enquiry_business_route AS c1,
    t692.enquiry_id AS c11, t913.YEAR AS c12,
    t913.full_date AS c13, t666.surname AS c14,
    t666.post_code AS c15, t855.company_name AS c16,
    t983.notes AS c30
    FROM
    mkt_dw_enev_enhi_dim t983,
    mkt_dw_key_partner_dim t855,
    mkt_dw_event_type_dim t821,
    mkt_dw_customer_dim t666,
    mkt_dw_time_dim t913,
    mkt_dw_enquiry_event_fact t692
    WHERE (
    t692.enquiry_id = t983.enqu_id
    AND t666.customer_dim_key = t692.customer_dim_key
    AND t692.event_date_time_key = t913.time_dim_key
    AND TRUNC(t983.event_date)= t913.FULL_DATE
    AND t692.event_type = t821.event_type_dim_key
    AND t692.key_partner_dim_key = t855.key_partner_dim_key
    AND t821.event_type_category = 'RECEIVE_FEE'
    AND t913.YEAR = 2009
    and t692.enquiry_id = 535986
    For the following two lines I would like to have the OUTER JOIN.
    AND t692.event_type = t821.event_type_dim_key(+)
    AND t821.event_type_category(+) = 'RECEIVE_FEE' (THIS IS THE FILTER CONDITION, AT THE MOMENT IT DOESN'T WORK WITH OUTER JOIN SYMBOL)
    Please could you let me know the best way of achieving the above.
    Thanks
    Srikanth

    In the BMM layer in the join condition you will be able to specify the join to be (left, right or full outer join).
    You can even add the required table in the LTS(logical table source) and also specify a left, right or full outer join there as well.
    There is an interesting work around as mentioned in the below blog to get to the Outer join results with out changing anything in rpd but in Answers.
    http://obiee101.blogspot.com/2008/11/obiee-outerjoin-workaround.html
    Hope it helps
    Thanks
    prash

  • Outer Join with Where Clause in LTS

    HI all,
    I have a requirement like this in ANSI SQL:
    select p1.product_id, p1.product_name, p2.product_group
    from product p1 left outer join product_group p2 on p1.product_id = p2.product_id
    and p2.product_group = 'NEW'
    In Regular SQL:
    select p1.product_id, p1.product_name, p2.product_group
    from product p1, product_group p2
    WHERE p1.product_id *= p2.product_id and p2.product_group = 'NEW'
    In OBIEE, I am using a left outer join between these two in Logical table Source, and also, Gave
    p2.product_group = 'NEW' in WHERE clause of LTS.
    This doesn't seem to solve purpose.
    Do you have any idea how to convert WHERE clause in physical query that OBIEE is generating to something like
    product p1 left outer join product_group p2 on p1.product_id = p2.product_id AND p2.product_group = 'NEW'
    I am using Version 10.1.3.4.1
    Creating an Opaque view would be my last option though.

    Hello
    I have read your post and the responses as well. and I understand that you have issues with the Outer Join with where Clause in LTS.
    Try this solution which worked for me (using your example ) -
    1. In the Physical Layer created a Complex join between PRODUCT and PRODUCT_GROUP tables and use this join relationship :
    PRODUCT.PROD_ID = PRODUCT_GROUP.PROD_ID  AND  PRODUCT_GROUP.GROUP_NAME = 'MECHANICAL' 
    2. In the General Tab of PRODUCT table LTS add PRODUCT_GROUP  table and select Join Type as Left Outer Join.
    3. Check Consistency and make sure there are no errors .
    when you run a request you should see the following query generated -
    select distinct T26908.PROD_ID as c1,
         T26908.PROD_NAME as c2,
         T26912.GROUP_NAME as c3
    from
         PRODUCT T26908 left outer join PRODUCT_GROUP T26912 On T26908.PROD_ID = T26912.PROD_ID and T26912.GROUP_NAME = 'MECHANICAL'
    order by c1, c2, c3
    Hope this works for you. If it does please mark this response as 'Correct' .
    Good Luck.

  • Key-lookup on SCD II does not generate complete outer join

    Using OWB 10.2.0.3
    In a mapping to populate a fact table, I have to join two source tables (inner join). After that I have to perform a number of lookups on dimension objects to retrieve the dimension keys I want to store in my fact table. These dimensions are all SCD type II. All lookups are performed on the detail level of each dimension.
    In the generated code, the join condition is an outer join. However, the condition that OWB generates to determine the correct level of the dimension is an inner join:
    SELECT
    FROM
    "TMI_CELLEN_ACT" "TMI_CELLEN_ACT",
    "DIM_TMI_BESTEMMINGEN" "KL_DIM_TMI_BESTEMMINGEN"
    WHERE
    ( "KL_DIM_TMI_BESTEMMINGEN"."BEST_CODE" (+) = "TMI_CELLEN_ACT"."BESTEMMINGSCODE" ) AND
    ( ( "KL_DIM_TMI_BESTEMMINGEN"."BEST_ID" IS NULL ) OR
    ( "KL_DIM_TMI_BESTEMMINGEN"."BEST_ID" = "KL_DIM_TMI_BESTEMMINGEN"."DIMENSION_KEY" ) ) AND
    ( ( "KL_DIM_TMI_BESTEMMINGEN"."EFFECTIVE_DATE" IS NULL ) OR
    ( ( "KL_DIM_TMI_BESTEMMINGEN"."EXPIRATION_DATE" IS NOT NULL ) AND
    ( TO_DATE ( trunc(sysdate) ) >= "KL_DIM_TMI_BESTEMMINGEN"."EFFECTIVE_DATE" ) AND
    ( TO_DATE ( trunc(sysdate) ) <= "KL_DIM_TMI_BESTEMMINGEN"."EXPIRATION_DATE" ) ) OR
    ( ( "KL_DIM_TMI_BESTEMMINGEN"."EXPIRATION_DATE" IS NULL ) AND
    ( TO_DATE ( trunc(sysdate) ) >= "KL_DIM_TMI_BESTEMMINGEN"."EFFECTIVE_DATE" ) ) )
    In my case, this results in an empty data set.
    When using ANSI sql, the 'level-conditions' are generated as a WHERE-clause, which also results in an empty data set. When this code is included in the LEFT OUTER JOIN clause, all my data is there.
    What is going on here?
    Thanks
    Paul

    The "clever" workaround is to use a joiner, which is the way we implement the key lookup. So simply use that.
    To just explain why we limit the key-lookup. The main reason is that this operator is cardinality neutral. That means we always expect it to return one and only one row. If we give you too much flexibility we increase the risk of getting more than one row back which would break the logic for the mapping.
    Hope this makes sense, but just go with the joiner.
    Thanks,
    Jean-Pierre

  • How to poll a blob using db adapter, with outer joins condition

    Hi All,
    We are trying to poll tables which contain column types as long and blob, we are using relationships in adapter and kept outer joins. by this we got select distinct t1.document .....etc
    distinct keyword cannot be used for blobs.
    is there any way to poll these tables having blob column types with outer joins.
    thanks a lot in advance,
    RR

    Hi,
    Procedure will be an explicit Invoke not Polling. If you can alter you design such that your BPEL process instead of polling gets triggered by some external entity (Java, PL/SQL, Scheduler, another BPEL etc.), you can put the data fetching logic in the procedure and call this procedure from your BPEL process to get the data. And your BPEL process is called periodically at an interval by an external entity.
    Also see if you can restrict the duplicate records at the database level itself. Polling, AFAIK, is limited in terms of customization and wouldn't be easy to customize. However, would like to learn a way if someone has.
    Regards,
    Neeraj Sehgal

  • How to understand the way OBIEE implements outer joins?

    Hello guys
    I have a few scenarios where I have to implement outer joins and inner joins between dimensions and facts..
    There are 2 ways as far as I know that allows me to implement outer joins in BMM layer.
    1, Join the Logical dim table A to Logical Fact table B using outer join. The modeling will look like the below:
    A Dim ---outer------B fact -----------inner----C Dim
    By this design, the query that selects columns from all 3 tables will look at this:
    select columns from ((B fact inner joins C on key1 = key2) left outer joins on A dim) on key3=key4)..
    2, Join logical dim table A to fact table B inside the LTS of fact B by mapping the LTS B to dim A using outer join. then join fact B to C:
    B fact (mapped to fact B outer join Dim A) ------------inner -------C dim
    By this design, the query that selects columns from all 3 tables will look at this instead:
    select columns from C, B left outer join A on key1=key2 where key3=key4
    Comparing these 2 queries, the first one seems to do inner joins first and then outer join the result set to Dim A, the second query seems to outer join Dim A first and the result set inner joins to Dim C..
    I ran the same report using these 2 different designs, and the data comes out very different. The report of the first query is much smaller than the report of the second query...
    Can anyone help me understand how OBIEE understands outer joins? The second query is so far giving the right result, however, I can't get rid of the outer join in the query even if not selecting columns from Dim A, which is impacting the performance of other reports without Dim A.
    Your inputs will be greatly appreciated
    Thanks
    Edited by: user7276913 on Apr 20, 2010 9:31 AM
    Edited by: user7276913 on Apr 20, 2010 9:31 AM

    Xcode is the IDE.
    Objective-C is the language typically used.
    There's lots of getting started stuff at https://developer.apple.com

  • Left outer join using multiple table

    Hi,
    I am trying to use left outer join with multiple tables , the join condition will be based on  PERNR and BEGDA & ENDA for each infotype in selection screen.
      select pa00~pernr pa00~begda pa00~endda pa00~massn pa00~massg pa00~stat2 pa00~aedtm pa00~uname
        pa01~begda pa01~endda pa01~bukrs pa01~persg pa01~persk pa01~mstbr pa01~ename pa01~aedtm pa01~uname
        pa02~begda pa02~endda pa02~nachn pa02~vorna pa02~midnm pa02~aedtm pa02~uname
        pa016~begda pa016~endda pa016~cttyp pa016~aedtm pa016~uname
        into CORRESPONDING FIELDS OF TABLE i_pall
        from  ( PA0000 as pa00 left OUTER JOIN pa0001 as pa01 on pa00~pernr = pa01~pernr )
        left OUTER JOIN pa0002 as pa02 on pa00~pernr eq pa02~pernr )
        left OUTER JOIN  pa0016 as pa016 on pa00~pernr eq pa016~pernr )
        where pa00~pernr in S_pernr
        AND pa00~begda in s_bg0000
        and pa00~endda in s_nd0000.
    but this fails  to fetch the value of begda enda from each pa0000,pa0001,pa0002,pa0016.
    Please help!
    Monirul

    Why don't you use the standard logical database PNPCE and then Provide statement?

Maybe you are looking for