Question - View with a join based on two unequal strings.

Hello -
First my apologies for the likely novice question.
I'm creating a view based on two tables as such:
SELECT *
FROM table1 LEFT OUTER JOIN table2 ON table1.string = table2.string AND table1.number = table2.number
Problem: table1.string looks like "A00A01%%%" and table2.string looks like "A1" (which would correspond to "A00A01%%%".
Question: Can I create the join based on the 4th and 6th character of the string = the other string, or should I create a view with a formula creating a new field and then create a second view? (Note: creating or changing the field in the original table is not an option).
Thank you.

Hi,
Yes, you can do that. Join conditions don't have to be as simple as "ON a.col1 = b.col2"; they can involve functions, like CONCAT and SUBSTR.
For example:
FROM            table1
LEFT OUTER JOIN table2
ON              SUBSTR (table1.string, 4, 1)
                ||
                SUBSTR (table1.string, 6, 1) = table2.string
...The query might be faster if you create a function-based index on the join condition from table1. This does not require changing table1 itself. (For a LEFT OUTER JOIN, like this, it probably won't matter.)

Similar Messages

  • OLAP on 11g and Materialised Views with Multiple Value-Based Hierarchies

    Hello OLAPians
    I am trying to setup Orable BIEE to report on an OLAP cube with pre-aggregated data. As OBIEE is not able to hook into the OLAP directly i have to create an SQL cubeview.
    Currently i am on a 10g OLAP environment and am using the oracle sample SQL cubeview generator to create an SQLview of my cube.
    The cube itself has multiple dimensions and these dimensions have multiple VALUE-based (ragged) hierarchies and dimension members can be shared across hierarchies also.
    Initially i had a problem running the view generator plugin because there is a bug within it that does not finish if there are multiple value-based hierarchies present. I was able to get around this by manually editing the limitmap for the cubeview and manually creating the SQL view.
    The question that i want to ask is how robust is the 11g materialised views with multiple value-based hierarchies and the sharing of dimension members across different hierarchies?
    Has anyone successfully been able to create a cubeview and import it into OBIEE without the hassle of manually editing the limitmap?
    A problem arises with the value-based setup whereby if the client creates a newer depth in the ragged hierarchy, i need to manually create the limitmap and the cube-view over again, and then re-map the BI Administration mappings.

    The simple answer to your question,
    how robust is the 11g materialised views with multiple value-based hierarchies...?is that materialized views are not supported on top of value-based hierarchies in 11g. The reason is that it is not possible to write a reasonable SQL statement that aggregates a fact over a value-based hierarchy. Such a SQL statement is necessary if we want to create a rewritable MV on top of the cube.
    But I suspect this is not what you are really asking. If you are trying to set up OBIEE on top of the cube in 10g using the view generator, then you will probably want to use the "ET VIEWS" that are generated automatically in 11g. These are generated whether or not you enable materialized views on top of your cube. I am not aware of any issues with the generated value-based hierarchy view support in 11g. Members may be shared between value hierarchies and you will not need to generate or modify limit maps.

  • How do I update a view with a join

    I have a module with database block based on a view with joins, so I am not able to perform insert, update & delete directly.
    Therefore I created an unbound item that can be changed. The relevant database record is searched and updated.
    So, with above work around, insert, update & delete is possible.
    This works just fine.
    Now, the 'save icon' in the menu (diskette icon), does not get activated automatically when there are changes to be saved. This is because the view is not changed.
    So, I enable the 'save icon' manually in the when-validate-item trigger. But now when I navigate to another record, the 'save icon' gets de-activated by QMS/headstart code. This is because the view is not changed.
    So, I tried set_record_property (CHANGED_STATUS) to let the application
    know there are changes to be saved.
    But then, I get an error:
    * FRM-40654: Record has been updated by another user. Re-query block to see
    change.
    What is the proper way to handle this problem?
    null

    Peter,
    I think you've gone down the wrong track with your workaround.
    You should base your form on the view and allow update and insert to the view just as if it was a table.
    If you are using Oracle 8i, create an INSTEAD-OF trigger on the view in the database which redirects the DML to insert or update the appropriate table(s) instead of the view.
    If you are pre Oracle 8i, in the form you can create on-insert, on-update, and on-delete triggers to redirect the DML to the appropriate table.
    The only other tricky situation comes if you have items in your form that are server-derived (in the TAPI) of the table(s) in question. If so, you must explicitly code the form to retrieve these server-derived values. Also note that with a view, you cannot have a server derived primary key since there would be no way to retrieve it in the form. (Views don't have a rowid.) You must derive primary key columns in the form when the form is based on the view.
    Regards,
    Lauri

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

  • Maintenance view with MARA joined twice

    Hello,
    I have a Z table which contains 2 fields containing material number, say: MATNR_1 and MATNR_2. Both have foreign keys pointing to MARA table.
    Now I'd like to create a maintenance view for that Z table which will contain texts for both of those matnr fields, taken from MAKT table. So I need a maintenance view which has that Z table as the main table of the view and MARA+MAKT tables joined <u>twice</u>: first for the field MATNR_1 and next for field MATNR_2.
    It looks like it is impossible to achieve by just clicking in SE11 - the system takes only the first matnr field into account (MATNR_1) and joining MARA for the second time (for field MATNR_2) seems not possible.
    Has anyone an idea how to achieve this ?

    I found a solution myself - actually a workaround, here it is if someone is interested:
    You can have data from a secondary table (a table that you cannot join by defining the view) filled "manually" at the screen level. When you generate a maintenance objects with the maintenance generator, modify the generated screen by adding a new field to it (for data that you need to be displayed). In PBO of that screen call your additional PBO module which just reads the data from the db table (or from anywhere you want) and fills that field.
    You can check standard transaction FI12 to have an example: field BNKA-BANKA is filled exactly with this technique (see PBO of that screen).

  • Problem with object view with primary-key based object identifier

    Hello!
    I met such problem.
    t1 is persinstent-capable class:
    class t1 : public PObject { .... };
    T1OV is object view, based on object table T1OT
    I1 is primary key of the table T1OT.
    Next code:
    t1* t = new (conn, "T1OV") t1(...);
    conn->commit();
    try
    t->markDelete();
    conn->commit(); // exception throws here
    Works fine if T1OV defined as:
    create view t1ov of t1 with object identifier default
    as select * from t1ot;
    And throws an exception
    "ORA-22883: object deletion failed"
    if:
    create view t1ov of t1 with object identifier (I1)
    as select * from t1ot;
    Such problem also occurs when object view is based on relational table/view (OID is primary-key based).
    Also it occurs when
    t->markModified() used insted of t->markDelete()
    I am using Oracle 9i second release for windows and
    MS VC++
    Thank You

    http://download-uk.oracle.com/docs/cd/B10501_01/server.920/a96540/statements_85a.htm#2065512
    You can specify constraints on views and object views. You define the constraint at the view level using the out_of_line_constraint clause. You define the constraint as part of column or attribute specification using the inline_constraint clause after the appropriate alias.
    Oracle does not enforce view constraints. However, operations on views are subject to the integrity constraints defined on the underlying base tables. This means that you can enforce constraints on views through constraints on base tables.
    Restrictions on View Constraints
    View constraints are a subset of table constraints and are subject to the following restrictions:
    You can specify only unique, primary key, and foreign key constraints on views. However, you can define the view using the WITH CHECK OPTION clause, which is equivalent to specifying a check constraint for the view.
    Because view constraints are not enforced directly, you cannot specify INITIALLY DEFERRED or DEFERRABLE.
    View constraints are supported only in DISABLE NOVALIDATE mode. You must specify the keywords DISABLE NOVALIDATE when you declare the view constraint, and you cannot specify any other mode.
    You cannot specify the using_index_clause, the exceptions_clause clause, or the ON DELETE clause of the references_clause.
    You cannot define view constraints on attributes of an object column.
    Rgds.

  • Materialized View with recursive join

    Why is this not allowed?
    create materialized view bone_mv
    refresh complete
    on commit
    as
    select
    a.pk
    from
    tablea a,
    tableb b,
    tableb b2
    where
    tablea.col1 = b.col1 and
    tablea.col2 = b2.col2
    If I use "on demand" there is no problem.

    Hi,
    Have you managed to overcome this problem? If so, could you please let me know.
    Thanks
    Raja

  • Are Cube organized materialized view with Year to Date calculated measure eligible for Query Rewrite

    Hi,
    Will appreciate if someone can help me with a question regarding Cube organized MV (OLAP).
    Does cube organized materialized view with calculated measures based on time series  Year to date, inception to date  eg.
    SUM(FCT_POSITION.BASE_REALIZED_PNL) OVER (HIERARCHY DIM_CALENDAR.CALENDAR BETWEEN UNBOUNDED PRECEDING AND CURRENT MEMBER WITHIN ANCESTOR AT DIMENSION LEVEL DIM_CALENDAR."YEAR")
    are eligible for query rewrites or these are considered advanced for query rewrite purposes.
    I was hoping to find an example with YTD window function on physical fact dim tables  with optimizer rewriting it to Cube Org. MV but not much success.
    Thanks in advance

    I dont think this is possible.
    (My own reasoning)
    Part of the reason query rewrite works for base measures only (not calc measures in olap like ytd would be) is due to the fact that the data is staged in olap but its lineage is understandable via the olap cube mappings. That dependency/source identification is lost when we build calculated measures in olap and i think its almost impossible for optimizer to understand the finer points relating to an olap calculation defined via olap calculation (olap dml or olap expression) and also match it with the equivalent calculation using relational sql expression. The difficulty may be because both the olap ytd as well as relational ytd defined via sum() over (partition by ... order by ...) have many non-standard variations of the same calculation/definition. E.g: You can choose to use or choose not to use the option relating to IGNORE NULLs within the sql analytic function. OLAP defn may use NASKIP or NASKIP2.
    I tried to search for query rewrite solutions for Inventory stock based calculations (aggregation along time=last value along time) and see if olap cube with cube aggregation option set to "Last non-na hierarchical value" works as an alternative to relational calculation. My experience has been that its not possible. You can do it relationally or you can do it via olap but your application needs to be aware of each and make the appropriate backend sql/call. In such cases, you cannot make olap (aw/cubes/dimensions) appear magically behind the scenes to fulfill the query execution while appearing to work relationally.
    HTH
    Shankar

  • Query rewrites with Nested materialized views with different aggregations

    Platform used : Oracle 11g.
    Here is a simple fact table (with measures m1,m2) and dimensions (a) Location (b) Calendar and (c) Product. The business problem is that aggregation operator for measure m1,m2 are different along location dimension and Calendar dimension. The intention is to preaggregate the measures for a product along the calendar dimension and Location dimension and store it as materialized views.
    The direct option is to define a materialized view with Inline queries (Because of the different aggrergation operator, it is not possible to write a query without Inline query). http://download-uk.oracle.com/docs/cd/B28359_01/server.111/b28313/qradv.htm#BABEAJBF documents the limitations that it works only for 'Text match' and 'Equivalent queries' and that is too limiting.
    So decided to have nested materialized view, with first view having just joins(my_dim_mvw_joins), the second view having aggregations along Calendar dimension (my_dim_mvw_calendar) and third view having aggregations along the Location dimension(my_dim_mvw_location). Obviously I do not want the query I fire to know about materialized views and I fire it against the fact table. I see that for the fired query (Which needs aggregations along both Calendar and Location), is rewritten with just second materialized view but not the third. (Had set QUERY_REWRITE_INTEGRITY as TRUSTED) .
    Wanted to know whether there are limitations on Query Writes with nested materialized views? Thanks
    (Have given a simple testable example below. Pls ignore the values given in 'CALENDAR_IDs', 'PRODUCT_IDs' etc as they are the same for all the queries)
    -- Calendar hierarchy table
    CREATE TABLE CALENDAR_HIERARCHY_TREE
    (     "CALENDAR_ID" NUMBER(5,0) NOT NULL ENABLE,
    "HIERARCHY1_ID" NUMBER(5,0),
    "HIERARCHY2_ID" NUMBER(5,0),
    "HIERARCHY3_ID" NUMBER(5,0),
    "HIERARCHY4_ID" NUMBER(5,0),
    CONSTRAINT "CALENDAR_HIERARCHY_TREE_PK" PRIMARY KEY ("CALENDAR_ID")
    -- Location hierarchy table
    CREATE TABLE LOCATION_HIERARCHY_TREE
    (     "LOCATION_ID" NUMBER(3,0) NOT NULL ENABLE,
    "HIERARCHY1_ID" NUMBER(3,0),
    "HIERARCHY2_ID" NUMBER(3,0),
    "HIERARCHY3_ID" NUMBER(3,0),
    "HIERARCHY4_ID" NUMBER(3,0),
    CONSTRAINT "LOCATION_HIERARCHY_TREE_PK" PRIMARY KEY ("LOCATION_ID")
    -- Product hierarchy table
    CREATE TABLE PRODUCT_HIERARCHY_TREE
    (     "PRODUCT_ID" NUMBER(3,0) NOT NULL ENABLE,
         "HIERARCHY1_ID" NUMBER(3,0),
         "HIERARCHY2_ID" NUMBER(3,0),
         "HIERARCHY3_ID" NUMBER(3,0),
         "HIERARCHY4_ID" NUMBER(3,0),
         "HIERARCHY5_ID" NUMBER(3,0),
         "HIERARCHY6_ID" NUMBER(3,0),
         CONSTRAINT "PRODUCT_HIERARCHY_TREE_PK" PRIMARY KEY ("PRODUCT_ID")
    -- Fact table
    CREATE TABLE RETAILER_SALES_TBL
    (     "PRODUCT_ID" NUMBER,
    "PRODUCT_KEY" VARCHAR2(50 BYTE),
    "PLAN_ID" NUMBER,
    "PLAN_PERIOD_ID" NUMBER,
    "PERIOD_ID" NUMBER(5,0),
    "M1" NUMBER,
    "M2" NUMBER,
    "M3" NUMBER,
    "M4" NUMBER,
    "M5" NUMBER,
    "M6" NUMBER,
    "M7" NUMBER,
    "M8" NUMBER,
    "LOCATION_ID" NUMBER(3,0),
    "M9" NUMBER,
    CONSTRAINT "RETAILER_SALES_TBL_LOCATI_FK1" FOREIGN KEY ("LOCATION_ID")
    REFERENCES LOCATION_HIERARCHY_TREE ("LOCATION_ID") ENABLE,
    CONSTRAINT "RETAILER_SALES_TBL_PRODUC_FK1" FOREIGN KEY ("PRODUCT_ID")
    REFERENCES PRODUCT_HIERARCHY_TREE ("PRODUCT_ID") ENABLE,
    CONSTRAINT "RETAILER_SALES_TBL_CALEND_FK1" FOREIGN KEY ("PERIOD_ID")
    REFERENCES CALENDAR_HIERARCHY_TREE ("CALENDAR_ID") ENABLE
    -- Location dimension definition to promote query rewrite
    create DIMENSION LOCATION_DIM
    LEVEL CHAIN IS LOCATION_HIERARCHY_TREE.HIERARCHY1_ID
    LEVEL CONSUMER_SEGMENT IS LOCATION_HIERARCHY_TREE.HIERARCHY3_ID
    LEVEL STORE IS LOCATION_HIERARCHY_TREE.LOCATION_ID
    LEVEL TRADING_AREA IS LOCATION_HIERARCHY_TREE.HIERARCHY2_ID
    HIERARCHY PROD_ROLLUP (
    STORE CHILD OF
    CONSUMER_SEGMENT CHILD OF
    TRADING_AREA CHILD OF
    CHAIN
    -- Calendar dimension definition
    create DIMENSION CALENDAR_DIM
    LEVEL MONTH IS CALENDAR_HIERARCHY_TREE.HIERARCHY3_ID
    LEVEL QUARTER IS CALENDAR_HIERARCHY_TREE.HIERARCHY2_ID
    LEVEL WEEK IS CALENDAR_HIERARCHY_TREE.CALENDAR_ID
    LEVEL YEAR IS CALENDAR_HIERARCHY_TREE.HIERARCHY1_ID
    HIERARCHY CALENDAR_ROLLUP (
    WEEK CHILD OF
    MONTH CHILD OF
    QUARTER CHILD OF
    YEAR
    -- Materialized view with just joins needed for other views
    CREATE MATERIALIZED VIEW my_dim_mvw_joins build immediate refresh complete enable query rewrite as
    select product_id, lht.HIERARCHY1_ID, lht.HIERARCHY2_ID, lht.HIERARCHY3_ID, lht.location_id, cht.HIERARCHY1_ID year,
    cht.HIERARCHY2_ID quarter, cht.HIERARCHY3_ID month, cht.calendar_id week, m1, m3, m7, m9
    from retailer_sales_tbl RS, calendar_hierarchy_tree cht, location_hierarchy_tree lht
    WHERE RS.period_id = cht.CALENDAR_ID
    and RS.location_id = lht.location_id
    and cht.CALENDAR_ID in (10,236,237,238,239,608,609,610,611,612,613,614,615,616,617,618,619,1426,1427,1428,1429,1430,1431,1432,1433,1434,1435,1436,1437,1438,1439,1440,1441,1442,1443,1444,1445,1446,1447,1448,1449,1450,1451,1452,1453,1454,1455,1456,1457,1458,1459,1460,1461,1462,1463,1464,1465,1466,1467,1468,1469,1470,1471,1472,1473,1474,1475,1476,1477)
    AND product_id IN (5, 6, 7, 8, 11, 12, 13, 14, 17, 18, 19, 20)
    AND lht.location_id IN (2, 3, 11, 12, 13, 14, 15, 4, 16, 17, 18, 19, 20)
    -- Materialized view which aggregate along calendar dimension
    CREATE MATERIALIZED VIEW my_dim_mvw_calendar build immediate refresh complete enable query rewrite as
    select product_id, HIERARCHY1_ID , HIERARCHY2_ID , HIERARCHY3_ID ,location_id, year, quarter, month, week,
    sum(m1) m1_total, sum(m3) m3_total, sum(m7) m7_total, sum(m9) m9_total,
    GROUPING_ID(product_id, location_id, year, quarter, month, week) dim_mvw_gid
    from my_dim_mvw_joins
    GROUP BY product_id, HIERARCHY1_ID , HIERARCHY2_ID , HIERARCHY3_ID , location_id,
    rollup (year, quarter, month, week);
    -- Materialized view which aggregate along Location dimension
    CREATE MATERIALIZED VIEW my_dim_mvw_location build immediate refresh complete enable query rewrite as
    select product_id, year, quarter, month, week, HIERARCHY1_ID, HIERARCHY2_ID, HIERARCHY3_ID, location_id,
    sum(m1_total) m1_total_1, sum(m3_total) m3_total_1, sum(m7_total) m7_total_1, sum(m9_total) m9_total_1,
    GROUPING_ID(product_id, HIERARCHY1_ID, HIERARCHY2_ID, HIERARCHY3_ID, location_id, year, quarter, month, week) dim_mvw_gid
    from my_dim_mvw_calendar
    GROUP BY product_id, year, quarter, month, week,
    rollup (HIERARCHY1_ID, HIERARCHY2_ID, HIERARCHY3_ID, location_id)
    -- SQL Query Fired (for simplicity have used SUM as aggregation operator for both, but they will be different)
    select product_id, year, HIERARCHY1_ID, HIERARCHY2_ID,
    sum(m1_total) m1_total_1, sum(m3_total) m3_total_1, sum(m7_total) m7_total_1, sum(m9_total) m9_total_1
    from
    select product_id, HIERARCHY1_ID , HIERARCHY2_ID , year,
    sum(m1) m1_total, sum(m3) m3_total, sum(m7) m7_total, sum(m9) m9_total
    from
    select product_id, lht.HIERARCHY1_ID , lht.HIERARCHY2_ID , lht.HIERARCHY3_ID ,lht.location_id, cht.HIERARCHY1_ID year, cht.HIERARCHY2_ID quarter, cht.HIERARCHY3_ID month, cht.calendar_id week,m1,m3,m7,m9
    from
    retailer_sales_tbl RS, calendar_hierarchy_tree cht, location_hierarchy_tree lht
    WHERE RS.period_id = cht.CALENDAR_ID
    and RS.location_id = lht.location_id
    and cht.CALENDAR_ID in (10,236,237,238,239,608,609,610,611,612,613,614,615,616,617,618,619,1426,1427,1428,1429,1430,1431,1432,1433,1434,1435,1436,1437,1438,1439,1440,1441,1442,1443,1444,1445,1446,1447,1448,1449,1450,1451,1452,1453,1454,1455,1456,1457,1458,1459,1460,1461,1462,1463,1464,1465,1466,1467,1468,1469,1470,1471,1472,1473,1474,1475,1476,1477)
    AND product_id IN (5, 6, 7, 8, 11, 12, 13, 14, 17, 18, 19, 20)
    AND lht.location_id IN (2, 3, 11, 12, 13, 14, 15, 4, 16, 17, 18, 19, 20)
    GROUP BY product_id, HIERARCHY1_ID , HIERARCHY2_ID , HIERARCHY3_ID , location_id, year
    ) sales_time
    GROUP BY product_id, year,HIERARCHY1_ID, HIERARCHY2_ID
    This Query rewrites only with my_dim_mvw_calendar. (as saw in Query Plan and EXPLAIN_MVIEW). But we would like it to use my_dim_mvw_location as that has aggregations for both dimensions.

    blackhole001 wrote:
    Hi all,
    I'm trying to make my programmer's life easier by creating a database view for them to query the data, so they don't have to worry about joining tables. This sounds like a pretty horrible idea. I say this because you will eventually end up with programmers that know nothing about your data model and how to properly interact with it.
    Additionally, what you will get is a developer that takes one of your views and see's that of the 20 columns in it, it has 4 that he needs. If all those 4 columns comes from a simple 2 table join, but the view has 8 tables, you're wasting a tonne of resources by using the view (and heaven forbid they have to join that view to another view to get 4 of the 20 columns from that other view as well).
    Ideally you'd write stored routines that satisfy exactly what is required (if you are the database resource and these other programmers are java, .net, etc... based) and the front end developers would call those routines customized for an exact purpose.
    Creating views is not bad, but it's by no means a proper solution to having developers not learn or understand SQL and/or the data model.

  • The order doesn't work in my view with join between two lists. And now?

    Hi,
    I work with sharepoint 2010.
    I did the join between two list follow this
    post.
    I did it and everything is ok, but the order doesn't work.
    What can be it?
    Thanks
    K2rto'4 - Analista Sharepoint
    "Hoje melhor do que ontem, amanhã melhor do que hoje!" 改 善

    Hi,
    I've two lists in my view with join. The list A and the list B.
    I'm ordering the view with the column list A.
    The column list A it's a column for type lookup to list B's column.
    In my view i'm ordering with the column list A of type lookup.
    The view with join is not ordering in order growing.
    I want the view will be ordering by order growing.
    Do you understood?
    Hugs
    K2rto'4 - Analista Sharepoint
    "Hoje melhor do que ontem, amanhã melhor do que hoje!" 改 善

  • Query based on two views

    Hello ppl, I need your help.
    I got this query which is based on two views.
    View_1: x1, x2, x3, x4, day, xy
    View_2: y1, y2, y3, y4, day, xy
    By running a SELECT query on each view takes approx 2 minutes, yes there are lots of records.
    When I combine the query most of the time it times out. I think there is something wrong with my query.
    View_1 = View_2 on col xy and day, however I have to get the records from View_2 for the following day, i.e if day = 3 from View_1 and the record from View_2 should be coming from view_2
    at present my query is like this
    SELECT a.x1, a.x2, a.x3, a.x4, a.day, a.xy, b.y1, b.y2
    FROM view_1 a, view_2 b
    WHERE b.y2= 100
    AND a.xy = b.xy
    AND b.y1 = ( SELECT b.y1
    FROM view_1 a, view_2 b
    WHERE b.day = a.day + 1)
    ORDER BY a.x1
    This query gets called in a coldfusion page.
    P.S I can also ask the DBA to make me a new view based on the same columns as the query. Would that help with speed?

    I don't see any reason why my query shouldn't give
    you what you desire.
    View_1
    x1     x2     x3     x4     Day     XY
    2      3      23      32      3      2132
    3      3      2      3      4      2132
    4      3      43      32      5      2132
    View_2
    y1     y2     y3     y4     Day     XY
    4      100      13      32      3      2132
    5      100      4      3      4      2132
    7      100      43      32      5      2132
    5      100      23      12      6      2132
    Is it a coincidence that XY has the same value in your sample? Could it be different
    and at the same time participate in the desired result?
    SELECT     a.x1, a.x2, a.x3, a.x4, a.day, a.xy, b.y1, b.y2
    FROM     view_1 a
    ,     view_2 b
    WHERE     b.y2 = 100
    AND     a.xy = b.xy
    AND     b.day = a.day + 1
    ORDER BY a.x1
    >
    X1     X2     X3     X4     Day     XY     y1     y2
    2      3      23     32      3      2132      5      100
    3      3      2      3      4      2132      7      100
    4      3      43     32      5      2132      5      100
    According to the reply to my question above, it can be ok or not.
    That is why I proposd this (in case the reply were yes):
    SELECT a.x1, a.x2, a.x3, a.x4, a.day, a.xy, b.y1, b.y2
    FROM view_1 a, view_2 b, vew_1 c
    WHERE b.y2= 100
    AND a.xy = b.xy
    AND b.day = c.day + 1
    ORDER BY a.x1

  • ADF BC: Creating updatable VO based upon DB View with "instead of" trigger

    Hello all,
    I have got an interesting issue. I have an Oracle DB view that is used to hide some complexity in the underlying DB design (it does some unions). This view is updatable because we have created an "instead of" update trigger to update the correct table when a row is updated. This is working fine in SQL.
    Next, we have created an ADF Entity object based upon the view, specifying an appropriate PK for the DB View. Then, we have created an updatable VO based upon the EO. All well and good so far. The issue we have is in trying to commit changes to the DB - because the ADF BC framework is trying to lock the row to update (using SELECT ... FOR UPDATE), it's not working because of ORA-02014 - cannot select FOR UPDATE from view with DISTINCT, GROUP BY, etc.
    This leads me to thinking about overridding doSelect() on the EO as hinted here http://radio.weblogs.com/0118231/stories/2005/07/28/differenceBetweenViewObjectSelectAndEntityDoselectMethod.html
    As a temporary test, we have over-ridden the EO's doSelect to call super.doSelect(false) and it does work, although we will have lost update issues as detailed in Steve's article.
    My questions:
    1). Is overriding doSelect() the correct thing here? Perhaps there is a better way of handling this problem? I do have a base EO class from which all of the EO's extend, so adding this behavior should be straightforward.
    2). Does anyone have example doSelect implementation? I am thinking of overriding doSelect for my EO and calling super.doSelect (lock=false), but then I need to deal with some possible exceptions, no?
    Kind regards,
    John

    Hi John,
    I have exactly the same issue as you experienced back in January. I have a complex data modelling requirement which requires the need to pivot rows into columns using ROW_NUMBER() and PARTITION clauses. To hide the complexity from the middle tier, I have created a database view and appropriate INSTEAD OF triggers and mapped my EO to the view. I have overriden the lock() method on the EO implementation class (to avoid ORA-02014) and would like to try the same solution you used with the pl/sql call to lock the record.
    My question is, how did you manage the release of the lock if the transaction was not rolled back or committed by your application i.e. if the user closed the browser for instance.
    In my naivity, I would like to think that the BC4J framework would release any locks for the database session when it found the servlet session to be terminated however my concern is that the lock would persist and cause complications.
    Any assistance greatly appreciated (if you would be willing to supply your lock() method and pl/sql procedure logic I would be even more grateful!).
    Many thanks,
    Dave
    London

  • Materialized View with Joins

    Dear Dev/DBAs,
    I have the following scenario:
    SQL> CREATE TABLE T1 (ID NUMBER(3),NAME VARCHAR2(10));
    SQL> CREATE TABLE T2 (ID NUMBER(3),NAME VARCHAR2(10));
    The T1 contains records having the ID num from 10 to 80 and the T2 having the ID from 90 to 170
    SQL> SELECT * FROM T1 JOIN ALL SELECT * FROM T2
    It give all records in the 2 tables.
    I'm planning to create a materialized view (like CREATE MATERIALIZED VIEW V_TAB REFRESH ON COMMIT AS SELECT * FROM T1 JOIN ALL SELECT * FROM T2) and it seems i can't do with the error ORA-12054, further the oracle documentation says that materialized view can only be used with a simple join.
    Do you have another solution??
    Note that the materialized views can be used to improve queries.
    Thank you in advance

    Straight from the link I posted:
    *Restrictions on Fast Refresh on Materialized Views with UNION ALL*Materialized views with the UNION ALL set operator support the REFRESH FAST option if the following conditions are satisfied:
    * The defining query must have the UNION ALL operator at the top level.
    The UNION ALL operator cannot be embedded inside a subquery, with one exception: The UNION ALL can be in a subquery in the FROM clause provided the defining query is of the form SELECT * FROM (view or subquery with UNION ALL) as in the following example:
    CREATE VIEW view_with_unionall AS
    (SELECT c.rowid crid, c.cust_id, 2 umarker
    FROM customers c WHERE c.cust_last_name = 'Smith'
    UNION ALL
    SELECT c.rowid crid, c.cust_id, 3 umarker
    FROM customers c WHERE c.cust_last_name = 'Jones');
    CREATE MATERIALIZED VIEW unionall_inside_view_mv
    REFRESH FAST ON DEMAND AS
    SELECT * FROM view_with_unionall;
    Note that the view view_with_unionall satisfies the requirements for fast refresh.
    * Each query block in the UNION ALL query must satisfy the requirements of a fast refreshable materialized view with aggregates or a fast refreshable materialized view with joins.
    The appropriate materialized view logs must be created on the tables as required for the corresponding type of fast refreshable materialized view.
    Note that the Oracle Database also allows the special case of a single table materialized view with joins only provided the ROWID column has been included in the SELECT list and in the materialized view log. This is shown in the defining query of the view view_with_unionall.
    * The SELECT list of each query must include a maintenance column, called a UNION ALL marker. The UNION ALL column must have a distinct constant numeric or string value in each UNION ALL branch. Further, the marker column must appear in the same ordinal position in the SELECT list of each query block.
    * Some features such as outer joins, insert-only aggregate materialized view queries and remote tables are not supported for materialized views with UNION ALL.
    * Partiton Change Tracking (PCT)-based refresh is not supported for UNION ALL materialized views.
    * The compatibility initialization parameter must be set to 9.2.0 or higher to create a fast refreshable materialized view with UNION ALL.

  • Materialized View  with Joins and Possibilities of Partitioning

    Hi,
    We have a materialized view which has a data to query around 12 gb. The query goes some thing like
    this.
      Select a.c1,a.c2,b.c1,b.c2,c.c1,c.c2
      from a,b,c
      where a.c1=b.c1
      --and the where condition goes on...
      --i.e Basically joining 3 different tables with complex join conditions but without any group functions and subqueries.
       Now i have few questions here.
    Firstly as the Mview is created with joins we will have to create separate logs for each tables and we have did the same. The logs are created with rowid and sequence for better performance during refresh.
    Question No 1
    Is this is a best approach for materializing a query with complex join conditions. Or Is it better to make 3 different materialized views for each 3 tables and join those 3 MViews and write a query for my report. I ask this question just to make sure the refresh time is brought down by this method. But as such as we have created 3 different logs for 3 tables the refresh must be happening separately.
    Question No 2
    Data is likely to grow faster and faster on this. So we have a idea of making this a partitioned Mview. Can the Pro's advice me on this and suggest me the right practice for the same and help me to correct links from where i can pick a example and continue from there.
    Question No 3
    How to find whether the materialized view has refreshed on a fast mode or complete mode after the last refresh.
    Apart from querying and checking the rowid which i feel is quiet cumbersome for a mview with a data volume like what we have. By default when i see the info in TOAD for this Mview it shows Refresh Mode as "Force". But how to ascertain this.
    Thanks in anticipation for a good round of discussion

    Hi,
    We have a materialized view which has a data to query around 12 gb. The query goes some thing like
    this.
      Select a.c1,a.c2,b.c1,b.c2,c.c1,c.c2
      from a,b,c
      where a.c1=b.c1
      --and the where condition goes on...
      --i.e Basically joining 3 different tables with complex join conditions but without any group functions and subqueries.
       Now i have few questions here.
    Firstly as the Mview is created with joins we will have to create separate logs for each tables and we have did the same. The logs are created with rowid and sequence for better performance during refresh.
    Question No 1
    Is this is a best approach for materializing a query with complex join conditions. Or Is it better to make 3 different materialized views for each 3 tables and join those 3 MViews and write a query for my report. I ask this question just to make sure the refresh time is brought down by this method. But as such as we have created 3 different logs for 3 tables the refresh must be happening separately.
    Question No 2
    Data is likely to grow faster and faster on this. So we have a idea of making this a partitioned Mview. Can the Pro's advice me on this and suggest me the right practice for the same and help me to correct links from where i can pick a example and continue from there.
    Question No 3
    How to find whether the materialized view has refreshed on a fast mode or complete mode after the last refresh.
    Apart from querying and checking the rowid which i feel is quiet cumbersome for a mview with a data volume like what we have. By default when i see the info in TOAD for this Mview it shows Refresh Mode as "Force". But how to ascertain this.
    Thanks in anticipation for a good round of discussion

  • Materialized view with join

    In 10g release 2,I tried to create following materialized view with join:
    test_link is a normal table
    test_geom is a table contains a column in SDO_GEOMETRY
    CREATE MATERIALIZED VIEW LOG ON test_link with rowid
    CREATE MATERIALIZED VIEW LOG ON test_geom with rowid,primary key
    CREATE MATERIALIZED VIEW MV_LINK USING INDEX REFRESH FAST ON DEMAND AS
    SELECT li.rowid link_rowid,geom.rowid geom_rowid,li.link_id,geom.link
    FROM test_link li, test_geom geom
    WHERE li.link_id=geom.link_id
    But I always got an error like:
    ORA-12015: cannot create a fast refresh materialized view from a complex query
    If I change the geometry table to another table, everything works fine.
    Anyone have ideas?

    Unfortunately, creating a fast refreshable materialized view on a join with one of the select columns being a user defined type (sdo_geometry is a user defined type) is not allowed. See 5303489 in the metalink bug database.
    You could do like the workaround in the article suggests and create two materialized views and then create a regular view on top.
    In our scenario, our materialized view also contains unions, so we would really like to have one physical object at the end of the day. One approach that we are currently investigating is to create the materialized view (MV1) without the geometry column, which makes it fast refreshable, and also create a materialized view (MV2) on the table containing the geometry column. MV2 is also fast refreshable. We then create a table (T3) that contains all of the columns from MV1, plus a geometry column. An insert, update, delete trigger on MV1 is created. The trigger is used to push all of the columns from MV1 to T3 and the geometry column from MV2 to T3. I have created the above in one of our test environments and haven't encountered any issues yet.
    Let me know if you come up with a better approach.

Maybe you are looking for

  • Adobe Acrobat 11 will not open files in IE 10.0.06

    Adobe Acrobat 11 will not open files in IE 10.0.06. Problem started about 2 months ago. It can open older files on computer but cannot open or downloadd any from internet. Using Office 2010. Already spent an hour with my computer tech support under w

  • MB_MIGO_BADI - Line item data inside CHECK_ITEMS method

    Hi All, I have implement MB_MIGO_BADI and i want to put a check inside the method CHECK_ITEMS where the importing parameter is line ID. How can I get the data for the line based on the line ID inside the check_items methods, so that I can make the cu

  • Annoying elementary problems with Lumia 800

    Hello all from noKIA and microSoft... Latest OS version upgraded 7.10.8773.98 but still elementary baby problems... 1. First incoming phone  call ring tone seconds are at full volume 30/30 despite Your setting... **bleep**??? Why these first seconds

  • Error 1417 and 1418

    I just updated my iTunes to 7.0, and now i cannot update nor restore my iPod, it says there is an error. When I update the iPod software it says error 1417, restore with error 1418. Can someone please help me out? It would be greatly appreciated

  • CUIC hyperlink in report

    Is it possible to have an HTML hyperlink in a CUIC 10.5? I have a report I was using in CUIC 9 and CUIC 10 that had HTML code in the report data, and until 10.5 it was rendering this to provide a link and external image in the report.