Entity Framework : Outer Joins

Hello,
I'm trying to solve some issues with an application that I'm developing....
I have a problem with outer joins:
var query = (from i in dbo.ITEMs
                         join o in dbo.ORGANIZATIONs on i.ORGSEQNO equals o.ORGSEQNO
                         join iv in dbo.ITEMVERSIONs on i.ITEMSEQNO equals iv.ITEMSEQNO
                         join it in dbo.ITEMTARGETs on iv.VERSIONSEQNO equals it.VERSIONSEQNO
                         join id in dbo.ITEMDESCRIPTIONs.DefaultIfEmpty() on it.ITEMTARGETSEQNO equals id.ITEMTARGETSEQNO
                         select i).AsQueryable();
If I remove the DefaultIfEmpty the query works as expected, with the "DefaultIfEmpty" in, it generates a sub-select that doesn't execute.
1 ORA-00904: "SingleRowTable3"."X": invalid identifier SQL1.sql 44 23
This is the occorring error.
Thanks for your help.

You can check my thread Entity Framework generates invalid oracle sql.
Generally Entity Framework sometimes generates joins using APPLY which does not work on NON SQL SERVER system.

Similar Messages

  • Calling Oracle stored procedure with out param of user define type from Entity Framework 5 with code first

    Guys i am using Entity Framework 5 code first (I am not using edmx) with Oracle and all works good, Now i am trying to get data from stored procedure which is under package but stored procedure have out param which is user define type, Now my question is
    how i will call stored procedure from entity framework
    Thanks in advance.

    I agree with you, but issue is we have lots of existing store procedure, which we need to call where damn required. I am sure those will be few but still i need to find out.
    If you think you are going to get existing MS Stored Procedures  or Oracle Packages that had nothing to do with the ORM previously to work that are not geared to do simple CRUD operations with the ORM and the database tables, you have a rude awakening
    coming that's for sure. You had better look into using ADO.NET and Oracle Command objects and call those Oracle Packages by those means and use a datareader.
    You could use the EF backdoor, call Oracle Command object and use the Packages,  if that's even possible, just like you can use MS SQL Server Stored Procedures or in-line T-SQL via the EF backdoor.
    That's about your best shot.
    http://blogs.msdn.com/b/alexj/archive/2009/11/07/tip-41-how-to-execute-t-sql-directly-against-the-database.aspx

  • Entity framework TPT does not work - showstopper

    Greetings,
    I'm experiencing a similar problem that is described here:
    [Entity Framework and inheritance - Possible bug in EF?|http://stackoverflow.com/questions/11506683/entity-framework-and-inheritance-possible-bug-in-ef.]
    I'm using:
    Windows 7 64 bit
    ODAC 11.2 Release 5 32 bit
    Oracle Express 11.2 on localhost
    Visual Studio 2012
    Entity framework 5.0
    .net 4.5
    Create a simple database with TPT inheritance:
    CREATE TABLE Person(
    Id NUMBER(38, 0) NOT NULL,
    Name VARCHAR2(50),
    CONSTRAINT PK100 PRIMARY KEY (Id)
    CREATE TABLE Employee(
    Id NUMBER(38, 0) NOT NULL,
    JobTitle VARCHAR2(50),
    CONSTRAINT PK101 PRIMARY KEY (Id)
    ALTER TABLE Employee ADD CONSTRAINT ref_Employee_person
    FOREIGN KEY (Id)
    REFERENCES Person(Id)
    CREATE TABLE Superhero(
    Id NUMBER(38, 0) NOT NULL,
    Superpower VARCHAR2(50),
    CONSTRAINT PK102 PRIMARY KEY (Id)
    ALTER TABLE Superhero ADD CONSTRAINT ref_Superhero_person
    FOREIGN KEY (Id)
    REFERENCES Person(Id)
    -- Sequence
    CREATE SEQUENCE seq_id
    INCREMENT BY 1
    START WITH 55
    MINVALUE 1
    MAXVALUE 9999999999999999999999999999
    NOCYCLE
    NOORDER
    CACHE 20
    CREATE OR REPLACE TRIGGER PERSON_BI BEFORE INSERT ON PERSON FOR EACH ROW
    BEGIN IF :NEW.ID IS NULL THEN SELECT SEQ_ID.NEXTVAL INTO :NEW.ID FROM DUAL; END IF; END;
    Create a console application, add an edmx file, set up inheritance like so:
    Diagram
    And I set the Id property in Person entity as StoreGeneratedPattern to Identity
    Then I created the following program:
    static void Main(string[] args)
    //Employee
    var db = new Entities();
    EMPLOYEE e = new EMPLOYEE() { ID = 0, JOBTITLE = "Programmer"};
    e.NAME = "John Regular Doe";
    db.People.Add(e);
    //Superhero
    SUPERHERO s = new SUPERHERO();
    s.NAME = "Superman";
    s.SUPERPOWER = "Flight";
    db.People.Add(s);
    db.SaveChanges();
    //Fetch all persons and look at the type
    //this is where I get an error:
    var allPeople = db.People.ToList();
    allPeople.ForEach(x => Console.WriteLine("type: " + x.GetType()));
    This throws the following error when I fetch into allPeople:
    All objects in the EntitySet 'Entities.People' must have unique primary keys. However, an instance of type 'TestingTPTInheritance.EMPLOYEE' and an instance of type 'TestingTPTInheritance.SUPERHERO' both have the same primary key value, 'EntitySet=People;ID=38'.
    Looking at the database everything looks fine
    -- Person table --
    ID     NAME
    39     John Regular Doe
    40     Superman
    -- Employee table --
    ID     JOBTITLE
    39     Programmer
    -- Superhero table --
    ID     SUPERPOWER
    40     Flight
    If I take the select that EF generates in " db.People.ToList();" and run it I get the following result:
    C1      C2     NAME      C3      C4
    0X0X     40     Superman           
    0X0X     39     John Regular Doe     Programmer     
    Is this a bug in ODAC. If so is there a workaround or will there be a fix soon?
    Edited by: Amplus on 7.11.2012 07:59

    Thank you for the reply shsu
    I was being careless when I copied the error message and sequence, sorry about that. I did run this serveral times after I copied the error message. I recreate the seqence starting with 1 and recreated the problem. The error message is:
    All objects in the EntitySet 'Entities.People' must have unique primary keys. However, an instance of type 'TestingTPTInheritance.EMPLOYEE' and an instance of type 'TestingTPTInheritance.SUPERHERO' both have the same primary key value, 'EntitySet=People;ID=2'.
    The data in the tables is:
    Person:
    ID     NAME
    1      John Regular Doe
    2      Superman
    employee
    ID     JOBTITLE
    1      Programmer
    Superhero
    ID     SUPERPOWER
    2      Flight
    And the generated select is:
    SELECT
    CASE WHEN (( NOT (("Project1"."C2" = 1) AND ("Project1"."C2" IS NOT NULL))) AND ( NOT (("Project2"."C2" = 1) AND ("Project2"."C2" IS NOT NULL)))) THEN '0X' WHEN (("Project1"."C2" = 1) AND ("Project1"."C2" IS NOT NULL)) THEN '0X0X' ELSE '0X1X' END AS "C1",
    CAST( "Extent1"."ID" AS number(19,0)) AS "C2",
    "Extent1"."NAME" AS "NAME",
    CASE WHEN (( NOT (("Project1"."C2" = 1) AND ("Project1"."C2" IS NOT NULL))) AND ( NOT (("Project2"."C2" = 1) AND ("Project2"."C2" IS NOT NULL)))) THEN NULL WHEN (("Project1"."C2" = 1) AND ("Project1"."C2" IS NOT NULL)) THEN "Project1"."JOBTITLE" END AS "C3",
    CASE WHEN (( NOT (("Project1"."C2" = 1) AND ("Project1"."C2" IS NOT NULL))) AND ( NOT (("Project2"."C2" = 1) AND ("Project2"."C2" IS NOT NULL)))) THEN NULL WHEN (("Project1"."C2" = 1) AND ("Project1"."C2" IS NOT NULL)) THEN NULL ELSE "Project2"."SUPERPOWER" END AS "C4"
    FROM "TPT"."PERSON" "Extent1"
    LEFT OUTER JOIN (SELECT
    "Extent2"."JOBTITLE" AS "JOBTITLE",
    CAST( "Extent2"."ID" AS number(19,0)) AS "C1",
    1 AS "C2"
    FROM "TPT"."EMPLOYEE" "Extent2" ) "Project1" ON ( CAST( "Extent1"."ID" AS number(19,0))) = "Project1"."C1"
    LEFT OUTER JOIN (SELECT
    "Extent3"."SUPERPOWER" AS "SUPERPOWER",
    CAST( "Extent3"."ID" AS number(19,0)) AS "C1",
    1 AS "C2"
    FROM "TPT"."SUPERHERO" "Extent3" ) "Project2" ON ( CAST( "Extent1"."ID" AS number(19,0))) = "Project2"."C1"
    With the following result:
    C1      C2     NAME      C3      C4
    0X0X     2      Superman      null      null --> should't there be a "Flight" entry here??
    0X0X     1      John Regular Doe     Programmer     null
    I also tried this:
    var result1 = db.People.OfType<SUPERHERO>().ToList(); //Count=1
    var result2 = db.People.OfType<EMPLOYEE>().ToList(); //Count=1
    var result3 = db.People.OfType<PERSON>().ToList(); //Throws the following error:
    All objects in the EntitySet 'Entities.People' must have unique primary keys. However, an instance of type 'TestingTPTInheritance.EMPLOYEE' and an instance of type 'TestingTPTInheritance.SUPERHERO' both have the same primary key value, 'EntitySet=People;ID=2'.
    The only thing I can think of is that my little console app is picking up the oracle client from oracle express instead of the ODAC driver. Is there an easy way to force it to use the correct driver? I have this in my config file but I'm not sure if it works:
    <oracle.dataaccess.client>
    <settings>
    <add name="DllPath" value="C:\oracle\product\11.2.0\client_3\bin" />
    </settings>
    </oracle.dataaccess.client>
    And I have also referenced Oracle.Data.Access here:
    C:\oracle\product\11.2.0\client_3\odp.net\bin\4\Oracle.DataAccess.dll
    client_3 directory is my ODAC Release 5 installation. I changed the config settings to:
    <oracle.dataaccess.client>
    <settings>
    <add name="DllPath" value="C:\oracle\product\11.2.0\client_3\odp.net\bin\4\Oracle.DataAccess.dll" />
    </settings>
    </oracle.dataaccess.client>
    then the program was able to run this line:
    var allPeople = db.People.ToList();
    But both objects were of type EMPLOYEE. Then I ran this:
    var result1 = db.People.OfType<SUPERHERO>().ToList();
    and get the following error:
    All objects in the EntitySet 'Entities.People' must have unique primary keys. However, an instance of type 'TestingTPTInheritance.EMPLOYEE' and an instance of type 'TestingTPTInheritance.SUPERHERO' both have the same primary key value, 'EntitySet=People;ID=2'.
    The problem must be that I do have multiple versions of Oracle client installed on my computer and it is picking up the wrong one either when I'm generating the edmx file or when the application is connecting to the db. I think my next step will be to uninstall all oracle client instances as well as oracle express and try again from scratch!!

  • Entity framework code first inheritance table per type problem

    hello
    i am using ODP.NET version 11.2.0.3.20. i am trying to get entity framework code first to work. one problem i have encountered is with inheritance. i have a "table per type" inheritance scenario. i have 3 tables involved. the base table is called "S_PERIOD" which maps to the base "Period" class. i have a derived table called "S_SEASON_QUARTER" that maps to the derived "Quarter" class. And I have another derived table called "S_SEASON_PRICE_PERIOD" that maps to the derived "PriceBreak" class. for testing purposes i am trying to load all records. the problem is that every class instance ends up being of type "Quarter", which is incorrect. for whatever reason the provider thinks that every "S_PERIOD" record has a corresponding "S_SEASON_QUARTER" record. i took a look at the generated SQL and posted it down below. looking at this SQL it's clear to me why every object ends up being of type "Quarter". It looks like the provider is checking the "C2" field to determine the concrete type to instantiate. the problem however is that the "C2" field value provided by each derived table is ALWAYS equal to "1", which is a problem since this will result in the "case" statement always hitting the second "when" condition. does anyone have any idea how to fix this? thank you
    SELECT
    CASE WHEN (( NOT (("Project1"."C2" = 1) AND ("Project1"."C2" IS NOT NULL))) AND ( NOT (("Project2"."C2" = 1) AND ("Project2"."C2" IS NOT NULL)))) THEN '0X' WHEN (("Project1"."C2" = 1) AND ("Project1"."C2" IS NOT NULL)) THEN '0X0X' ELSE '0X1X' END AS "C1",
    CAST( "Extent1"."PERIOD_ID" AS number(10,0)) AS "C2",
    "Extent1"."START_DATE" AS "START_DATE",
    "Extent1"."END_DATE" AS "END_DATE",
    "Extent1"."NAME" AS "NAME",
    "Extent1"."TYPE_CODE" AS "TYPE_CODE",
    CAST( "Extent1"."CREATE_USER_ID" AS number(10,0)) AS "C3",
    "Extent1"."CREATE_DATE" AS "CREATE_DATE",
    CAST( "Extent1"."MODIFY_USER_ID" AS number(10,0)) AS "C4",
    "Extent1"."MODIFY_DATE" AS "MODIFY_DATE",
    CASE WHEN (( NOT (("Project1"."C2" = 1) AND ("Project1"."C2" IS NOT NULL))) AND ( NOT (("Project2"."C2" = 1) AND ("Project2"."C2" IS NOT NULL)))) THEN NULL WHEN (("Project1"."C2" = 1) AND ("Project1"."C2" IS NOT NULL)) THEN "Project1"."QUARTER_NAME" END AS "C5"
    FROM "DBO_SPACE_DEV"."S_PERIOD" "Extent1"
    LEFT OUTER JOIN (SELECT
         "Extent2"."QUARTER_NAME" AS "QUARTER_NAME",
         CAST( "Extent2"."QUARTER_ID" AS number(10,0)) AS "C1",
         1 AS "C2"
         FROM "DBO_SPACE_DEV"."S_SEASON_QUARTER" "Extent2" ) "Project1" ON ( CAST( "Extent1"."PERIOD_ID" AS number(10,0))) = "Project1"."C1"
    LEFT OUTER JOIN (SELECT
         CAST( "Extent3"."PRICE_PERIOD_ID" AS number(10,0)) AS "C1",
         1 AS "C2"
         FROM "DBO_SPACE_DEV"."S_SEASON_PRICE_PERIOD" "Extent3" ) "Project2" ON ( CAST( "Extent1"."PERIOD_ID" AS number(10,0))) = "Project2"."C1"
    Edited by: 997830 on Apr 3, 2013 8:40 AM

    An update:
    I tried again following this example to the letter:
    Using NuGet to Install and Configure Oracle Data Provider for .NET
    This time I used a console application as described in the example. Yes, I rebuilt the project after the NuGet install.
    I made the appropriate mods to App.config. I get the same error message as with the MVC example above.
    Does the ODP.Net driver really work with EF? If so, can anyone provide me with a working sample project?

  • Entity Framework doesn't save new record into database

    Hy,
    I have problem with saving new record into database using Entity Framework.
    When I run program, everything seems normal, without errors . Program shows existing, manually added records into the database, and new one too. But new one isn't save into database after running program.
    I've got no idea where's problem. There is code for add new record, show existing.
    Thanks for help!!
    // add new record
    using (var db=new DatabaseEntitiesContext())
    var person = new Table()
    First_Name = "New_FName",
    Second_Name = "New_SName",
    PIN = "4569"
    db.Tables.Add(person);
    db.SaveChanges();
    //show all records
    using (var db=new DatabaseEntitiesContext())
    var selected = from x in db.Tables
    select x;
    foreach (var table in selected)
    Console.WriteLine("{0}{1}{2}",table.First_Name,table.Second_Name,table.PIN);

    Hi BownieCross;
    If you are using a local database file in your project the following may be the cause.
    From Microsoft Documentation:
    Issue:
    "Every time I test my application and modify data, my changes are gone the next time I run my application."
    Explanation:
    The value of the Copy
    to Output Directory property is Copy
    if newer or Copy
    always. The database in your output folder (the database that’s being modified when you test your application) is overwritten every
    time that you build your project. For more information, see How
    to: Manage Local Data Files in Your Project.
    Fernando (MCSD)
    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".
    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects
    and unknown namespaces.

  • Issues with limit/filter on outer join table in BQY

    I'm converting a series of BQY's from Brio 6.6 to Hyperion 9.3. I have some questions about the "use ODBC outer join syntax on limits" option in the OCE. I sort of understand this option's purpose, but I don't completely understand the SQL I'm seeing. For example Brio 6.6 is generating the following SQL statement:
    SELECT * FROM tblA AL1 LEFT OUTER JOIN tblB AL38 ON (AL38.ParentID=AL1.ChildID AND
    AL38.Data='SomeData') WHERE ((NOT AL38.Action IS NULL))
    Now, Hyperion 9.3 generated the SQL statement as follows:
    SELECT * FROM tblA AL1 LEFT OUTER JOIN tblB AL38 ON (AL38.ParentID=AL1.ChildID AND
    AL38.Data='SomeData') AND (NOT AL38.Response IS NULL))
    My questions are:
    1) Why isn't the "NOT AL38.Action IS NULL" statement included in the outer join in Brio? My limited understanding of the "use ODBC outer join syntax on limits" seems to indicate that it should end up there. I want the SQL to look like this, but I don't know why Brio generates this SQL.
    2) How can I get Hyperion to generate the same SQL as Brio? And still use the OCE with "use ODBC outer join syntax on limits" selected?

    Setting the Cardinality of Department > Employee role to OptionalOne
    gives rise to cartesian join (which is a bigger issue).
    Therefore, the Cardinality of Department > Employee role should remain as
    OptionalMany (default).
    This means, the outer join problem still remains unsolved. I have, therefore,
    unmarked the above answer by me.
    The question is - why has Report Builder been designed in such a way that the primary entity is always the child entity when attributes are selected from both parent and child entities?
    Most people desire that all the rows of the parent entity be fetched irrespective of whether there are corresponding rows in the child entity or not. Report Builder tool should not dictate what the user wants to get, meaning it is not right to assume
    that the focus of the report is Employee when attributes are selected from both Department and Employee. Report Builder should not make the child entity (i.e., Employee) as the primary entity when the user selects attributes from the child entity after
    having selected attributes from the parent entity.
    I am sorry to say that clients may not accept the Report Builder tool as this does not fetch the records as desired.
    I hope there is someone who can suggest how the outer join problem can be solved by just tweaking the properties of the report model (SMDL).
    Besides, the end users are business users and are not tech savvy. They are not expected to modify queries. They would simply drag and drop attributes from entities to create adhoc reports.

  • 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

  • Need help further tuning view source for outer join

    I have been working on tuning views for use in Discoverer for some time, and I have greatly improved upon what was there, but it is still not where I need it to be. There are 2 views the users join together in Discoverer - one for contract lines, and one for contract flexfields. Run as a 1 to 1 join on contract number, performance is great. However, as soon as I have an outer join on flexfields, the performance is awful. We are talking a difference of under a minute to hours and hours. I have to be able to perform an outer join because there can be contracts without flexfields. Can anyone suggest an alternative method to get the data or further tuning? I will paste both the contract lines and contract flexfields source - I have tuned the flexfields but have done nothing to date with the lines.
    CREATE OR REPLACE VIEW XXDBD_CONTRACT_FLEXFIELDS AS
    SELECT core.contract_id, core.service_id, core.contract_number, core.service_line, core.service, core.product_line, core.equipment, core.UL_Certificate_And_End_Date, core.MAF, core.Termination_Penalty_Percentage, core.multi_year, core.multi_year_effective_dates, core.terms_multi_year, core.SerLineRenPricingMethod, core.ren_line_change, core.zone, core.add_invoice_display, core.add_subgrouping, re.diebold_price, attr.coverage_hours, attr.reaction_times, attr.resolution_times, attr.repair_times, tr.performance_requirement, attr.penalty, attr.penalty_amount, attr.penalty_bonus, attr.mon_break_start, attr.mon_break_end, attr.tues_break_start, attr.tues_break_end, attr.wed_break_start, attr.wed_break_end, attr.thu_break_start, attr.thu_break_end, attr.fri_break_start, attr.fri_break_end, attr.sat_break_start, attr.sat_break_end, attr.sun_break_start, attr.sun_break_end, attr.split_covering, attr.cash_handling
    FROM (SELECT aa.ID Contract_id,
    aa.contract_number,
    dd.id Service_ID ,
    dd.cle_id dd_cle_id,
    dd.line_number service_line,
    xxdbd_Disco_Service_Contract.GetServNameInv
    (dd.id) Service,
    dd.line_number ||'.'||ee.line_number Product_Line,
    xxdbd_Disco_Service_Contract.GetEqpNoInvoice(ee.id)
    Equipment,
    DECODE(dd.attribute_category,'Service Contracts',
    NVL(xxdbd_Disco_Service_Contract.GetContractMasterProperty('DBD_OKS_50_CHARS', dd.attribute1),dd.attribute1),'') UL_Certificate_And_End_Date,
    dd.attribute2 MAF,
    DECODE(dd.attribute_category,'Service Contracts',NVL(xxdbd_Disco_Service_Contract.GetContractMasterProperty('DBD_OKS_NUMERIC', dd.attribute3),dd.attribute3),'') Termination_Penalty_Percentage,
    DECODE(dd.attribute_category,'Service Contracts', DECODE(NVL(xxdbd_Disco_Service_Contract.GetContractMasterProperty('DBD_OKS_MULTIYEAR', dd.attribute5),dd.attribute5),
    'N','No Multi-Year',
    'Y','Multi-Year, Years not Known',
    'Y1','Multi-Year for 1 Year',
    'Y2','Multi-Year for 2 Year',
    'Y3','Multi-Year for 3 Year',
    'Y4','Multi-Year for 4 Year',
    'Y5','Multi-Year for 4 Year',dd.attribute5),'')Multi_Year,
    dd.attribute4 Multi_Year_Effective_Dates,
    DECODE(dd.attribute_category,'Service Contracts', NVL(xxdbd_Disco_Service_Contract.GetContractMasterProperty('DBD_OKS_450_CHARS', dd.attribute9),dd.attribute9),'') Terms_Multi_Year,
    DECODE(dd.attribute_category,'Service Contracts', DECODE(NVL(xxdbd_Disco_Service_Contract.GetContractMasterProperty('DBD_OKS_RENEWAL_PRICING', dd.attribute6),dd.attribute6),
    'MP', 'DBD Markup Percent',
    'CP', 'DBD Contract Price',
    'AI', 'DBD Amount Increase',
    'AD', 'DBD Amount Decrease',
    'TA', 'DBD Target Amount',
    'FR', 'DBD Flat Rate',dd.attribute6),'') SerLineRenPricingMethod,
    DECODE(dd.attribute_category,'Service Contracts', NVL(xxdbd_Disco_Service_Contract.GetContractMasterProperty('DBD_OKS_NUMERIC', dd.attribute7),dd.attribute7),'') Ren_Line_Change,
    DECODE(dd.attribute_category,'Service Contracts', DECODE(NVL(xxdbd_Disco_Service_Contract.GetContractMasterProperty('DBD_OKS_ZONE', dd.attribute8),dd.attribute8),
    'DNA1','DNA Zone 1',
    'DNA2','DNA Zone 2',
    'DNA3','DNA Zone 3',
    'BRAZIL1','Brazil Zone 1 (50 KM)',
    'BRAZIL2','Brazil Zone 2 (80 KM)',
    'BRAZIL3','Brazil Zone 3 (200 KM)',dd.attribute8),'')Zone,
    DECODE(dd.attribute11, 'N','None','SC','Sub Component', 'SN', 'Serial Number', 'SNSC', 'Serial Number and Sub-Component') Add_Invoice_Display,
    DECODE(dd.attribute10, 'SI','Service Item', 'CP','Covered Product', 'PC','Product Category') Add_SubGrouping,
    dd.attribute12 Diebold_Price,
    ee.id ee_id,
    ee.cle_id ee_cle_id
    FROM okc_k_headers_b aa,
    okc_k_lines_b dd,
    okc_k_lines_b ee
    -- xxdbd_temp_flex_contract tfc
    WHERE aa.id = dd.DNZ_CHR_ID
    AND dd.CLE_ID IS NULL
    AND dd.id = ee.cle_id
    AND ee.DNZ_CHR_ID = aa.id
    AND ee.LSE_ID =9
    AND dd.LSE_ID =1
    -- and aa.contract_number = 'NL0000014'
    -- and aa.contract_number in (select contract_number from xxdbd_flex_contract)
    -- AND tfc.contract_number = aa.contract_number
    ) core,
    (SELECT h.contract_number,
    DECODE(l.attribute_category,
    'Coverage Break', xxdbd_get_sib_cont_id(xxdbd_get_parent_cle_id(l.cle_id,2)),
    'Business Process',xxdbd_get_sib_cont_id(xxdbd_get_parent_cle_id(l.cle_id,1)),
    'Coverage Template Header',xxdbd_get_sib_cont_id(l.cle_id),
    'Transaction Type', xxdbd_get_sib_cont_id(xxdbd_get_parent_cle_id(l.cle_id,2)),null) ee_id,
    DECODE(l.attribute_category, 'Business Process', l.attribute1) Coverage_Hours,
    DECODE(l.attribute_category, 'Business Process', l.attribute2) Reaction_Times,
    DECODE(l.attribute_category, 'Business Process', l.attribute3) Resolution_Times,
    DECODE(l.attribute_category, 'Business Process', l.attribute4) Repair_Times,
    DECODE(l.attribute_category, 'Business Process', DECODE(l.attribute5,
    'RA', 'REACTION'
    , 'RS', 'RESOLUTION'
    , 'RR', 'REACTION & RESOLUTION'
    , 'NR', 'NO REQUIREMENT',
    l.attribute5)) Performance_Requirement,
    DECODE(l.attribute_category, 'Coverage Template Header', l.attribute1) Penalty,
    DECODE(l.attribute_category, 'Coverage Template Header', l.attribute2) Penalty_Amount,
    DECODE(l.attribute_category, 'Coverage Template Header', l.attribute3) Penalty_Bonus,
    DECODE(l.attribute_category, 'Coverage Break', l.attribute1) Mon_Break_Start,
    DECODE(l.attribute_category, 'Coverage Break', l.attribute2) Mon_Break_End,
    DECODE(l.attribute_category, 'Coverage Break', l.attribute3) Tues_Break_Start,
    DECODE(l.attribute_category, 'Coverage Break', l.attribute4) Tues_Break_End,
    DECODE(l.attribute_category, 'Coverage Break', l.attribute5) Wed_Break_Start,
    DECODE(l.attribute_category, 'Coverage Break', l.attribute6) Wed_Break_End,
    DECODE(l.attribute_category, 'Coverage Break', l.attribute7) Thu_Break_Start,
    DECODE(l.attribute_category, 'Coverage Break', l.attribute8) Thu_Break_End,
    DECODE(l.attribute_category, 'Coverage Break', l.attribute9) Fri_Break_Start,
    DECODE(l.attribute_category, 'Coverage Break', l.attribute10) Fri_Break_End,
    DECODE(l.attribute_category, 'Coverage Break', l.attribute11) Sat_Break_Start,
    DECODE(l.attribute_category, 'Coverage Break', l.attribute12) Sat_Break_End,
    DECODE(l.attribute_category, 'Coverage Break', l.attribute13) Sun_Break_Start,
    DECODE(l.attribute_category, 'Coverage Break', l.attribute14) Sun_Break_End,
    DECODE(l.attribute_category, 'Transaction Type', l.attribute1) Split_Covering,
    DECODE(l.attribute_category, 'Transaction Type', l.attribute2) Cash_Handling
    from okc_k_lines_b l , okc_k_headers_b h--, xxdbd_temp_flex_contract tfc
    where l.attribute_category in ('Coverage Break', 'Business Process', 'Coverage Template Header','Transaction Type')
    and h.id = l.dnz_chr_id
    -- and h.contract_number in (select contract_number from xxdbd_flex_contract)
    -- and tfc.contract_number = h.contract_number
    ) attr
    where core.ee_id = attr.ee_id (+)
    and core.contract_number = attr.contract_number (+);
    create or replace view xxdbd_contract_lines as
    select aa.id Contract_id,
    bb.id Service_id,
    aa.CONTRACT_NUMBER,
    F1.USER_NAME Created_By,
    F2.USER_NAME LastUpdated_By,
    bb.LINE_NUMBER Service_Line_No,
    bb.LINE_NUMBER ||'.'|| cc.LINE_NUMBER Product_Line_No,
    xxdbd_Disco_Service_Contract.GetServNameInv(bb.id) Service,
    xxdbd_Disco_Service_Contract.GetServDescInv(bb.id) Service_Desc,
    xxdbd_Disco_Service_Contract.GetServicePrice(bb.id) Service_Price,
    bb.PRICE_UNIT Service_List_Price,
    bb.CURRENCY_CODE,
    aa.SCS_CODE Contract_Type,
    bb.STS_CODE Service_Status,
    bb.TRN_CODE Term_Code,
    bb.START_DATE Service_start,
    bb.END_DATE Service_end,
    TO_NUMBER(OKS_ENT_UTIL_PVT.get_billtoshipto(Null, bb.id, 'OKX_BILLTO' )) SERVICE_BillToSite,
    xxdbd_Disco_Service_Contract.GetLocAccount(TO_NUMBER(OKS_ENT_UTIL_PVT.get_billtoshipto(Null, bb.id, 'OKX_BILLTO' ))) Bill_Account,
    xxdbd_Disco_Service_Contract.GetLocation(TO_NUMBER(OKS_ENT_UTIL_PVT.get_billtoshipto(NULL, bb.id, 'OKX_BILLTO' ))) Service_BillTo,
    TO_NUMBER(OKS_ENT_UTIL_PVT.get_billtoshipto(NULL, bb.id, 'OKX_SHIPTO' )) SERVICE_ShipToSite ,
    xxdbd_Disco_Service_Contract.GetLocation(TO_NUMBER(OKS_ENT_UTIL_PVT.get_billtoshipto(NULL, bb.id, 'OKX_SHIPTO' ))) Service_Ship_To,
    xxdbd_Disco_Service_Contract.GetLocAccount(TO_NUMBER(OKS_ENT_UTIL_PVT.get_billtoshipto(NULL, bb.id, 'OKX_SHIPTO' ))) Ship_Account,
    bb.DATE_RENEWED,
    bb.DATE_TERMINATED,
    cc.START_DATE Eqp_Start,
    cc.END_DATE Eqp_End,
    xxdbd_Disco_Service_Contract.GetEqpNoInvoice(cc.id) Eqp_No,
    xxdbd_Disco_Service_Contract.GetEqpDescInvoice(cc.ID) Eqp_Desc,
    xxdbd_Disco_Service_Contract.GetEqpQuantityInvoice(cc.id) Eqp_Quan,
    xxdbd_Disco_Service_Contract.GetEqpSerialNoInvoice(cc.id) Eqp_Serial,
    xxdbd_Disco_Service_Contract.GetCustomerCt(aa.id, bb.id) Cust_Contact,
    DD.ORGANIZATION_ID,
    dd.INSTALL_ADDRESS,
    dd.INSTALL_DATE,
    dd.INSTALL_SITE_ID INSTALL_SITE_USE_ID,
    dd.PARTY_SITE_NAME INSTALL_SITE_NAME,
    dd.PARTY_SITE_NUMBER INSTALL_SITE_NUMBER
    ,cii.inventory_item_id
    ,cii.inv_master_organization_id
    ,aa.authoring_org_id
    ,cc.id equipment_id
    ,TO_NUMBER(replace(bb.attribute12,',','')) annual_contract_amt
    ,ou.name operating_unit
    ,ou.organization_id operating_unit_id
    ,substr(xxdbd_ra_utility.Get_BusinessProcess(cc.cle_id),1,100) business_process
    ,cii.instance_id
    ,cii.instance_number
    from okc_k_headers_b aa
    ,okc_k_lines_b bb
    ,okc_k_lines_b cc
    ,fnd_user f1
    ,fnd_user f2
    ,csi_item_instances cii
    ,okc_k_items items
    ,hr_all_organization_units ou
    ,xxdbd_oks_install_info_v dd
    where aa.id = bb.dnz_chr_id
    and bb.cle_id is null
    and cc.cle_id = bb.id
    and cc.dnz_chr_id = aa.id
    and f1.user_id = bb.created_by
    and f2.user_id = bb.last_updated_by
    and cc.lse_id in (9,25,18,40)
    and dd.line_id (+) = cc.id
    and items.cle_id = cc.id
    and cii.instance_id = items.object1_id1
    and aa.authoring_org_id = ou.organization_id (+);
    Here are the explain plans from TOAD:
    Operation Object Name Rows Bytes Cost Object Node In/Out PStart PStop
    SELECT STATEMENT Optimizer Mode=CHOOSE 6 49124
    NESTED LOOPS OUTER 6 80 K 49124
    VIEW 6 80 K 49112
    HASH JOIN 6 1 K 49112
    HASH JOIN 17 K 2 M 20214
    TABLE ACCESS FULL OKC.OKC_K_HEADERS_B 5 K 175 K 37
    TABLE ACCESS BY INDEX ROWID OKC.OKC_K_LINES_B 17 K 1 M 20162
    INDEX SKIP SCAN XXDBD.XXDBD_OKC_K_LINES_B_N10 39 17085
    TABLE ACCESS FULL OKC.OKC_K_LINES_B 502 K 34 M 27803
    VIEW PUSHED PREDICATE 1 107 2
    TABLE ACCESS BY INDEX ROWID OKC.OKC_K_LINES_B 42 3 K 216
    NESTED LOOPS 50 5 K 219
    TABLE ACCESS BY INDEX ROWID OKC.OKC_K_HEADERS_B 1 33 3
    INDEX RANGE SCAN OKC.OKC_K_HEADERS_B_U2 1 2
    INDEX RANGE SCAN OKC.OKC_K_LINES_B_N2 1 K 32
    Operation Object Name Rows Bytes Cost Object Node In/Out PStart PStop
    SELECT STATEMENT Optimizer Mode=CHOOSE 245 63309
    NESTED LOOPS 245 291 K 63309
    NESTED LOOPS OUTER 245 286 K 63064
    NESTED LOOPS 245 80 K 62574
    HASH JOIN 245 74 K 61839
    HASH JOIN 245 71 K 61756
    HASH JOIN OUTER 245 68 K 61673
    HASH JOIN 245 60 K 61664
    HASH JOIN 205 K 32 M 28046
    TABLE ACCESS FULL OKC.OKC_K_HEADERS_B 5 K 244 K 37
    TABLE ACCESS FULL OKC.OKC_K_LINES_B 205 K 23 M 27803
    TABLE ACCESS FULL OKC.OKC_K_LINES_B 2 M 168 M 27803
    TABLE ACCESS FULL HR.HR_ALL_ORGANIZATION_UNITS 2 K 64 K 8
    TABLE ACCESS FULL APPLSYS.FND_USER 13 K 172 K 81
    TABLE ACCESS FULL APPLSYS.FND_USER 13 K 172 K 81
    TABLE ACCESS BY INDEX ROWID OKC.OKC_K_ITEMS 1 26 3
    INDEX RANGE SCAN OKC.OKC_K_ITEMS_N1 1 2
    VIEW APPS.XXDBD_OKS_INSTALL_INFO_V 1 861 2
    UNION-ALL PARTITION
    NESTED LOOPS 1 167 9
    NESTED LOOPS 1 108 8
    NESTED LOOPS 1 85 7
    NESTED LOOPS 1 51 6
    TABLE ACCESS BY INDEX ROWID OKC.OKC_K_LINES_B 1 25 3
    INDEX UNIQUE SCAN OKC.OKC_K_LINES_B_U1 1 2
    TABLE ACCESS BY INDEX ROWID OKC.OKC_K_ITEMS 1 26 3
    INDEX RANGE SCAN OKC.OKC_K_ITEMS_N1 1 2
    TABLE ACCESS BY INDEX ROWID CSI.CSI_ITEM_INSTANCES 1 34 1
    INDEX UNIQUE SCAN CSI.CSI_ITEM_INSTANCES_U01 1
    TABLE ACCESS BY INDEX ROWID AR.HZ_PARTY_SITES 1 23 1
    INDEX UNIQUE SCAN AR.HZ_PARTY_SITES_U1 1
    TABLE ACCESS BY INDEX ROWID AR.HZ_LOCATIONS 1 59 1
    INDEX UNIQUE SCAN AR.HZ_LOCATIONS_U1 1
    NESTED LOOPS 1 144 8
    NESTED LOOPS 1 85 7
    NESTED LOOPS 1 51 6
    TABLE ACCESS BY INDEX ROWID OKC.OKC_K_LINES_B 1 25 3
    INDEX UNIQUE SCAN OKC.OKC_K_LINES_B_U1 1 2
    TABLE ACCESS BY INDEX ROWID OKC.OKC_K_ITEMS 1 26 3
    INDEX RANGE SCAN OKC.OKC_K_ITEMS_N1 1 2
    TABLE ACCESS BY INDEX ROWID CSI.CSI_ITEM_INSTANCES 1 34 1
    INDEX UNIQUE SCAN CSI.CSI_ITEM_INSTANCES_U01 1
    TABLE ACCESS BY INDEX ROWID AR.HZ_LOCATIONS 1 59 1
    INDEX UNIQUE SCAN AR.HZ_LOCATIONS_U1 1
    NESTED LOOPS 1 161 8
    NESTED LOOPS 1 85 7
    NESTED LOOPS 1 51 6
    TABLE ACCESS BY INDEX ROWID OKC.OKC_K_LINES_B 1 25 3
    INDEX UNIQUE SCAN OKC.OKC_K_LINES_B_U1 1 2
    TABLE ACCESS BY INDEX ROWID OKC.OKC_K_ITEMS 1 26 3
    INDEX RANGE SCAN OKC.OKC_K_ITEMS_N1 1 2
    TABLE ACCESS BY INDEX ROWID CSI.CSI_ITEM_INSTANCES 1 34 1
    INDEX UNIQUE SCAN CSI.CSI_ITEM_INSTANCES_U01 1
    TABLE ACCESS BY INDEX ROWID AR.HZ_PARTIES 1 76 1
    INDEX UNIQUE SCAN AR.HZ_PARTIES_U1 1
    TABLE ACCESS BY INDEX ROWID CSI.CSI_ITEM_INSTANCES 1 21 1
    INDEX UNIQUE SCAN CSI.CSI_ITEM_INSTANCES_U01 1
    And here is the SQL to join:
    select * from xxdbd_contract_lines l, xxdbd_contract_flexfields f
    where f.service_id (+) = l.service_id
    and f.contract_number (+) = l.contract_number
    and l.contract_number = 'NL0000014'
    Operation Object Name Rows Bytes Cost Object Node In/Out PStart PStop
    SELECT STATEMENT Optimizer Mode=CHOOSE 1 49221
    HASH JOIN OUTER 1 38 K 49221
    VIEW APPS.XXDBD_CONTRACT_LINES 1 19 K 96
    NESTED LOOPS OUTER 1 1 K 96
    NESTED LOOPS 1 358 94
    NESTED LOOPS 1 345 93
    NESTED LOOPS 1 332 92
    NESTED LOOPS 1 311 91
    NESTED LOOPS 1 285 88
    NESTED LOOPS 448 72 K 88
    NESTED LOOPS OUTER 1 78 4
    TABLE ACCESS BY INDEX ROWID OKC.OKC_K_HEADERS_B 1 46 3
    INDEX RANGE SCAN OKC.OKC_K_HEADERS_B_U2 1 2
    TABLE ACCESS BY INDEX ROWID HR.HR_ALL_ORGANIZATION_UNITS 1 32 1
    INDEX UNIQUE SCAN HR.HR_ORGANIZATION_UNITS_PK 1
    TABLE ACCESS BY INDEX ROWID OKC.OKC_K_LINES_B 378 32 K 84
    INDEX RANGE SCAN XXDBD.XXDBD_OKC_K_LINES_B_N10 378 16
    TABLE ACCESS BY INDEX ROWID OKC.OKC_K_LINES_B 1 119
    INDEX RANGE SCAN OKC.OKC_K_LINES_B_N2 1 K 32
    TABLE ACCESS BY INDEX ROWID OKC.OKC_K_ITEMS 1 26 3
    INDEX RANGE SCAN OKC.OKC_K_ITEMS_N1 1 2
    TABLE ACCESS BY INDEX ROWID CSI.CSI_ITEM_INSTANCES 1 21 1
    INDEX UNIQUE SCAN CSI.CSI_ITEM_INSTANCES_U01 1
    TABLE ACCESS BY INDEX ROWID APPLSYS.FND_USER 1 13 1
    INDEX UNIQUE SCAN APPLSYS.FND_USER_U1 1
    TABLE ACCESS BY INDEX ROWID APPLSYS.FND_USER 1 13 1
    INDEX UNIQUE SCAN APPLSYS.FND_USER_U1 1
    VIEW APPS.XXDBD_OKS_INSTALL_INFO_V 1 861 2
    UNION-ALL PARTITION
    NESTED LOOPS 1 167 9
    NESTED LOOPS 1 108 8
    NESTED LOOPS 1 85 7
    NESTED LOOPS 1 51 6
    TABLE ACCESS BY INDEX ROWID OKC.OKC_K_LINES_B 1 25 3
    INDEX UNIQUE SCAN OKC.OKC_K_LINES_B_U1 1 2
    TABLE ACCESS BY INDEX ROWID OKC.OKC_K_ITEMS 1 26 3
    INDEX RANGE SCAN OKC.OKC_K_ITEMS_N1 1 2
    TABLE ACCESS BY INDEX ROWID CSI.CSI_ITEM_INSTANCES 1 34 1
    INDEX UNIQUE SCAN CSI.CSI_ITEM_INSTANCES_U01 1
    TABLE ACCESS BY INDEX ROWID AR.HZ_PARTY_SITES 1 23 1
    INDEX UNIQUE SCAN AR.HZ_PARTY_SITES_U1 1
    TABLE ACCESS BY INDEX ROWID AR.HZ_LOCATIONS 1 59 1
    INDEX UNIQUE SCAN AR.HZ_LOCATIONS_U1 1
    NESTED LOOPS 1 144 8
    NESTED LOOPS 1 85 7
    NESTED LOOPS 1 51 6
    TABLE ACCESS BY INDEX ROWID OKC.OKC_K_LINES_B 1 25 3
    INDEX UNIQUE SCAN OKC.OKC_K_LINES_B_U1 1 2
    TABLE ACCESS BY INDEX ROWID OKC.OKC_K_ITEMS 1 26 3
    INDEX RANGE SCAN OKC.OKC_K_ITEMS_N1 1 2
    TABLE ACCESS BY INDEX ROWID CSI.CSI_ITEM_INSTANCES 1 34 1
    INDEX UNIQUE SCAN CSI.CSI_ITEM_INSTANCES_U01 1
    TABLE ACCESS BY INDEX ROWID AR.HZ_LOCATIONS 1 59 1
    INDEX UNIQUE SCAN AR.HZ_LOCATIONS_U1 1
    NESTED LOOPS 1 161 8
    NESTED LOOPS 1 85 7
    NESTED LOOPS 1 51 6
    TABLE ACCESS BY INDEX ROWID OKC.OKC_K_LINES_B 1 25 3
    INDEX UNIQUE SCAN OKC.OKC_K_LINES_B_U1 1 2
    TABLE ACCESS BY INDEX ROWID OKC.OKC_K_ITEMS 1 26 3
    INDEX RANGE SCAN OKC.OKC_K_ITEMS_N1 1 2
    TABLE ACCESS BY INDEX ROWID CSI.CSI_ITEM_INSTANCES 1 34 1
    INDEX UNIQUE SCAN CSI.CSI_ITEM_INSTANCES_U01 1
    TABLE ACCESS BY INDEX ROWID AR.HZ_PARTIES 1 76 1
    INDEX UNIQUE SCAN AR.HZ_PARTIES_U1 1
    VIEW APPS.XXDBD_CONTRACT_FLEXFIELDS 6 112 K 49124
    NESTED LOOPS OUTER 6 80 K 49124
    VIEW 6 80 K 49112
    HASH JOIN 6 1 K 49112
    HASH JOIN 17 K 2 M 20214
    TABLE ACCESS FULL OKC.OKC_K_HEADERS_B 5 K 175 K 37
    TABLE ACCESS BY INDEX ROWID OKC.OKC_K_LINES_B 17 K 1 M 20162
    INDEX SKIP SCAN XXDBD.XXDBD_OKC_K_LINES_B_N10 39 17085
    TABLE ACCESS FULL OKC.OKC_K_LINES_B 502 K 34 M 27803
    VIEW PUSHED PREDICATE 1 107 2
    TABLE ACCESS BY INDEX ROWID OKC.OKC_K_LINES_B 42 3 K 216
    NESTED LOOPS 50 5 K 219
    TABLE ACCESS BY INDEX ROWID OKC.OKC_K_HEADERS_B 1 33 3
    INDEX RANGE SCAN OKC.OKC_K_HEADERS_B_U2 1 2
    INDEX RANGE SCAN OKC.OKC_K_LINES_B_N2 1 K 32

    DECODE(l.attribute_category, 'Coverage Template Header', l.attribute3) Penalty_Bonus,
    DECODE(l.attribute_category, 'Coverage Break', l.attribute1) Mon_Break_Start,
    DECODE(l.attribute_category, 'Transaction Type', l.attribute1) Split_Covering,Uh oh, the dreaded entity attibute value, or generic, data model.
    http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:10678084117056
    I am afraid slow performance is a built in feature of this database design, not much you can do in queries.
    You could possibly create the views as materialized views and query those instead.
    Quote from the linked article
    But, how does it perform? Miserably, terribly, horribly. A simple "select
    first_name, last_name from person" query is transformed into a 3-table join with
    aggregates and all. Further, if the attributes are "NULLABLE" - that is, there
    might not be a row in OBJECT_ATTRIBUTES for some attributes, you may have to
    outer join instead of just joining which in some cases can remove more optimal
    query plans from consideration.
    Writing queries might look pretty straightforward, but it's impossible to do in
    a performant fashion.

  • Oracle.jbo.RowAlreadyDeletedException with outer join

    Hi,
    I have created a VO, based on an EO, with an outer join present.
    The first time I query my data (search) everything goes well, but when I perform a search the second time, I receive the error message: "oracle.apps.fnd.framework.OAException: oracle.jbo.RowAlreadyDeletedException: JBO-25019: Entiteitsrij van sleutel oracle.jbo.Key[202 53162 ] not found in XxpostMmpParametersEO."
    The reason why is because of the outer join there is no 1 to 1 relationship between the EO and the VO. However for the first time , it works fine.
    Does someone have an idea how I can avoid the error for my second search action?
    Thanks in advance!
    br
    Guy

    Hi all,
    the following article:
    http://radio.weblogs.com/0123729/stories/2003/05/15/entityObjectOverTableWhosePrimaryKeyMayBeNull.html
    suggest a possible workaround. It wok fine, but it is not generic! :((
    By
    Alessandro

  • Outer Join issue in SSRS

    Symptom description:
    I have a Department table and an Employee table. In Department table, Deptno is the primary key. In Employee table, Empid is the primary key and Deptno is a foreign key pointing to Deptno of Department table.
    Using BIDS, I have created a Data Source View (DSV) incorporating the above two tables and a relationship is also formed where Employee is the source and Department is the destination. I have then autogenerated a Report Model (.smdl) using the DSV.
    Now, when I select attributes from both Department entity and Employee entity in Report Builder 3.0, the query generated by Report Builder fetches only those records from Department for which an employee exists.
    My objective is to fetch all records from Department when Department is joined with Employee irrespective of whether an employee exists or not for that department. How can this be achieved?
    Given below is the query generated by Report Builder:
    SELECT DISTINCT
        "DEPT"."DepartmentNo" "DepartmentNo",
        "DEPT"."DepartmentDepartmentName" "DepartmentDepartmentName",
        "DEPT"."City" "City",
        "EMP"."EMPID" "EmployeeID",
        "EMP"."EMP_NAME" "EmployeeName",
        "EMP"."SALARY" "Salary"
    FROM
        "CLINICOPIA_REPORTS"."EMP" "EMP"
        LEFT OUTER JOIN (
            SELECT /*+ NO_MERGE */
                "DEPT"."DEPTNO" "DepartmentNo",
                "DEPT"."DEPT_NAME" "DepartmentDepartmentName",
                "DEPT"."CITY" "City",
                "DEPT"."DEPTNO" "DEPTNO"
            FROM
                "CLINICOPIA_REPORTS"."DEPT" "DEPT"
        ) "DEPT" ON "EMP"."DEPTNO" = "DEPT"."DEPTNO"
    WHERE
        CAST(1 AS NUMERIC(1,0)) = 1
    ORDER BY
        "DepartmentNo", "DepartmentDepartmentName", "City", "EmployeeID", "EmployeeName", "Salary";
    Environment: SharePoint 2010 serves as the Web Front-End Server and also hosts Reporting Services Add-in. SQL Server 2008 R2 SP2 is the Back-End Server hosting Sql Server Reporting Services
    (SSRS) in SharePoint Integrated mode. The data is fetched in the Report Builder 3.0 reports from an Oracle database.
    Environment details-
    Web Front-End Server: SharePoint Server 2010 with Enterprise Client Access License features. Operating System is Microsoft Windows Server 2008 R2 Standard - 64 Bit.
    Back-End Database Server: SQL Server 2008 R2 Enterprise SP2. Operating System is Microsoft Windows Server 2008 R2 Standard - 64 Bit.
    Oracle Database Server: Operating System is Red Hat Enterprise Linux Server release 5 (Tikanga). Oracle Database version is Oracle Database 10g R2 Enterprise Edition Release 10.2.0.2.0 - Production.

    Setting the Cardinality of Department > Employee role to OptionalOne
    gives rise to cartesian join (which is a bigger issue).
    Therefore, the Cardinality of Department > Employee role should remain as
    OptionalMany (default).
    This means, the outer join problem still remains unsolved. I have, therefore,
    unmarked the above answer by me.
    The question is - why has Report Builder been designed in such a way that the primary entity is always the child entity when attributes are selected from both parent and child entities?
    Most people desire that all the rows of the parent entity be fetched irrespective of whether there are corresponding rows in the child entity or not. Report Builder tool should not dictate what the user wants to get, meaning it is not right to assume
    that the focus of the report is Employee when attributes are selected from both Department and Employee. Report Builder should not make the child entity (i.e., Employee) as the primary entity when the user selects attributes from the child entity after
    having selected attributes from the parent entity.
    I am sorry to say that clients may not accept the Report Builder tool as this does not fetch the records as desired.
    I hope there is someone who can suggest how the outer join problem can be solved by just tweaking the properties of the report model (SMDL).
    Besides, the end users are business users and are not tech savvy. They are not expected to modify queries. They would simply drag and drop attributes from entities to create adhoc reports.

  • Error with Outer Join

    So, I have a complex VO that includes two updatable entities. One of these is an outer join. It's an adjustment table which has a 0-1 relation with travel Request table that has an estimated amount.
    I only want a record in this adjustement table when there's a change.
    HOWEVER, if I make a change on the screen to the fields in my other entity, ADF wants to insert into the outer join table and I get an error because the field is null and it's required.
    So, how do I keep ADF from inserting a row into the outer join but still update the other entity?
    I'm using JDev 11.1.1.3.0
    Thanks,
    Jet

    Thanks for the feedback. I had to remember to go back and add it to the App Module and juggle the bindings a bit, but I got it sorted out so it doesn't error
    However when I do that and
    if there is no row
    cuz there hasn't been an adjustment yet
    it doesn't give me a field to enter one in. It just prints the label with nothing next to it??????????????????
    if I already put a row in then it displays properly and I can change it.
    How do I make it give me a field so I can insert a row when required?

  • WCF Data Service from Entity Framework 5 in SharePoint 2013

    not sure which forum is best, so im going to throw it in here.
    I am working on a proof of concept. I want to create a WCF Data Service within sharepoint 2013. not only do i want to do that, i want to use the Entity Framework 5 to expose the data via OData. Now, I have crawled the internet and seen various examples of
    how to create wcf data services and wcf services in sharepoint 2010/2013. and have tried to apply those as needed to create this POC. So.. what I have done so far. 
    MonitoringData.cs
    [BasicHttpBindingServiceMetadataExchangeEndpoint]
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]
    [System.Runtime.InteropServices.Guid("0185abf6-e8b8-42e2-9965-6bb644338077")]
    public class MonitoringData : DataService<MonitoringServiceEntities>
    // This method is called only once to initialize service-wide policies.
    public static void InitializeService(DataServiceConfiguration config)
    // TODO: set rules to indicate which entity sets and service operations are visible, updatable, etc.
    // Examples:
    config.SetEntitySetAccessRule("*", EntitySetRights.AllWrite);
    config.SetServiceOperationAccessRule("*", ServiceOperationRights.All);
    config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V3;
    MonitoringData.svc:
    <%@ServiceHost Language="C#" Debug="true"
    Service="$SharePoint.Type.0185abf6-e8b8-42e2-9965-6bb644338077.AssemblyQualifiedName$"
    Factory="Microsoft.SharePoint.Client.Services.MultipleBaseAddressDataServiceHostFactory, Microsoft.SharePoint.Client.ServerRuntime, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
    upon deployment, this error when hitting the https://server/_vti_bin/poc/monitoringdata.svc/$metadata
    "The type 'xxxxxxxx', provided as the Service attribute value in the ServiceHost directive, or provided in the configuration element system.serviceModel/serviceHostingEnvironment/serviceActivations could
    not be found."
    Breaking out the google-fu, i found that adding the dll to the <compilation> section was needed for the web.config. so i did that. and now i just get a blank screen with no errors.
    so i crack open fiddler. i see the following 
    200 http
    tunnel to
    server:443 0
    401 https
    server /_vti_bin/poc/monitoringdata.svc/$metadata
    16
    401
    https server
    /_vti_bin/poc/monitoringdata.svc/$metadata
    0
    404
    https server
    /_vti_bin/poc/monitoringdata.svc/$metadata
    0
    best i can see is that im either not authorized, and its returning null (which shouldnt be the case) or something is just busted.
    The goal is to use ntml auth and https to connect to this service. any ideas?

    One thing I found was that it's never worth the trouble to place the WCF service in a web site running SharePoint, it's better to place it in a dedicated web site, as described in this article:
    http://sharepointdragons.com/2011/10/07/parallel-programming-in-sharepoint-2010-the-back-to-the-future-pattern/
    It's usually too much work to get the web.config settings right because of the settings it inherits from its parents.
    Kind regards,
    Margriet Bruggeman
    Lois & Clark IT Services
    web site: http://www.loisandclark.eu
    blog: http://www.sharepointdragons.com
    I'll say that it is one solution to move the WCF Service outside of sharepoint. but my "1000 mile" requirements makes this a necessity. 
    To broaden the scope of what I am doing, I have a custom SharePoint Service Application. this custom application has a proxy that used a restful interface. Now, with all the methods i will have to write (over 100, x3 for all of the "proxy to a proxy" scenarios)
    I wanted to explore the idea of using odata. so i can use the various clients to write their own queries instead of me writing them all and exposing them. especially since its all linq queries to a database underneath. I feel that I am missing some specific
    component to make this work, and its surely due to my incomplete knowledge of WCF or EF.

  • Create a outer Join for a @SecondaryTable in EJB 3.0

    Hello
    I need to create a outer Join for a @SecondaryTable in EJB 3.0, any can help me?
    Thanks in Advance…

    Yes, I have this relations in the entity:
    @Table(name = "RF_HTRANSACTION")
    @SecondaryTables({
    @SecondaryTable(name="RF_CLIENTS",
    pkJoinColumns={@PrimaryKeyJoinColumn(name="NUMERO_CLIENTE", referencedColumnName="NUMERO_CLIENTE")}
    @SecondaryTable(name="RF_SUPPLIER",
    pkJoinColumns={@PrimaryKeyJoinColumn(name="NUMERO_PROVEEDOR", referencedColumnName="NUMERO_PROVEEDOR")}
    @SecondaryTable(name="RFSUPPLIER_PROY",
    pkJoinColumns={@PrimaryKeyJoinColumn(name="NUMERO_PROYECTO", referencedColumnName="NUMERO_PROYECTO")}
    @SecondaryTable(name="RF_REFAGENTS",
    pkJoinColumns={@PrimaryKeyJoinColumn(name="NUMERO_RA", referencedColumnName="NUMERO_RA")}
    I need to create a outer join between RF_HTRANSACTION and RF_REFAGENTS.

  • Entity Framework in WPF Application - Using Statement or Implement IDisposable

    I have a WPF application that uses Entity Framework.
    I have implemented a Repository that implements IDisposable, that holds my EF context.  When the application starts up I new up a Repository, which news up an EF context, then when the application shuts down, I dispose of my Repository, which disposes
    the EF context as well.
    The end result is that my context remains open during the entire lifetime of the application.  
    I've been reading up on EF, and all the examples put the operations against the EF context in a using statement.  Is that the preferred approach?  What is the priority: to keep the context open briefly, or just to make sure you properly dispose
    of it when you're finished with it.
    Thanks.
    Aaron

    >
    https://msdn.microsoft.com/en-us/library/aa355056(v=vs.110).aspx
    That link is only for WCF and it's broken implementation of the Dispose pattern.
    >I have been burnt in doing it where the connection was not closed or disposed when it short-circuted out of the Using statement on exception
    If so, it was a bug.  You should expect that not to happen.
    'using' will close your connection, unless the connection was open before the DbContext and was passed in.  'using' is the safest way to ensure that the connections are closed in a timely manner.
    David
    David http://blogs.msdn.com/b/dbrowne/
    I absoultly do not agree with you. I have been burnt in using the Using statment. And it was along the lines that an excpetion was thrown within the Using statement and no closing of the connection or dispoiong of it ever occured, which is what the WCF example
    is showing on how a Using statement can be short-circuted and things can go wrong.
    I don't care if the Using statement issue is being shown on a WCF typed cleint. I do the same thing in using straight up ADO.NET or EF, becuase I have been burnt by the Using statement, and I dont use them to open,  close or dispose of a connection.

  • Self Reference Model Class - How to populate using Entity Framework

    Hi,i have table in SQL Server named Employees as follows:
    EmployeeId lastName FirstName reportsTo
    1 Davolio Nancy 2
    2 Fuller Andrew NULL
    3 Leverling Janet 2
    4 Peacock Margaret 2
    5 Buchanan Steven 2
    6 Suyama Michael 5
    7 King Robert 5
    8 Callahan Laura 2
    9 Dodsworth Anne 5
    I would like to use Entity Framework to populate my Model Class .My model class looks as follows:
    public class Employees
        readonly List<Employees> _children = new List<Employees>();
        public IList<Employees> Children
            get { return _children; }
        public string FirstName { get; set; }
        public string LastName {get; set;}
    I want to use this class in ViewModel  to populate my TreeView control. Can anyone help me in order to define Linq to Entities in order to populate my model class Employees from table in SQL Server as defined. Thanks in advance.
    Almir

    Hello Fred,
    unfortunately it does not work, maybe I can be more specific about what I'm trying to get. I'm following Josh Smith's article on CodeProject related to WFP TreeView
    Josh Smith article. He has Class named Person with the following structure
    public class Person
    readonly List<Person> _children = new List<Person>();
    public List<Person> Children
    get
    return _children;
    public string Name { get; set; }
    The same is populated from Database class using method named GetFamilyTree() which look as follows:
    public static Person GetFamilyTree()
    // In a real app this method would access a database.
    return new Person
    Name = "David Weatherbeam",
    Children =
    new Person
    Name="Alberto Weatherbeam",
    Children=
    new Person
    Name="Zena Hairmonger",
    Children=
    new Person
    Name="Sarah Applifunk",
    new Person
    Name="Jenny van Machoqueen",
    Children=
    new Person
    Name="Nick van Machoqueen",
    new Person
    Name="Matilda Porcupinicus",
    new Person
    Name="Bronco van Machoqueen",
    new Person
    Name="Komrade Winkleford",
    Children=
    new Person
    Name="Maurice Winkleford",
    Children=
    new Person
    Name="Divinity W. Llamafoot",
    new Person
    Name="Komrade Winkleford, Jr.",
    Children=
    new Person
    Name="Saratoga Z. Crankentoe",
    new Person
    Name="Excaliber Winkleford",
    I'm trying to figure out how should I write
    GetFamilyTree() method using Entity Framework in order to connect to my SQL Server database and populate this Person class as it was populated manually in Joshs Example. The table I'm using in SQL Server is described in
    my first post named Employees (it's self reference table)

Maybe you are looking for