Custom Materialized View

Hi
I am ha query regarding Materialized View .
Materialized View Query :
select * from emp@db1 where salary in ('1000','3000');
Scenario :
In the DB2 (Target DB) :
create materialized view emp_mv
refresh force on demand
as
select * from emp@db1 where salary in ('1000','3000');
Replication works fine .
In DB1 (Source DB) :
Update emp set salary=2000 where salary=1000 and empno=123;
Now in the DB2 (where my MV is located) , i want the existing record (salary=1000) to be still there and the new record (salary=2000) should not be present for empno=123
In DB1 (Source DB) :
Update emp set salary=3000 where salary=2000 and empno=123;
Now in the DB2 (where my MV is located) , i want the previous record (salary=1000) to be still there and the new record (salary=3000) should also be present for empno=123 (Now there should be tow records)
Is it possible ?
Any pointers is appreciated !
Thanks

A Materialized View is designed (intended) to give you a copy of data as the data exists in the source. If that row (with the pre-delete image) does not exist in the source, it should not exist in the MV.
How would you distinguish between the two images of the row at the MV site ? Which one is the "older" one and which is the "newer" one ? You'd have to write custom methods (tags, timestamps etc) to differentiate between the two rows.
A Materialized View is a generic solution. You cannot customize.
You have to define your own custom table (with the additional tagging methods) and your own procedures to replicate the two images of the same row. That is one of the uses of triggers. Before the row is updated, copy the preupdate image of the row (with additional column(s) for tagging the change) out to another table.
The "custom" MV can then be defined as a UNION of the two tables, the "master" table and the "audit trail" table.
You'll have to consider how you will handle DELETEs as well.
Hemant K Chitale

Similar Messages

  • Periodic refresh of Materialized View

    Hi,
    I am working in a Oracle database for Oracle E-Business Suite.
    In the database we have a custom materialized view defined as follow:
    CREATE MATERIALIZED VIEW APPS.XXCUS_NAME_MV
    <...>
    BUILD IMMEDIATE
    REFRESH FORCE ON DEMAND
    <....>
    From the below SQL I learn that the MV was refreshed during the night, I assume this is every night since i have executed the query for the last several days.
    SELECT OWNER, MVIEW_NAME, LAST_REFRESH_DATE, REFRESH_METHOD, REFRESH_MODE, BUILD_MODE
    FROM DBA_MVIEWS
    WHERE MVIEW_NAME LIKE 'XXCUS_NAME_MV%'
    APPS
    XXCUS_NAME_MV
    10-10-2013 2:00:14
    FORCE
    DEMAND
    IMMEDIATE
    However, I cannot find anywhere how this refresh is scheduled by means of a job?
    I tried below query but there are no scheduled jobs for  DBMS_REFRESH.REFRESH or DBMS_MVIEW.REFRESH.
    SELECT * FROM DBA_JOBS;
    Does anyone has an idea how the MV is refreshed automatically (periodically) other tahn by jobs?
    Thx!

    Try looking in the *_SCHEDULER_JOBS view. This is now the preferred means of scheduling jobs, though DBA_JOBs is still supported.
    this link might give you a good start:
    http://docs.oracle.com/cd/E11882_01/server.112/e25494/scheduse.htm

  • Leave a distinct value in a materialized view on two tables

    Hi and thank you for reading,
    I have the following problem. I am creating a materialized view out of two tables, with "where a.id = b.id".
    The resulting materialized view list several values twice. For example, one customer name has several contact details and thus the customer name is listed several times. Now I would like to join each customer name with just ONE contact detail, how can I do that? (Even if I would loose some information while doing this).
    Thanks
    Evgeny

    Hi,
    You can do this
    SELECT   deptno, empno, ename, job, mgr, hiredate, sal, comm
        FROM emp_test
    ORDER BY deptno;
        DEPTNO      EMPNO ENAME      JOB              MGR HIREDATE          SAL       COMM
            10       7782 CLARK      MANAGER         7839 1981-06-09       2450          
            10       7839 KING       PRESIDENT            1981-11-17       5000          0
            10       7934 MILLER     CLERK           7782 1982-01-23       1300          
            20       7566 JONES      MANAGER         7839 1981-04-02       2975          
            20       7902 FORD       ANALYST         7566 1981-12-03       3000          
            20       7876 ADAMS      CLERK           7788 1987-05-23       1100          
            20       7369 SMITH      CLERK           7902 1980-12-17        800          
            20       7788 SCOTT      ANALYST         7566 1987-04-19       3000          
            30       7521 WARD       SALESMAN        7698 1981-02-22       1250        500
            30       7844 TURNER     SALESMAN        7698 1981-09-08       1500          
            30       7499 ALLEN      SALESMAN        7698 1981-02-20       1600        300
            30       7900 JAMES      CLERK           7698 1981-12-03        950          
            30       7698 BLAKE      MANAGER         7839 1981-05-01       2850          
            30       7654 MARTIN     SALESMAN        7698 1981-09-28       1250       1400
    14 rows selected.
    SELECT CASE
              WHEN ROW_NUMBER () OVER (PARTITION BY deptno ORDER BY empno) =
                                                                         1
                 THEN deptno
           END deptno,
           empno, ename, job, mgr, hiredate, sal, comm
      FROM emp_test;
        DEPTNO      EMPNO ENAME      JOB              MGR HIREDATE          SAL       COMM
            10       7782 CLARK      MANAGER         7839 1981-06-09       2450          
                     7839 KING       PRESIDENT            1981-11-17       5000          0
                     7934 MILLER     CLERK           7782 1982-01-23       1300          
            20       7369 SMITH      CLERK           7902 1980-12-17        800          
                     7566 JONES      MANAGER         7839 1981-04-02       2975          
                     7788 SCOTT      ANALYST         7566 1987-04-19       3000          
                     7876 ADAMS      CLERK           7788 1987-05-23       1100          
                     7902 FORD       ANALYST         7566 1981-12-03       3000          
            30       7499 ALLEN      SALESMAN        7698 1981-02-20       1600        300
                     7521 WARD       SALESMAN        7698 1981-02-22       1250        500
                     7654 MARTIN     SALESMAN        7698 1981-09-28       1250       1400
                     7698 BLAKE      MANAGER         7839 1981-05-01       2850          
                     7844 TURNER     SALESMAN        7698 1981-09-08       1500          
                     7900 JAMES      CLERK           7698 1981-12-03        950          
    14 rows selected.Edited by: Salim Chelabi on 2009-09-14 08:13

  • Subquery in a Materialized View

    I have a requirement where we have to build a summary view to show a customer's latest transaction. There can be several million customers so I am thinking if a Materialized view that gets refreshed once every day is a good option here. This is a Datawarehouse application where the records get appended once every day. I would like a summarized materialized view that is dropped and refreshed every day morning.
    Here is the query that gets the latest order amount for each of the customer:
    SELECT cu.cust_name,
    od.order_amount
    FROM customers cu,
    orders od
    WHERE cu.cust_id = od.cust_id
    and od.order_date =
    (select max(order_date) from orders od
    where od.cust_id = cu.cust_id)
    My questions are:
    1) Is the materialized view a snapshot? Or does it go against the underlying table every time the MV is accessed, much like a regular view?
    2) I would like a snapshot type of solution here. Since there could be 100 million orders for 1 million customers, a summary snapshot of 1 million records would perform much better IMO. Correct me if I got it wrong.
    Thank you in advance for your help.

    Users query will be explicitly against the Mview.
    After doing some reading on the MView, I am more inclined to think that Mview is not an ideal solution for my requirement here.
    SELECT cu.cust_name,
    od.order_amount,
    MAX(od.order_date) over (PARTITION BY od.cust_id) max_date
    FROM customers cu,
    orders od
    WHERE cu.cust_id = od.cust_id
    The orders is a 20+ million records table. I thought by using a Mview that holds the maximum order date will avoid going to the orders table when users want to see that is the latest order date for a customer. However, the report requirements are such that the users will want to see what is the maximum order date within a certain date range. If this being the case, there is no point in using an Mview.
    Once again, pl correct me if my understanding is not correct.

  • Regd FAST refresh option in a Materialized view

    Hi All,
    I am using a pipeline function in which I am creating a table of records and a few cursors to fetch data from various tables.
    Now this PL/SQL table is being used to construct a Materialized view.
    Creation of Materialized view is happening fine but not with FAST refresh option. It gives an error " Cannot create a FAST refresh Materialized view from a complex query."
    The query which I have used for the view creation is
    CREATE MATERIALIZED VIEW CUSTOM.ABC
    PCTFREE 0
    BUILD IMMEDIATE
    REFRESH FAST ON DEMAND
    AS
    SELECT A.Number,
    A.Guarantors_Number,
    A.Guarantors_Name,
    A.Personal_Garantee_PCNT,
    A.Company, LG.Source_System,
    A.Type_of_Info,
    A.File_Gen_Date,
    A.Periodicity
    FROM
    TABLE(CUSTOM.CDM_LG_PACK_PF.CDM_LG_FUNC) A;
    where CDM_LG_PACK_PF is the package and CDM_LG_FUNC is the pipeline function I have written to fetch all the records.
    Please help me on how can I do a FAST refresh on this materialized view.
    Thanks in advance,
    Gaurav

    Welcome to the forum!
    FAST refresh doesn't mean that the operation is fast (time wise), it means it's an incremental refresh.
    If you have a complex query, you can't use a FAST refresh - that's what the exception tells you.

  • Customer Material Infomation Missing

    **Hello Friends,**
    **We have a scenario where we create Delivery without Referance to an Order and in the Invoice we see that Customer Material Information is not getting copied.In the Billing i see that it is taking referance from VBAP Table but in our case we don't have any referance to a Sales Order so it is not getting copied there. Is there any way we can make the changes in the copy control to make it appear in the Invoice as the Customer Material Information is already available in the Deliery document. This information is very vital for us as the Invoice Idocs should carry Customer Material Information which is not happening currently.*
    Customer Material Information  can be seen in the Invoice Item Tab -PO Data.
    Thanks in advance for your help
    Sunil

    The field on the invoice item PO data tab is VBAP-KDMAT.  It is a view to a non-existent sales order, so you cannot populate it with data on your type of invoice.
    HOWEVERu2026u2026you really need the CMIR data on the Idoc, right? 
    So use an invoice IDoc user exit to insert the appropriate segment. 
    My particular favorite exit for such things is INCLUDE ZXEDFU02, which is found in function module EXIT_SAPLVEDF_002.
    An Idoc type INVOIC02 should carry the customeru2019s material number in an E1EDP19 segment with qualifier QUALF=001.  Set up your exit to test for the existence of such a segment.  If it is not found, then query table KNMT for the KDMAT that you want and insert the new E1EDP19 segment at the appropriate index.

  • ORA-12096: error in materialized view log

    Hi All,
    I had created a fast refresh materialized view. Log was also created.
    Now i dropped the mv and the logs.
    But now every time i update or insert into this customer table i get error message.
    ORA-12096: error in materialized view log on Customer
    ORA-00942: table or view does not exist
    There are entries in the DBA_MVIEW_LOGS for customer table.
    Please suggest.

    Hi,
    What database version are you on?
    And do you have access to Metalink/My Oracle Support?
    Found this, by the way:
    ORA-12096: error in materialized view log on <table>
    If problems occur when you try to access a log file for a materialized view, the system issues an ORA-12096 error message which is followed by the actual error. If the ORA-12096 error message is accompanied by an ORA-00942 message, the problem may be due to an online reorganization that was only partially undone. In this case, you can drop the log file for the materialized view manually (after you have verified that it is no longer required):
    DROP MATERIALIZED VIEW LOG ON <table>;
    Edited by: hoek on Jul 29, 2009 2:15 PM

  • Track changes in Materialized view.

    Hi all,
    i would like to know if it is possibile to track changes in a Materialized view.
    1) i have a materialized view tha can be fast refreshed, built on remote tables
    2) base tables have, on remote DB, Materialized view log with rowid and primary key
    3) Changes in the base tables are not frequent so the refresh of my mv is very fast even if master tables have millions of records.
    I would like to know if it is possibile to insert into my materialized view the date of the refresh of the single record. In this way i can read only data that have changed in my MV. The problem is that even if only one row has changed i have to read all the data from my mview.
    thanks
    Fra
    Edited by: 859718 on 24-mag-2011 0.08

    Hi,
    firstly I must say - it's silly to refuse materialized view log. The impact of this solution is minimal and it's standard and reliable. Then you can use fast refresh and that is certaily the best for both - master and MV side. The MV log is just a table, where trigger stores rowid of changed rows. There are not other solution, bacause you need to do the same things as MV log funcionality.
    If you cannot make changes to the remote database, I see only one (but unreliable solution) - use the flashback query. Then you will be able to see row changes for some period in past. The information is read from undo tablespace so that the period length depends on remote database workload. It's risky to rely on information from UNDO tablespace, but you can write your own refresh with some special fucionailty - if flashback query returns the desired changes, refresh only changed rows, otherwise do complete refresh.
    SELECT
        ROWID,
        VERSIONS_STARTSCN,
        VERSIONS_ENDSCN,
        VERSIONS_OPERATION,
        t.*
    FROM master_table versions between timestamp minvalue and maxvalue t
    where VERSIONS_STARTSCN is not null;Columns description is for example here:
    http://www.oracle-developer.net/display.php?id=320
    And if you wrote your own custom refresh function you could add the timestamp functionality too :-)

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

  • To Integrate materialized view Refresh in DAC Execution Plan

    We have couple of materialized views which we want to get refreshed in DAC execution plan.
    We have referred Technote "BI_Apps796_Perf_Tech_Note_V8" which detailed how materialized view can be refreshed in DAC Execution Plan.
    We have followed below steps but our materized view is not getting refreshed.
    1. Create new Task Actions in DAC using "Tools -> Seed Data -> Actions -> Task Actions"
    with SQL Statement link
    BEGIN
    DBMS_MVIEW.REFRESH('getTableName()', 'C');
    DBMS_STATS.GATHER_TABLE_STATS(ownname => 'getTableOwner()', tabname=> 'getTableName()', cascade => TRUE, estimate_percent => DBMS_STATS.AUTO_SAMPLE_SIZE, method_opt => 'FOR ALL COLUMNS SIZE AUTO', degree => DBMS_STATS.DEFAULT_DEGREE);
    END;
    2. Defined custom MV as a table in DAC
    3. Added custom MV as the related table to the original Fact.
    4. Reassembled corresponding Subject Areas and rebuilt Execution plan
    But the MV is not getting refershed. Neither could locate any task in Ordered Task which will refresh this MV.
    Have we missed any step? Any pointers in this direction would be appericiated?
    Do we have to specify action .. to task "Load Fact table tas" and specify Success action as Refresh MV?
    How can we trace task in All tasks/Ordered tasks in DAC EP to locate task corresponding to MV refresh?

    Thanks Veeravalli for Suggesion!
    Tried adding Task action Refresh MV as action type "Success Action" for Fact task .. It did add a step of Refresh MV for load Fact Task in EP
    But it is passing the Orgininal Factable name as to be refreshed as MV which is giving DB error.
    "Refresh MV" for WC_B_TEST_F failed on "DataWarehouse"
    sql: BEGIN
    DBMS_MVIEW.REFRESH('WC_B_TEST_F', 'C');
    DBMS_STATS.GATHER_TABLE_STATS(ownname => 'olap', tabname=> 'WC_B_TEST_F',cascade => FALSE, estimate_percent => DBMS_STATS.AUTO_SAMPLE_SIZE, method_opt => 'FORALL COLUMNS SIZE AUTO', degree => DBMS_STATS.DEFAULT_DEGREE);
    END;
    Error: MESSAGE:::ORA-23401: materialized view "OLAP"."WC_B_TEST_F" does not exist
    ORA-06512: at "SYS.DBMS_SNAPSHOT", line 2563
    ORA-06512: at "SYS.DBMS_SNAPSHOT", line 2776
    ORA-06512: at "SYS.DBMS_SNAPSHOT", line 2745
    ORA-06512: at line 2
    instead of WC_B_TEST_F, we wanted "OLAP"."WC_B_TEST_MV" to be refreshed
    Do we need to create another task for MV refresh rather than task action? and add Refresh MV as task action there?
    Thanks,

  • Updatable materialized view site - replication

    Hi all,
    I have a shared instance database (with multiple schemas) hosting different applications for different customers. I'm now going to move out one of the application - the materialized view site to another database in new server. (as per request by customer to another data center) by using schema level import/export. The master site will remain untouched.
    As i'm rather new in replication, I would like your advise in which data dictionary tables where I can find which are the schemas having the below privileges. As this is a legacy database handed over to us long back, i need to dig out all the info to plan for the migratiion. I need to identify which schema is taking part in the snapshot replication in the mview site as there are 20 over schemas in the database. Can anyone advise me? Kindly provide addtional info if u think it helps.
    grant_admin_any_schema
    privilege_type => 'proxy_snapadmin'
    privilege_type => 'receiver'
    privilege_type => 'propagator'
    thanks

    dba_sys_privs

  • Dimension updates in Analytic workspace:Materialized views?

    We are using the 10g version of Oracle OLAP. We have 1 materialized view joining with our custom table and forming 1 source view per dimension. We load the cube programatically by refresh the dimension materialized views, followed by loading fact data to views against cube and then the actual workspace and cube creation..
    Question is :
    1) Do dimensions get loaded to analytic workspace only when the analytic workspace is created (programatically or maintain dimension via AW)?
    2) Assume we do not create the analytic workspace programatically or do not do a maintain dimension. In this case willl the dimensions in the analytic workspace get refreshed any time the data in source tables in the materialized view or custom table used in dimension source view change?
    Please advise.
    Thanks,
    Sudip

    If the data source changes for OLAP 10g then you must maintain the AW/ dimensions/cubes. There is no ability to check if anything in the source has changed.
    If using 11g, then you can use the MV refresh capabilities to maintain your AW (if your model conforms)...MV refresh features detects changes in the source tables.
    Hope I understood your question correctly.

  • Sales order - entering customer material

    Hello,
    We have list of machine part numbers which do not tally with a customer machine parts numbers.
    For example our part number is TSS0001 whereas Customers part number is 004-XVG-43966-1
    Customer would like to have his own part number listed in the sales order.
    Is there a field in sales order where we can enter customer part number?
    Thank you

    Hello,
    this can be effectively done by maintaining Customer Material infor records. Data on a material defined for one specific customer is stored in the customer material information records. This data includes
    customer-specific material number , customer-specific material description.
    For example, one of your customers uses a number for a material, which differs from the number your company uses to identify it, you can store the material number used by the customer in the customer material information record.
    During order entry, items can be entered by specifying the material number used by the customer. You also enter a customer material number in the order view of the sales order. You can then use both material numbers during the order entry, the material number your company uses or the one defined by the customer, because the system can carry out allocation automatically.
    The transaction code is VD51.
    Prase

  • Materialized View - Refresh in 10g FAST .. refresh in 11g SLOW

    Sorry I'm not able to paste anything.
    The customer moved their database from 10g to a 11gR2 database.
    They created the MV in the new system and now it takes 26 hours to refresh
    as opposed to 15 min in the old 10g database.
    Just looking for a game plan for troubleshooting.
    I know I'm not providing much of anything so please forgive me.
    Where would you look first ? Explain plan .. system settings .. ? Let me know.
    If you have a good reference then that would work. The docs are not working.
    Thanks in advance.
    BB

    Do you mean they upgraded their existing database from 10g to 11gr2?
    Or do you mean they loaded the data into a new 11gr2 database?Yeah I confirmed this morning that they data-pumped the entire database to the 11g host.
    Unless you provide more information there is no way to provide any specific suggestions.
    What kind of MV? Are the source and MV on the same server?They do a manual refresh :
    create materialized view (mview_name as select ...)
    dbms_snapshot.refresh(mview_name, 'C')
    The source is the same for both however it is from a place that uses a connection.
    If it is a new DB then there may be missing indexes or constraints.
    The MV may initially be empty and the first refresh will be a COMPLETE
    one that will take a lot longer than an incremental.
    Some of the objects or constraints could be invalid. The indexes appear to be the same and the constraints enabled/disabled in the same manner.
    They confirmed that the refresh after the initial is taking way too long compared to before (10g).
    Oddly some of the mviews see no performance degradation in the new environment.
    They have many.
    Thanks for taking the time to think about it. It was much appreciated.
    If I get to the bottom of it I'll let everybody know.
    BB

  • Materialized view excessive logging.  SOS

    The refresh of our materialized view is causing excessive logging. I altered the materialized view to NOLOGGING but it did not have any effect, not sure why?
    We either need to change the refresh time from 3 minutes to every 15 minutes(which is a bummer, data would be more stale) or give up on the materialized view.
    The quantity of archive logs has more than doubled since we adding this materialized view and the file system partition filed up last night, halting activity inside the database!
    Any suggestions?

    The refresh is not set for direct path inserts.Good. Now you have something you can change to help resolve the issue.
    The MV does not have any indexes.So the logging issue you describe is purely caused by deletes from, and inserts into the MV during a complete refresh.
    You can use the advice given by Alex above, and use atomic_refresh => false. Before you say it cannot be done because the users will not have access to the data during refresh, you might need to get creative. If you use query rewrite, for example, users would have access to data from the base tables while the MV is being refreshed. Their queries may be slower for a while, but they will still get data. If waiting 3 minutes or so is unacceptable for the queries that sneak in during a refresh, you can consider the following. Use query rewrite and have 2 materialized views, one of which can refresh while the other is available. After refreshing one, disable query rewrite on the older one.
    We cannot perform a fast refresh due to the query required to build the view.I'll take your word on it, although I have come across this situation many times where MVs that were thought to be impossible to fast refresh actually can be made to do it. Again, you might need to get creative. Sometimes you can do this by having MVs built on other MVs.
    Also, consider using MVs on prebuilt tables. You get additional control over how to refresh the MV this way. You can build your own custom refresh process that might help you do your own "fast refresh" by just applying the delta to your data (insert a few rows, update a few aggregates, perhaps). You can even do things like partition swapping so you can build your refreshed data in a separate table and then swap it with the MV partition (even if it is all in one partition).

Maybe you are looking for

  • Error in starting the database

    when i shut down my database,there is no error but as i startup my database it is giving the following errors ORA-24324: service handle not initialized ORA-01041: internal error. hostdef extension doesn't exist ORA-12514: TNS:listener could not resol

  • VGA/DVI cable - wanting to use two monitors.

    I got a VGA/DVI cable to connect the VGA port on my LCD TV to the DVI port on my desktop computer. I'm trying to use 2 monitors on my computer which has both a VGA and DVI port. My regular monitor was already on, and the computer detected the TV as a

  • SLD question: When is Logical system mandatory?

    Hi Experts,       When we create a business system we get a dialog for entering logical system. My question is, for what business system, logical system in mandatory? Is it for ABAP? or third party? or Java? What is the real significance of a logical

  • PC Suite not showing all icons

    I have the s/ware installed on my old laptop and use it to connect to the internet via GPRS, both DKU-2 cable & Bluetooth. I installed the same version from a CD on my new laptop (XP home, SP2) but do not see the icon to connect to the internet. In a

  • Aggregate from two tables

    Dear all, I have a need to compare totals from 2 tables. The table data is as follows : create table FLIGHTS( PSGRNAME VARCHAR2(64), FLTNBR VARCHAR2(5), FLTDATE DATE, NBRINPARTY NUMBER ) ; insert into FLIGHTS (PSGRNAME, FLTNBR, FLTDATE, NBRINPARTY) v