Outer join in view criteria

Hi everybody
I use jdeveloper 11.1.1.6.0
I want to create outer join in view criteria, so I had to override getCriteriaItemClause method in ViewObjImpl.java
my query is like this :
SELECT t1.row_no, t2.type FROM   table_1  t1 , table_2  t2
WHERE   t1.row_no(+) = t2.row_no
  and       t1.user_Id(+) = :bindVar
table_1(row_no, user_Id )
table_2(row_no,type)
the part   " t1.user_Id(+) = :bindVar " should be put in the view criteria
the method:
    @Override
    public String getCriteriaItemClause(ViewCriteriaItem viewCriteriaItem) {         
            String newQeury =this.getEntityDef(0).getAliasName() + "." +  viewCriteriaItem.getColumnName() + "(+) = :bindVar ";
            return newQeury;
but when I run the view criteria the exception below raises:
oracle.jbo.expr.JISyntaxError: JBO-36000: An unexpected expression token is found.
when I remove sign "(+)" from newQeury
   String newQeury =this.getEntityDef(0).getAliasName() + "." +  viewCriteriaItem.getColumnName() + "= :bindVar ";  // remove sign '(+)' before = :bindVar
the exception below raises
JBO-29000: Unexpected exception caught: oracle.jbo.expr.JIEvalException, msg=JBO-25077: Name t1 not found in the given object: ViewRow [oracle.jbo.Key[5 1 5 ]].
Habib

This is a duplicate of https://forums.oracle.com/thread/2577092
Please don't post your questions multiple times. 
A possible solution posted to the original thread.
Timo

Similar Messages

  • Outer join in view criteria: how to ?

    Hello,
    I have to create a VO for a LOV. I created in this VO a ViewCriteria to pass variables for the query.
    The problem is that for one of this variable I have to set the clause as an outer join.
    JDeveloper creates:
    SELECT MyView1.Item, MyView2.Code
    FROM MyView1, MyView2
    WHERE MyView1.ID = MyView2.EXT_ID (+)
    AND MyView1.Item = :TheItem
    AND MyView2.Code = :TheCodebut I need something like:
    SELECT MyView1.Item, MyView2.Code
    FROM MyView1, MyView2
    WHERE MyView1.ID = MyView2.EXT_ID (+)
    AND MyView1.Item = :TheItem
    AND :TheCode = MyView2.Code (+)

    ADFboy wrote:
    this is optional parameter value, in the view criteria windows is this option....
    AdfBoyNo, this parameter is not optional because, in the call of the LOV it will be always set.
    But the query without the outer join returns too few rows...
    I tried to find where to "intercept" this programmatically, but I'm failing doing this. :(
    I'll have the same problem with another field, not for a LOV but to get the value of an attribute of a VO.
    Even in advanced mode the Where clause can't have parameters...

  • Outer Join on view hangs

    Hi there,
    sorry about the big post but I am wondering if someone could help me with this. I dont seem to be able to figure out what I am doing wrong here:
    I've created a function that merges a number of lines of text into one row, the function works fine if I call it directly:
    CREATE FUNCTION "LONG_TEXT" (code IN VARCHAR2, inc_no IN VARCHAR2)
    RETURN VARCHAR2 IS
    text_full VARCHAR2(32767);
    BEGIN
    FOR r IN ( SELECT bo_text
    FROM text_table
    WHERE SUBSTR(bo_key,1,4) = code
    AND SUBSTR(bo_key,5,10) = inc_no
    AND bo_text_code = 'IT'
    ORDER BY LINE_NO)
    LOOP
    text_full := text_full || ' ' || trim(r.bo_text);
    END LOOP;
    RETURN trim(text_full);
    END long_text;
    I've called the function in a view - works fine when I call it directly:
    CREATE OR REPLACE VIEW "EEV097_IT" ("CODE","INC_NO","BO_TEXT") AS SELECT DISTINCT SUBSTR(bo_key,1,4) AS code,
    SUBSTR(bo_key,5,10) AS inc_no,
    long_text(SUBSTR(bo_key,1,4),SUBSTR(bo_key,5,10)) AS bo_text
    FROM text_table
    WHERE bo_text_code = 'IT'
    Then I've joined the view to another table. This statement actually works:
    SELECT
    EEV097_IT.CODE,
    EEV097_IT.BO_TEXT,
    EEV097_IT.INC_NO,
    INC_DIM.REV_OCC_DATE
    FROM
    INC_DIM
    LEFT OUTER JOIN
    EEV097_IT ON EEV097_IT.CODE=INC_DIM.CODE AND
    EEV097_IT.INC_NO=INC_DIM.INC_NO
    WHERE
    INC_DIM.BO_USER_ID = 'L83321' AND
    INC_DIM.REV_OCC_DATE BETWEEN '19/FEB/07' AND '23/FEB/07'
    INC_DIM.INC_NO = '1234';
    but as soon as it take this line "INC_DIM.INC_NO = '1234'" out of the where clause or add a second inc_no something like INC_DIM.INC_NO in ('1234','2345'); oracle hangs when I execute this statement - At the end of the day I dont want to specify a inc_no in the where clause at all - The expected result is quite small just about 10 rows I am using oracle version 11.1.0.6.
    If someone has an idea please let me - there would be one work around to put the view as a nested selected into the statement that works fine, but I can't use it. I basically need to end up with a view that I can join to the other table like I did above - so the fix needs to be in the view or in the function.
    thanks
    jess

    Please provide more details as mentioned in When your query takes too long ... thread

  • Granting SELECT to user on VIEW with FULL OUTER JOIN fails?

    I have a quandary.
    Using Oracle 9i, I have created a simple view. When I perform a count on it, rows are returned.
    However, when I grant SELECT access to another user, they can't see the VIEW. The VIEW has a FULL OUTER JOIN operation in it.
    When I do the same thing using a regular join, it works.
    Any ideas why, please?
    SQL> conn ifsinfo/******@DB
    Connected.
    SQL> ed
    Wrote file afiedt.buf
      1  create view mctest3 as
      2  select
      3   vc.idcus ,
      4   ci.customer_id
      5  from
      6   ifsapp.vmo_company vc
      7  full outer join
      8   ifsapp.customer_info ci
      9  on
    10*  vc.custno = ci.customer_id
    SQL> /
    View created.
    SQL> select count(*) from mctest3;
      COUNT(*)
         73994
    SQL> GRANT SELECT ON MCTEST3 TO IFSAPP WITH GRANT OPTION;
    Grant succeeded.
    SQL> CONN IFSAPP/******@DB
    Connected.
    SQL> select count(*) from IFSINFO.MCTEST3;
    select count(*) from IFSINFO.MCTEST3
    ERROR at line 1:
    ORA-00942: table or view does not existbut with regular join:
    SQL> conn ifsinfo/******@DB
    Connected.
    SQL> create view mctest4 as
      2    select
      3     vc.idcus ,
      4     ci.customer_id
      5    from
      6     ifsapp.vmo_company vc, ifsapp.customer_info ci
      7    where vc.custno = ci.customer_id;
    View created.
    SQL> select count(*) from mctest4;
      COUNT(*)
         44269
    SQL> GRANT SELECT ON MCTEST4 TO IFSAPP WITH GRANT OPTION;
    Grant succeeded.
    SQL> conn ifsapp/******@DB
    Connected.
    SQL> select count(*) from IFSINFO.MCTEST4;
      COUNT(*)
         44269

    Hi,
    >>SQL> conn ifsinfo/******@DB
    Connected.
    SQL> ed
    Wrote file afiedt.buf
    1 create view mctest3 as
    2 select
    3 vc.idcus ,
    4 ci.customer_id
    5 from
    6 ifsapp.vmo_company vc
    7 full outer join
    8 ifsapp.customer_info ci
    9 on
    10* vc.custno = ci.customer_id
    SQL> /
    According to Note:244315.1, it is not possible to make a FULL OUTER JOIN on views owned by another user at the 9i version of Oracle. As above, do not use FULL OUTER JOIN on views owned by another user. Try to use outer join operator (+), and/or UNIONS instead.
    Cheers

  • Programmatically adding two view criteria

    Hello,
    I am using Jdev version 12.1.2.0.0 and i am trying to apply two view criteria to a view object:
    ViewObject vo = ...
    ViewCriteria vc1 = vo.createViewCriteria();
    ViewCriteriaRow vcr1 = vc1.createViewCriteriaRow();
    vcr1.setAttribute(smt,smt);
    vc1.add(vcr1);
    ViewCriteria vc2 = vo.createViewCriteria();
    ViewCriteriaRow vcr2 = vc2.createViewCriteriaRow();
    vcr2.setAttribute(smt,smt);
    vc2.add(vcr2);
    vo.applyViewCriteria(vc1);
    vo.applyViewCriteria(vc2,true);
    vo.executeQuery();
    I don't know why, but it executes just the second view criteria.
    Thank you in advanced.

    From the dos it looks like you add multiple rows to one view criteria but can only apply one view criteria
    public static void demoCriteria(ApplicationModule appMod)
      // Create and populate criteria rows to support query-by-example.
      ViewObject empView = appMod.createViewObject("Emp", "mypackage1.EmpView");
      ViewCriteria vc = empView.createViewCriteria();
      ViewCriteriaRow vcRow = vc.createViewCriteriaRow();
      // ViewCriteriaRow attribute name is case-sensitive.
      // ViewCriteriaRow attribute value requires operator and value.
      // Note also single-quotes around string value.
      ViewCriteriaItem jobItem = vcRow.ensureCriteriaItem("Job");
      jobItem.setOperator("=");
      jobItem.getValues().get(0).setValue("MANAGER");
      vc.add(vcRow);
      vcRow = vc.createViewCriteriaRow();
      ViewCriteriaItem salItem = vcRow.ensureCriteriaItem("Sal");
      salItem.setOperator(">");
      salItem.getValues().get(0).setValue(new Integer(2500));
      vc.add(vcRow);
      empView.applyViewCriteria(vc);
      // Multiple rows are OR-ed in WHERE clause.
      System.out.println("Demo View Criteria");
      // Should print employees that are MANAGER or have Sal > 2500
      QueryDemo.printViewObject(empView);
    Timo

  • Create a view that limits a large table, but also allows an outer join ?

    oracle 10.2.0.4
    CREATE TABLE MY_PAY_ITEMS
    ( EMP     VARCHAR2(8) NOT NULL
    , PAY_PRD VARCHAR2(8) NOT NULL
    , KEY1    VARCHAR2(8) NOT NULL
    , KEY2    VARCHAR2(8) NOT NULL
    , LN_ITEM VARCHAR2(4) NOT NULL
    , ITEM_AMT NUMBER(24,2) NOT NULL
    , FILLER  VARCHAR2(100) NOT NULL)
    INSERT INTO MY_PAY_ITEMS
    SELECT A.EMP
    , B.PAY_PRD
    , C.KEY1
    , D.KEY2
    , E.LN_ITEM 
    , F.ITEM_AMT
    FROM (SELECT TO_CHAR(ROWNUM, '00000000') "EMP" FROM DUAL  CONNECT BY LEVEL <= 50 ) A
    , (SELECT '2010-' || TO_CHAR(ROWNUM,'00') "PAY_PRD" FROM DUAL CONNECT BY LEVEL <= 52) B
    , (SELECT TO_CHAR(ROWNUM, '000') "KEY1" FROM DUAL CONNECT BY LEVEL <= 8) C
    , (SELECT TO_CHAR(ROWNUM, '000') "KEY2" FROM DUAL CONNECT BY LEVEL <= 5) D
    , (SELECT TO_CHAR(ROWNUM,'000') "LN_ITEM" FROM DUAL CONNECT BY LEVEL <= 20) E
    , (select round(DBMS_RANDOM.VALUE * 400,2)  "ITEM_AMT" from dual) F
    CREATE UNIQUE INDEX MY_PAY_ITEMS ON MY_PAY_ITEMS (EMP, PAY_PRD, KEY1, KEY2, LN_ITEM)
    CREATE TABLE MY_ITEM_DISPLAY
    ( DISPLAY_CODE VARCHAR2(4) NOT NULL
    , SEQUENCE     NUMBER(2) NOT NULL
    , COLUMN_ITEM1 VARCHAR2(4) not null
    , COLUMN_ITEM2 VARCHAR2(4) not null
    , COLUMN_ITEM3 VARCHAR2(4) not null
    , COLUMN_ITEM4 VARCHAR2(4) not null)
    INSERT INTO MY_ITEM_DISPLAY VALUES ('01',10,'001','003','004','005');
    INSERT INTO MY_ITEM_DISPLAY VALUES ('01',20,'007','013','004','009');
    INSERT INTO MY_ITEM_DISPLAY VALUES ('01',30,'001','004','009','011');
    INSERT INTO MY_ITEM_DISPLAY VALUES ('01',40,'801','304','209','111');
    INSERT INTO MY_ITEM_DISPLAY VALUES ('02',10,'001','003','004','005');
    INSERT INTO MY_ITEM_DISPLAY VALUES ('02',20,'007','013','004','009');
    INSERT INTO MY_ITEM_DISPLAY VALUES ('02',30,'001','004','009','011');
    MY_PAY_ITEMS is a table that stores payslip line items.  It has a total size of 500,000,000 rows.
    EMP is the unique employee id,  We have approx 200,000 employees (with approx 50,000 being active today).
    PAY_PRD is a weekly pointer (2010-01, 2010-02 ... 2010-52), we have data from 2004 and are adding a new pay period every week.  2010-01 is defined as the first monday in 2010 to the first sunday in 2010 etc.
    KEY1 is an internal key, it tracks the timeline within the pay period.
    KEY2 is a child of KEY1, it tracks the sequence of events within KEY1.
    LN_ITEM is the actual pay item that resulted from the event on average a person generates 20 rows per event.  Note that in this example everybody gets the same LN_ITEM values, but in practice it is 20 selected from 300
    ITEM_AMT is the net pay for the line item.
    FILLER is an assortment of fields that are irrelevant to this question, but do act as a drag on any row loads.
    MY_ITEM_DISPLAY is a table that describes how certain screens should display items.  The screen itself is a 4 column grid, with the contents of the individual cells being defined as a lookup of LN_ITEMS to retrieve the relevant LN_AMT.
    We have an application that receives a DISPLAY_CODE and an EMP.  It automatically creates a sql statement along the lines of
    SELECT * FROM MY_VIEW WHERE DISPLAY_CODE = :1 AND EMP = :2
    and renders the output for the user.
    My challenge is that I need to rewrite MY_VIEW as follows:
    1) Select the relevant rows from MY_ITEM_DISPLAY where DISPLAY_CODE = :1
    2) Select the relevant all rows from MY_PAY_ITEMS that satisfy the criteria
       a) EMP = :2
       b) PAY_PRD = (most recent one for EMP as at sysdate, thus if they last got paid in 2010-04 , return 2010-04)
       c) KEY1 = (highest key1 within EMP and PAY_PRD)
       d) KEY2 = (highest key2 within EMP, PAY_PRD and KEY1)
    3) I then need to cross reference these to create a tabular output
    4) Finally I have to return a line of 0's where no LN_ITEMs exist ( DISPLAY_CODE 01, sequence 40 contains impossible values for this scenario)
    The below query does part of it (but not the PAY_PRD, KEY1, KEy2 )
    select * from (
    SELECT A.DISPLAY_CODE
    , B.EMP
    , A.SEQUENCE
    , MAX(DECODE(B.LN_ITEM, A.COLUMN_ITEM1, B.ITEM_AMT, 0)) "COL1"
    , MAX(DECODE(B.LN_ITEM, A.COLUMN_ITEM2, B.ITEM_AMT, 0)) "COL2"
    , MAX(DECODE(B.LN_ITEM, A.COLUMN_ITEM3, B.ITEM_AMT, 0)) "COL3"
    , MAX(DECODE(B.LN_ITEM, A.COLUMN_ITEM4, B.ITEM_AMT, 0)) "COL4"
    FROM MY_ITEM_DISPLAY A, MY_PAY_ITEMS B
    WHERE B.PAY_PRD = '2010-03'
    GROUP BY A.DISPLAY_CODE, B.EMP, A.SEQUENCE)
    WHERE DISPLAY_CODE = '01'
    AND EMP = '0000011'
    ORDER BY SEQUENCE
    My questions
    1) How do I do the PAY_PRD, KEY1, KEY2 constraint, can I use some form of ROW_NUMBER() OVER function ?
    2) How do I handle the fact that none of the 4 column LN_ITEMS may exist  (see sequence 40, none of those line items can exist)...  Ideally the above SQL should return
    01, 0000011, 10, <some number>, <some number>, <some number>, <some number>
    01, 0000011, 20, <some number>, <some number>, <some number>, <some number>
    01, 0000011, 30, <some number>, <some number>, <some number>, <some number>
    01, 0000011, 40, 0            , 0            , 0            , 0           
    I tried a UNION, but his prevented the view from eliminating the bulk of the MY_PAY_ITEMS rows, as it resolve ALL of MY_PAY_ITEMS instead of just retrieving rows for the one EMP passed to the view.  The same seems to be true for any outer joins.

    Hi, if i understood you properly, you need :
    select nvl(q.display_code,lag(q.display_code) over (order by rownum)) display_code,
           nvl(q.emp,lag(q.emp) over (order by rownum)) emp,
           m.s,
           nvl(q.COL1,0) COL1,
           nvl(q.COL2,0) COL2,      
           nvl(q.COL3,0) COL3,
           nvl(q.COL4,0) COL4,
           nvl(PAY_PRD,lag(q.PAY_PRD) over (order by rownum)) PAY_PRD,
           nvl(KEY1,lag(q.KEY1) over (order by rownum)) KEY1,
           nvl(KEY2,lag(q.KEY2) over (order by rownum)) KEY2  
    from(
    select d.display_code,
           t.emp,
           d.sequence,
           max(DECODE(t.LN_ITEM, d.COLUMN_ITEM1, t.ITEM_AMT, 0)) keep (dense_rank first order by to_date(t.pay_prd,'yyyy-mm') desc ) "COL1",
           max(DECODE(t.LN_ITEM, d.COLUMN_ITEM2, t.ITEM_AMT, 0)) keep (dense_rank first order by to_date(t.pay_prd,'yyyy-mm') desc ) "COL2",
           max(DECODE(t.LN_ITEM, d.COLUMN_ITEM3, t.ITEM_AMT, 0)) keep (dense_rank first order by to_date(t.pay_prd,'yyyy-mm') desc ) "COL3",
           max(DECODE(t.LN_ITEM, d.COLUMN_ITEM4, t.ITEM_AMT, 0)) keep (dense_rank first order by to_date(t.pay_prd,'yyyy-mm') desc ) "COL4",
           max(t.PAY_PRD) PAY_PRD,
           max(t.key1) keep (dense_rank first order by to_date(t.pay_prd,'yyyy-mm') desc ) key1,
           max(t.key2) keep (dense_rank first order by to_date(t.pay_prd,'yyyy-mm') desc ) key2
      from MY_PAY_ITEMS t
      join MY_ITEM_DISPLAY d
        on d.display_code = '01'
    where t.emp = '00000011'
    group by d.display_code, t.emp, d.sequence
    ) q
    full outer join (select level*10 s from dual connect by level <= 4) m
    on m.s = q.sequence
    DISPLAY_CODE
    EMP
    S
    COL1
    COL2
    COL3
    COL4
    PAY_PRD
    KEY1
    KEY2
    01
    00000011
    10
    101.1
    103.1
    104.1
    105.1
    2010-03
    008
    005
    01
    00000011
    20
    107.1
    113.1
    104.1
    109.1
    2010-03
    008
    005
    01
    00000011
    30
    101.1
    104.1
    109.1
    111.1
    2010-03
    008
    005
    01
    00000011
    40
    0
    0
    0
    0
    2010-03
    008
    005
    Ramin Hashimzade

  • SQL for View Definition using outer join

    Hello everyone,
    I am creating a view using the statement below
    SELECT *
    FROM table_a A
    ,table_b B
    ,table_c C
    WHERE A.sg_code = B.sg_code and
    B.st_code = 'E' and
    A.sg_code = C.sg_code(+) and
    C.st_code = 'T'
    The structure of the view is as follows
    View
    sg_code| Name | start_date | end_date |
    1 | Test |13-03-2008 | NULL |
    Table_a
    sg_code,Name
    Table_b
    sg_code,st_code,actual_date
    the view can have a null for the column 'end_date'
    This means there will not be a record inserted in the Table_b for end_date=null, there will only be a record for actual_date=start_date
    In this scenario when I query the view I am not seeing the newly created record just because there is a condition "C.st_code = 'T'" with the outer join on the sg_code.
    When I look into the individual tables I see the records.
    Table A
    Pg_code,Name
    1 Test
    Table B
    Id pg_code As_of_date
    1 1 13-03-2008
    How should I modify my view definition so that I can query the view even if there is a null for 'end_date'
    Thanks
    fm

    the last line should be:
    C.st_code(+) = 'T'
    by failing to include the (+) on that line, you made it NOT an outer join. an outer joined table must be outer joined on every where criteria, including to constants.

  • 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.

  • How to outer join within a view link from (VO-VL-VO)

    I've got a table that stores the values of pre-defined attributes.
    I'd like to create an advancedTable region that shows all of the attributes with or without values, in my view object i have....
    select attribute, value
    from attributes, values
    where attributes.attribute_id = values.attribute_id (+)
    This is working, but a have another view object that is the master and this is the details.
    How can I do an outer join on the view link from master to detail? A simple (+) in the where condition does not do the trick.
    If I try anything fancy within the view link, I get a JBO-27122.
    Thank you,
    Jerry.

    Understand the concept of VL. Vl is nothing but a link between two VOs, with one VO row column serve as binding column for another VO.If u understand this u go to VL wizard and make VL declaratively. If not, refer to dev guide to know about VL.
    --Mukul                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Generate a where clause with outer join criteria condition: (+)=

    Hi,
    In my search page, I use Auto Customization Criteria mode, and I build where clause by using get Criteria():
    public void initSrpQuery(Dictionary[] dic, String userName) {
    int dicSize = dic.length;
    StringBuffer whereClause = new StringBuffer(100);
    Vector parameters = new Vector(5);
    int clauseCount = 0;
    int bindCount = 1;
    for(int i=0; i < dicSize; i++){
    String itemName = (String)(dic.get(OAViewObject.CRITERIA_ITEM_NAME));
    Object value = dic[i].get(OAViewObject.CRITERIA_VALUE);
    String joinCondition = (String)dic[i].get(OAViewObject.CRITERIA_JOIN_CONDITION);
    String criteriaCondition = (String)dic[i].get(OAViewObject.CRITERIA_CONDITION);
    String criteriaDataType = (String)dic[i].get(OAViewObject.CRITERIA_DATATYPE);
    String viewAttributename = (String)dic[i].get(OAViewObject.CRITERIA_VIEW_ATTRIBUTE_NAME);
    String columnName = findAttributeDef(viewAttributename).getColumnNameForQuery();
    if((value != null) /*&& (!("".equals((String).trim())))*/){
    if(clauseCount > 0){
    whereClause.append(" AND ");
    whereClause.append(columnName + " " + criteriaCondition + " :");
    whereClause.append(++bindCount);
    parameters.addElement(value);
    clauseCount++;
    If I want to generate following where clause:
    select
    ,emp.name
    ,emp.email
    ,emp.salesrep_number
    ,comp.name
    ,gs.srp_goal_header_id
    ,gs.status_code
    ,gs.start_date
    ,gs.end_date
    from g2c_goal_shr_emp_assignments_v emp
    ,jtf_rs_salesreps rs
    ,xxg2c_srp_goal_headers_all gs
    ,cn_comp_plans_all comp
    where 1 = 1
    and rs.salesrep_id = gs.salesrep_id (+)
    and gs.comp_plan_id = comp.comp_plan_id (+)
    and gs.period_year (+) = :1 -- :1 p_fiscal_year
    How can I generate a where clause with outer join : gs.period_year (+) = :1 ? Will I get '(+)=' from get(OAViewObject.CRITERIA_CONDITION)?
    thanks
    Lei

    If you are using SQL-Plus or Reports you can use lexical parameters like:
    SELECT * FROM emp &condition;
    When you run the query it will ask for value of condition and you can enter what every you want. Here is a really fun query:
    SELECT &columns FROM &tables &condition;
    But if you are using Forms. Then you have to change the condition by SET_BLOCK_PROPERTY.
    Best of luck!

  • View with outer join results wrong number of rows

    Hi,
    When i run a query on a view it returns 2 rows(2 distinct rows), when i run the same query with the select statement which the view is created , it returns only 1 row. According to data the 1 row result is correct, how come twi results. A coding sample as follows. Any help is most appreciated.
    I have a view created based on a outer join of two views in the format;
    create or replace view view1 as
    select ord.order_no order_no,
    ord.del_type del_type,
    det.qty qty
    from detail_view det, order_view ord
    where det.site(+) = ord.site
    and det.part(+) = ord.part
    and nvl(ord.del_type,'_NULL_') <> 'F'
    with read only;
    detail_view & order_view themselves have several group by/sum and union Alls.
    When i run the query on this view
    [Select * from View1 where order_no = 'A30' And del_type = 'B']
    it returns 2 distinct rows. But when i run the select statement which created the View1 with the query it returns only one row!!
    What did i do wrong?
    Thanks
    Sanjeewa

    I cannot reproduce this :
    SCOTT@LSC01> create table detail_view(qty number,site number,part number);
    Table created.
    SCOTT@LSC01> create table order_view(order_no varchar2(10), del_type varchar2(1), site number,part number);
    Table created.
    SCOTT@LSC01>
    SCOTT@LSC01> create or replace view view1 as
      2  select ord.order_no order_no,
      3  ord.del_type del_type,
      4  det.qty qty
      5  from detail_view det, order_view ord
      6  where det.site(+) = ord.site
      7  and det.part(+) = ord.part
      8  and nvl(ord.del_type,'_NULL_') <> 'F'
      9  with read only;
    View created.
    SCOTT@LSC01>
    SCOTT@LSC01> insert into order_view values ('A30','B',1,2);
    1 row created.
    SCOTT@LSC01> insert into order_view values ('A30','B',1,2);
    1 row created.
    SCOTT@LSC01>
    SCOTT@LSC01> Select * from View1 where order_no = 'A30' And del_type = 'B';
    ORDER_NO   D        QTY
    A30        B
    A30        B
    SCOTT@LSC01>
    SCOTT@LSC01> select ord.order_no order_no,
      2  ord.del_type del_type,
      3  det.qty qty
      4  from detail_view det, order_view ord
      5  where det.site(+) = ord.site
      6  and det.part(+) = ord.part
      7  and nvl(ord.del_type,'_NULL_') <> 'F' ;
    ORDER_NO   D        QTY
    A30        B
    A30        Bwhat is your version?

  • Implementing Outer join Views in creating Generic datasource

    Guys,
    Iam bringing the Purchase document level data from R/3  into BW.I have couple
    of other Ztables also from which i need to collect the information.So iam going to create a generic datasource based on the view.
    In case of Database view it is taking inner join, which is undesirable since the
    final data coming out of view will be reduced as we join the main base tables with ztables..Since Ztables may have very less data.And inner join gives complete information only if all tables contain the information given out in the view output.
    One option is to use maintainance view which uses outer join. Is it recommendable
    to use maintainance view in case of basing the Generic datasources on the view.
    Please inform me if any of you have done generic datasources using database view.Any idea in this regard is welcome.

    Hi,
    I think you may have to develop your Generic Datasorce with "Function Module" since there is no common field.
    Regards,
    Suman

  • Views-Outer joins

    Hi All,
           We are using generic extraction for extracting data from PM module using views. We are getting data only if there is a match on the join condition i.e. if I am using table-A and table-B and the join condition is table-A.id=table-B.id , then we are getting data only when we have match.If  table-A.id  is null  then we are not getting any record at all . Can we give outer join some where?
    Thanks for the Help
    Balraj

    Hi,
    I am not aware of a way doing that with generic extraction based on a ABAP view.
    Perhaps with an infoset (SQ02) you'll be able to achieve that but I am not sure.
    Finally you can write your own extractor to achieve your requirement. You have an example of extractor with function module RSAX_BIW_GET_DATA_SIMPLE (SE37).
    hope this helps...
    Olivier.

  • Try this one again, outer join with inline views

    Posted this before and got no response from anyone. Can anyone advise ?
    does anyone have an example of inline views combined with outer joins in the same statement ? - am currently converting app from sqlserver to oracle and sqlserver view has many left outer joins in from the same table as well as part of the outer join conditions being a subquery e.g.
    select ...
    from a left outer join b left outer join c
    on a.col = b.col and
    c.col = a.col and
    a.othercol = ((select ..
    from d
    where ...)
    OR (select ...
    from e
    where ...))
    where ....
    sometimes they are just mutliple part left outer joins but as many as 10. I guess I have to convert these to inline views then outer join to that, but not 100% sure. There may be a better way ?
    null

    select ...
    from a,b,(select ...) dummyTable
    where a.col = b.col(+)
    AND a.col = dummyTable (+)
    AND b.col = c.col(+)
    AND ....

  • Outer join for a database view

    Dear Experts,
    Could you tell me what is the outer join and the example of this?
    Is it possible I can create an outer join view for generic extraction?
    Thanks.
    Arthur

    This is what a nested loops would look like in ABAP.  It is not a function module, but it could be made into one very easily.
    REPORT zz_temp.
    DATA: l_t_tstc    TYPE TABLE OF tstc,
          l_t_tstct   TYPE TABLE OF tstct,
          l_s_tstc    TYPE tstc,
          l_s_tstct   TYPE tstct.
    SELECT *
    INTO CORRESPONDING FIELDS OF l_s_tstc
    FROM tstc AS t.
      SELECT tt~ttext
      INTO CORRESPONDING FIELDS OF l_s_tstct
        FROM tstct AS tt
        WHERE tt~tcode = l_s_tstc-tcode
        AND tt~sprsl = sy-langu.
      ENDSELECT.
      WRITE:/ l_s_tstc-tcode,l_s_tstct-ttext.
    ENDSELECT.

Maybe you are looking for

  • Hp fails in commitment

    reference no.:8035171957  dear friends, never ever forever in your entire life buy an Hp product. I bought  hp pavillion dv6 series back from india in september.and i was happy initially with the product but once i came to Uk in october for my master

  • Need to add a column in front in my current Vb script

     Attached is the script that I use for copying text from multiple files and transfering them to the excell sheet, listed below is my current outout in excell. Need a column in front for dates for all the rows. The date is also contained in the text f

  • Control Flex application using presentation clicker

    I am building an application using Flex and need the ability to navigate through a "table of Contents" list using a presentation clicker, similar to navigating through a powerpoint presentation. I have been searching through the forum most of the day

  • Discussion not appearing in Pending Moderator Items

    A customer posted a query as a comment in this document: http://scn.sap.com/docs/DOC-43224 I asked him to create a discussion and he says he did and it is being Moderated, but I do not see it in my Pending Moderator Items. Why not?

  • ABAP Dump when selecting Calendar Field for selection in Working Time reports

    Hi Team, Out client gets a weird issue, when he selects date from selection he gets dump, this is happening only in his system, If he tries from his same user id from different machine, he is not getting the error. Dump details below What happened?