Session Specific Materialized Views...

Its my understanding that when creating a materialized view, the default table the data is loaded into (from the query of the materialized view) is not session specific. Is there any way to make it session specific? Below is a view I just created... I want it to be session specific using the user currently logged into the system
CREATE MATERIALIZED VIEW DATA_PERMISSION_SETS
BUILD IMMEDIATE
REFRESH ON DEMAND AS
SELECT A.TRD_TRADER_LOGIN,
A.CY_COMPANY_KEY,
A.SID,
A.SERIAL_ID,
A.STRUCTURE_LEVEL,
A.STRUCTURE_KEY
FROM TRADER_DATA_PERMITS A
WHERE TRD_TRADER_LOGIN = USER;
If user "A" logs into the database, the data from the MV should be completely different than "B". I tried something close to this a few months ago using global temporary tables but it seems like oracle forms closes a session when using the built in "exit_form".. any help guys? Let me know your thoughts.
Thanks in advance.
Mo

Okay here is some details of what im trying to do. In my database is a security system, and within the security system is table which holds data permits for a row-level security system (oracle VPD using security context). So when a user logs in, he picks a security clearance, and based on the security clearance rows of data are populated into the filtering tables for the VPD context to decide which rows a user can see and not see... so heres an example...
Security clearance level 1 has access to
GVF Portfolio
RANDOM Portfolio
Subprime Portfolio
Security clearance level 2 has access to
1 Portfolio
RANDOM Portfolio
4 Portfolio
User 1 logs in using security clearance 1...
User 2 logs in using security clearance 2..
the filtering table will look like this for its permissions..
USER 1, GVF Portfolio
USER 1, RANDOM Portfolio
USER 1, Subprime Portfolio
USER 2, 1 Portfolio
USER 2, RANDOM Portfolio
USER 2, 4 Portfolio
now this example is assuming 2 users are in the system, with the minimal privledges inside the system. The current database can hold as many as 10k in users at a time all with entries in this table at login. If the VPD context has to sort through 150k + records for each row of a query, the run time is going to be EXTREMELY SLOW.
This is why I want to use a session specific materialized view or global table. It will minimize the records down to a few records, and the VPD context can use the materialized view as the filtering table instead of the full table.
The problem is the view data is not session specific. So if user 1 populates the materialized view and user 2 logs in to do the same, user 1's data from the materialized view will change from user 2's refresh...
Its a little hard to understand... let me know if you get me on this idea..
Mo

Similar Messages

  • Materialized view log with multiple materialized views

    DB: 9.2.0.8
    Yes its old. I am not allowed to upgrade it.
    I have a set of materialized views that are created off of 5 base tables. They do fast refreshes. So I have multiple materialized views for the same base table and same materialized view log.
    1. how do materialized view logs manage multiple dependent materialized views?
    2. How do I tell by looking at the materialized view log which rows have not been fast refresh for a specific materialized view?

    As a starter for 10 try reading: Materialized View Refresh : Log Population and Purge (Doc ID 236233.1) on MOS.
    Thanks
    Paul

  • Create materialized view with specific column sizes

    Hi all,
    I'm trying to create a materialized view with a specific a column size. Something like
    create materialized view test_mv
    refresh force on demand
    as
    select id,
           cast(my_compound_field as nvarchar2(50))
    from ( select id,
                  field1 || field2 my_compound_field
           from   my_table);But Oracle seems to ignore the cast and takes the maximum size it finds for field1 || field2 in the select query. The resulting table has a column nvarchar2(44) instead of nvarchar2(50).
    This can give a problem when the view is refreshed... there could be new data that exceeds the current size, i.e. where length(field1 || field2) > 44.
    How can I override the column size of a field in a materialized view?
    Edit: Some additional info to clarify my case:
    field1 and field2 are defined as nvarchar2(25). field1 || field2 can theoretically have a length of 50, but there is currently no data in my table that results in that length, the max is 44. I am afraid that there will be data in the future that exceeds 44, resulting in an error when the MV is refreshed!
    Edited by: Pleiadian on Jan 25, 2011 2:06 PM

    Cannot reproduce what you are saying is happening.
    SQL> create table t (a nvarchar2(50), b nvarchar2(50));
    Table created.
    SQL> create materialized view tmv as
      2  select a, b, a || b c from t;
    Materialized view created.
    SQL> desc tmv
    Name                                      Null?    Type
    A                                                  NVARCHAR2(50)
    B                                                  NVARCHAR2(50)
    C                                                  NVARCHAR2(100)
    SQL> drop materialized view tmv;
    Materialized view dropped.
    SQL> create materialized view tmv as
      2  select a, b, substr(a || b, 1, 10) c from t;
    Materialized view created.
    SQL> desc tmv
    Name                                      Null?    Type
    A                                                  NVARCHAR2(50)
    B                                                  NVARCHAR2(50)
    C                                                  NVARCHAR2(10)
    SQL> select * from v$version;
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
    PL/SQL Release 11.1.0.7.0 - Production
    CORE    11.1.0.7.0      Production
    TNS for Linux: Version 11.1.0.7.0 - Production
    NLSRTL Version 11.1.0.7.0 - Production
    SQL>Edited by: 3360 on Jan 25, 2011 8:10 AM
    And with data
    SQL> insert into t values ('3123423423143hhshgvcdcvw', 'ydgeew  gdfwe   dfefde  wfjjjjjjj');
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> desc tmv
    Name                                      Null?    Type
    A                                                  NVARCHAR2(50)
    B                                                  NVARCHAR2(50)
    C                                                  NVARCHAR2(10)
    SQL> select * from tmv;
    A
    B                                                  C
    3123423423143hhshgvcdcvw
    ydgeew  gdfwe   dfefde  wfjjjjjjj                      3123423423

  • Disabling Materialized View Logs for a session

    Hi all.
    I was wondering if it is possible to disable the fast refresh log for materialized views for just a given session. So for all other sessions except this one the log would be added to. I'm using 11g.
    In Oracle Database 11g, The Complete Reference on page 447 it states:
    "As of Oracle 11g, the capture of changes in materialized view logs can be disabled for an individual session while logging continues for changes made by other sessions". But no instructions are given
    Does anyone know how to do this? I have not been able to find the answer by looking around.
    Thanks!

    Yeah, I had saw that Oracle mentioned it here also: http://download.oracle.com/docs/cd/B28359_01/server.111/b28279/chapter1.htm#FEATURENO07197
    Any idea of what the code might look like? I've never had to alter an individual session for Oracle before.

  • CO46 for sales order no exploded view for specific material

    Dear All,
    When using CO46 for a sales order it does everything correct exept for a specific material. It is displayed above the sales order in the hierarchy, like if it is not contained in it and there is no exploded view possible.
    When I look closer to the MRP for the material it has planned orders but the orders reducing quantity don't link to the sales order. The MRP element data is empty.
    Anybody has a clue?
    Thanks in advance,
    Michaë

    The material in the SOI created collective requirements. Change Material Master availability check to 02 and recreate SOI

  • Materialized views with Complete refresh taking infinite time while refresh

    Hi,
    We have some materialized view which are configured for Complete refresh and are being refreshed manually everyday in the morning. Some times we face this issue of the MV taking longer time than usual for refresh. We tried running the below query to see if any object/MVs are locked and did not obtain any entries using the query:
    SELECT username U_NAME, owner OBJ_OWNER,
    object_name, object_type, s.osuser,
    DECODE(l.block,
    0, 'Not Blocking',
    1, 'Blocking',
    2, 'Global') STATUS,
    DECODE(v.locked_mode,
    0, 'None',
    1, 'Null',
    2, 'Row-S (SS)',
    3, 'Row-X (SX)',
    4, 'Share',
    5, 'S/Row-X (SSX)',
    6, 'Exclusive', TO_CHAR(lmode)
    ) MODE_HELD
    FROM gv$locked_object v, dba_objects d,
    gv$lock l, gv$session s
    WHERE v.object_id = d.object_id
    AND (v.object_id = l.id1)
    AND v.session_id = s.sid
    ORDER BY username, session_id;
    Hence please help us in troubleshooting this issue in Refreshing. and also let us know of any possible cause of Refresh taking longer time than usual.
    Thanking you in advance.
    Bharath

    >
    We have some materialized view which are configured for Complete refresh and are being refreshed manually everyday in the morning. Some times we face this issue of the MV taking longer time than usual for refresh
    >
    Which is it? 'some' MVs or 'the' MV that is taking longer than usual.
    1. How many MVs are being refreshed?
    2. What process are you using to refresh them
    3. Are you refreshing them one at a time serially or just starting the refresh of all of them at the same time?
    4. Do any of these MVs use the same base tables as the other MVs
    5. Are any of the MVs based on remote tables?
    6. Are any of the MVs based on other MVs?
    7. What does an AWR report show for the time period when things are taking longer than usual?
    All of the same issues that can cause a query to run slow can cause an MV refresh to go slow because an MV refresh is a query.
    But you need to provide a lot more information and metrics about your system if you want to get any advice that might be specific to your particular case.

  • Materialized View to run only once in a year...

    Hi everybody...
    I want to create a materialized view which will run only once in a year and specifically some minutes after 00:00 a.m. on new year's day,
    so i created the following:
    CREATE MATERIALIZED VIEW <mv_name>
    BUILD IMMEDIATE
    REFRESH START WITH TO_DATE('01/01/2007 00:15:00','DD/MM/RRRR HH24:MI:SS')
    NEXT SYSDATE+366
    I have two notes:
    1) how to declare the refresh to be done the first new year's day after the day it'll be created , i mean not static date (01/01/2007)
    2)some years are leap and some are not , so in order to run every new year's day how should i transform the above..????
    3)is there any view which displays the next run of a materialized view..???
    the view DBA_MV_REFRESH_TIMES displays the last refresh of mv's...
    I use Oracle 10.2.0.1 on XP ...
    Thanks , a lot
    Simon

    1).
    use the expression that evaluates to next january first.
    SQL> select sysdate, add_months(trunc(sysdate, 'yyyy'), 12) from dual ;
    SYSDATE     ADD_MONTHS(
    19-JUN-2006 01-JAN-2007
    1 row selected.
    SQL>2). for this also use the same expression that will evaluate to the january first of the year after that.

  • A bug when refreshing a materialized view?

    I am getting "ORA-00603: ORACLE server session terminated by fatal error" upon refresh of a materialized view. I've put together a test case to demonstrate the problem. Is it a bug?
    SQL*Plus: Release 10.1.0.3.0 - Production on Fri Jul 29 13:43:45 2005
    Copyright (c) 1982, 2004, Oracle.  All rights reserved.
    Connected to:
    Oracle9i Enterprise Edition Release 9.2.0.6.0 - Production
    With the Partitioning, OLAP and Oracle Data Mining options
    JServer Release 9.2.0.6.0 - Production
    [email protected]> create table t (
      2  id int primary key,
      3  t_name varchar2(10),
      4  t_date date
      5  );
    Table created.
    [email protected]> create materialized view log on t
      2    with rowid (t_name, id, t_date) including new values;
    Materialized view log created.
    [email protected]> create materialized view t_mv
      2   build immediate
      3   refresh fast
      4   on commit
      5  as
      6   select t_name, max(id) id, max(t_date) t_date, count(*)
      7     from t
      8    GROUP BY t_name;
    Materialized view created.
    [email protected]> create materialized view log on t_mv
      2    with rowid (id) including new values;
    Materialized view log created.
    [email protected]> create table v (
      2  id int primary key,
      3  t_id int references t(id) on delete cascade,
      4  v_name varchar2(10)
      5  );
    Table created.
    [email protected]> create materialized view log on v
      2    with rowid (v_name, t_id) including new values;
    Materialized view log created.
    [email protected]> create materialized view v_mv
      2   build immediate
      3   refresh fast
      4   on commit
      5  as
      6  select v.rowid rowid1, t_mv.rowid rowid2, v.v_name, v.t_id
      7  from v, t_mv
      8  where v.t_id = t_mv.id;
    Materialized view created.
    [email protected]> alter table v_mv
      2  add constraint v_mv_uk1 unique
      3  (
      4  v_name
      5  )
      6   enable
      7  ;
    Table altered.
    [email protected]> insert into t (id, t_name, t_date) values (1, 'A', sysdate);
    1 row created.
    [email protected]> insert into t (id, t_name, t_date) values (2, 'B', sysdate);
    1 row created.
    [email protected]> insert into t (id, t_name, t_date) values (3, 'A', sysdate);
    1 row created.
    [email protected]> insert into t (id, t_name, t_date) values (4, 'A', sysdate);
    1 row created.
    [email protected]> insert into t (id, t_name, t_date) values (5, 'B', sysdate);
    1 row created.
    [email protected]> insert into v (id, t_id, v_name) values (1, 1, 'V_A_1');
    1 row created.
    [email protected]> insert into v (id, t_id, v_name) values (2, 2, 'V_B_1');
    1 row created.
    [email protected]> insert into v (id, t_id, v_name) values (3, 3, 'V_A_2');
    1 row created.
    [email protected]> insert into v (id, t_id, v_name) values (4, 4, 'V_A_3');
    1 row created.
    [email protected]> insert into v (id, t_id, v_name) values (5, 5, 'V_B_2');
    1 row created.
    [email protected]> commit;
    Commit complete.
    [email protected]> insert into t (id, t_name, t_date) values (6, 'A', sysdate);
    1 row created.
    [email protected]> insert into v (id, t_id, v_name) values (6, 6, 'V_B_2');
    1 row created.
    [email protected]> commit;
    commit
    ERROR at line 1:
    ORA-12008: error in materialized view refresh path
    ORA-00001: unique constraint (FESA.V_MV_UK1) violated
    [email protected]> -- ORA-12008 is fine here: that's what was expected
    [email protected]> delete from t where id = 5;
    1 row deleted.
    [email protected]> commit;
    ERROR:
    ORA-03114: not connected to ORACLE
    commit
    ERROR at line 1:
    ORA-00603: ORACLE server session terminated by fatal errorWhy ORA-00603?
    Best regards,
    Maciej

    It may be a bug, or it may be a result of the dependencies between the materialized views. I don't have a 9.2.0.6 instance that I'm willing to trash to test this, but this is what I get on 9.2.0.1.
    If it is a bug they at least changed the behaviour of the bug in 9.2.0.6.
    I ran your script up to the first commit then did:
    SQL> SELECT * FROM t;
            ID T_NAME     T_DATE
             1 A          29-JUL-05
             2 B          29-JUL-05
             3 A          29-JUL-05
             4 A          29-JUL-05
             5 B          29-JUL-05
    SQL> SELECT * FROM t_mv;
    T_NAME             ID T_DATE      COUNT(*)
    A                   4 29-JUL-05          3
    B                   5 29-JUL-05          2
    SQL> SELECT * FROM v;
            ID       T_ID V_NAME
             1          1 V_A_1
             2          2 V_B_1
             3          3 V_A_2
             4          4 V_A_3
             5          5 V_B_2
    SQL> SELECT * FROM v_mv;
    no rows selectedHUH?? But:
    SQL> SELECT v.rowid rowid1, t_mv.rowid rowid2, v.v_name, v.t_id
      2  FROM v, t_mv
      3  WHERE v.t_id = t_mv.id;
    ROWID1             ROWID2             V_NAME           T_ID
    AAAH4QAAIAAAAl1AAD AAAH4MAAIAAAAlFAAA V_A_3               4
    AAAH4QAAIAAAAl1AAE AAAH4MAAIAAAAlFAAB V_B_2               5So, I tried:
    SQL> EXEC DBMS_MVIEW.REFRESH('V_MV');
    PL/SQL procedure successfully completed.
    SQL> SELECT * FROM v_mv;
    no rows selectedNow, this is confusing, so:
    SQL> EXEC DBMS_MVIEW.REFRESH('V_MV', 'COMPLETE');
    PL/SQL procedure successfully completed.
    SQL> SELECT * FROM v_mv;
    ROWID1             ROWID2             V_NAME           T_ID
    AAAH4dAAIAAAAl1AAD AAAH4ZAAIAAAAlFAAA V_A_3               4
    AAAH4dAAIAAAAl1AAE AAAH4ZAAIAAAAlFAAB V_B_2               5So at least I've got something in the MV. Now, to continue your test:
    SQL> insert into t (id, t_name, t_date) values (6, 'A', sysdate);
    1 row created.
    SQL> insert into v (id, t_id, v_name) values (6, 6, 'V_B_2');
    1 row created.
    SQL> COMMIT;
    Commit complete.I also expected the error but no joy, and look at this:
    SQL> SELECT * FROM v_mv;
    ROWID1             ROWID2             V_NAME           T_ID
    AAAH4dAAIAAAAl1AAE AAAH4ZAAIAAAAlFAAB V_B_2               5Forcing the refresh on v_mv gets:
    SQL> EXEC DBMS_MVIEW.REFRESH('V_MV', 'COMPLETE');
    BEGIN DBMS_MVIEW.REFRESH('V_MV', 'COMPLETE'); END;
    ERROR at line 1:
    ORA-12008: error in materialized view refresh path
    ORA-00001: unique constraint (OPS$ORACLE.V_MV_UK1) violatedVery strange! It gets better:
    SQL> DELETE FROM t WHERE id = 5;
    1 row deleted.
    SQL> commit;
    Commit complete.
    SQL> EXEC DBMS_MVIEW.REFRESH('V_MV', 'COMPLETE');
    PL/SQL procedure successfully completed.
    SQL> select * from v_mv;
    ROWID1             ROWID2             V_NAME           T_ID
    AAAH4dAAIAAAAl1AAF AAAH4ZAAIAAAAlFAAA V_B_2               6 But:
    SQL> SELECT * FROM t_mv;
    T_NAME             ID T_DATE      COUNT(*)
    A                   6 29-JUL-05          4
    B                   5 29-JUL-05          2
    SQL> SELECT * FROM t;
            ID T_NAME     T_DATE
             1 A          29-JUL-05
             2 B          29-JUL-05
             3 A          29-JUL-05
             4 A          29-JUL-05
             6 A          29-JUL-05Obvioulsy, something is not fast refreshing. So lets force it:
    SQL> EXEC DBMS_MVIEW.Refresh('T_MV', 'COMPLETE');
    PL/SQL procedure successfully completed.
    SQL> SELECT * FROM t_mv;
    T_NAME             ID T_DATE      COUNT(*)
    A                   6 29-JUL-05          4
    B                   2 29-JUL-05          1
    SQL> SELECT * FROM v_mv;
    ROWID1             ROWID2             V_NAME           T_ID
    AAAH4dAAIAAAAl1AAB AAAH4qAAIAAAAlEAAB V_B_1               2
    AAAH4dAAIAAAAl1AAF AAAH4qAAIAAAAlEAAA V_B_2               6Which looks right to me.
    Then, I blew everything away and did it allagain up to an including the inserts into t, then I inserted into v and commited. Now, both MV's were correct, so I did:
    SQL> insert into t (id, t_name, t_date) values (6, 'A', sysdate);
    1 row created.
    SQL> insert into v (id, t_id, v_name) values (6, 6, 'V_B_2');
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> SELECT * FROM t_mv;
    T_NAME             ID T_DATE      COUNT(*)
    A                   6 29-JUL-05          4
    B                   5 29-JUL-05          2Still strange, so blow it all away again insert into t commit, insert into v commit, then:
    SQL> insert into t (id, t_name, t_date) values (6, 'A', sysdate);
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> insert into v (id, t_id, v_name) values (6, 6, 'V_B_2');
    1 row created.
    SQL> commit;
    commit
    ERROR at line 1:
    ORA-12008: error in materialized view refresh path
    ORA-00001: unique constraint (OPS$ORACLE.V_MV_UK1) violatedAt least now it sees the error at commit time for v so lets try the delete:
    SQL> delete from t where id = 5;
    1 row deleted.
    SQL> commit;
    Commit complete.
    SQL> SELECT * FROM t_mv;
    T_NAME             ID T_DATE      COUNT(*)
    A                   6 29-JUL-05          4
    B                   5 29-JUL-05          2
    SQL> SELECT * FROM t;
            ID T_NAME     T_DATE
             1 A          29-JUL-05
             2 B          29-JUL-05
             3 A          29-JUL-05
             4 A          29-JUL-05
             6 A          29-JUL-05Still not actually refreshing somehow.
    I may play with this some more, it seems truly strange to me.
    John

  • Refresh a materialized view in parallel

    Hi,
    To improve the refresh performance for a materialized view, I set up it to be refreshed in parallel. The view can be refreshed successfully, however, I did not see the view is refreshed in parallel from session browser, can someone let me know if I miss any steps?
    1) In DB A (running 8 CPUs), set up the base table to be parallelized, the base table is called table1
    ALTER TABLE A.table1 PARALLEL ( DEGREE Default INSTANCES Default );
    2) In Database A, set up the materialized view log
    CREATE MATERIALIZED VIEW LOG
    ON table1 WITH primary key
    INCLUDING NEW VALUES;
    3) In Database B (in the same server with Database A), there is an existing table called table1, prebuilt with millions of records in the table. Due to the size of table1, I have to use prebuilt option
    Drop MATERIALIZED VIEW table1;
    CREATE MATERIALIZED VIEW table1 ON PREBUILT TABLE
    REFRESH FAST with primary key
    AS
    select /*+ PARALLEL(table1, 8) */ *
    from table1@A;
    4) in Database B, I executed this stored procedure -
    EXECUTE DBMS_MVIEW.REFRESH(LIST=>'table1',PARALLELISM=>8, METHOD=>'F');
    Thanks in advance!
    Liz

    I checked the execution plan when I executed the refresh stored procedure again, Does the plan indicates the parallel execution is working or not?
    SELECT STATEMENT REMOTE ALL_ROWSCost: 32,174 Bytes: 775,392 Cardinality: 1,182                                                   
    13 PX COORDINATOR                                              
    12 PX SEND QC (RANDOM) PARALLEL_TO_SERIAL SYS.:TQ10001 :Q1001                                        
         11 NESTED LOOPS PARALLEL_COMBINED_WITH_PARENT :Q1001                                   
         9 NESTED LOOPS PARALLEL_COMBINED_WITH_PARENT :Q1001Cost: 32,174 Bytes: 775,392 Cardinality: 1,182                               
              6 BUFFER SORT PARALLEL_COMBINED_WITH_CHILD :Q1001                         
                   5 PX RECEIVE PARALLEL_COMBINED_WITH_PARENT :Q1001                    
                        4 PX SEND ROUND-ROBIN PARALLEL_FROM_SERIAL SYS.:TQ10000 A               
                             3 VIEW APP_USR. Cost: 12,986 Bytes: 6,070,196 Cardinality: 275,918           
                                  2 HASH UNIQUE Cost: 12,986 Bytes: 9,105,294 Cardinality: 275,918      
                                       1 TABLE ACCESS FULL TABLE A.MLOG$_TABLE1 A Cost: 10,518 Bytes: 9,105,294 Cardinality: 275,918
         8 PARTITION RANGE ITERATOR PARALLEL_COMBINED_WITH_PARENT :Q1001Cost: 0 Cardinality: 1                          
         7 INDEX RANGE SCAN INDEX (UNIQUE) PARALLEL_COMBINED_WITH_PARENT A.PK_TABLE1 :Q1001Cost: 0 Cardinality: 1                     
    10 TABLE ACCESS BY LOCAL INDEX ROWID TABLE PARALLEL_COMBINED_WITH_PARENT A.TABLE1 :Q1001Cost: 0 Bytes: 634 Cardinality: 1

  • Reg:package code to refresh materialized views

    i am new to pl/sql packages and procedures.i want it to execute for running mappings in informatica which takes 0 and gives 1 when executed successfully
    create or replace PACKAGE BODY pkg_refresh_mv as
    procedure prc_mv (p_mv_name varchar2) is
    begin
    dbms_mview.refresh (p_mv_name);
    end prc_mv;
    procedure refresh_all_mv (proc_response IN OUT number) is
    begin
    dbms_mview.refresh('materialized view','C');
    dbms_mview.refresh('materialized view','C');
    proc_response := 1;
    exception
    when others then
    proc_response := 0;
    end refresh_all_mv ;
    end pkg_refresh_mv;
    when i execute this code i get the following errors
    PLS-00201: identifier 'PKG_REFRESH_MV' must be declared
    PLS-00304: cannot compile body of 'PKG_REFRESH_MV' without its specification
    what needs to be changed
    thanks

    try this one :
    CREATE OR REPLACE PACKAGE pkg_refresh_mv
    AS
       PROCEDURE prc_mv (p_mv_name VARCHAR2);  
       PROCEDURE refresh_all_mv (proc_response IN OUT NUMBER);
    END pkg_refresh_mv;
    CREATE OR REPLACE PACKAGE BODY pkg_refresh_mv
    AS
       PROCEDURE prc_mv (p_mv_name VARCHAR2)
       IS
       BEGIN
          dbms_mview.refresh (p_mv_name);
       END prc_mv;
       PROCEDURE refresh_all_mv (proc_response IN OUT NUMBER)
       IS
       BEGIN
          dbms_mview.refresh ('materialized view', 'C');
          dbms_mview.refresh ('materialized view', 'C');
          proc_response := 1;
       EXCEPTION
          WHEN OTHERS
          THEN
             proc_response := 0;
       END refresh_all_mv;
    END pkg_refresh_mv;
    /

  • Fast refresh of materialized view

    Hi All,
    This is my first posting on this forum, so I hope I don't step on anyone's toes as I wade into a problem that I am experiencing.
    I have a number of either join-only or single table aggregate materialized views that I have experienced problems with. All the views are setup for FAST REFRESH ON DEMAND but I'm hitting an error if I execute a COMPLETE refresh of the view when I've done an ALTER SESSION ENABLE PARALLEL DML. The error I get is:
    ERROR at line 1:
    ORA-30439: refresh of 'DTKTGT.CTNS_PER_HR_VOL_AGG_MV' failed because of ORA-32320: REFRESH FAST of "DTKTGT"."CTNS_PER_HR_VOL_AGG_MV" unsupported after cointainer table PMOPs
    ORA-06512: at "SYS.DBMS_SNAPSHOT", line 814
    ORA-06512: at "SYS.DBMS_SNAPSHOT", line 872
    ORA-06512: at "SYS.DBMS_SNAPSHOT", line 852
    ORA-06512: at "DTKTGT.MV_REFRESH", line 21
    ORA-06512: at line 2
    Any help anyone could provide would be greatly appreciated as every now and then, a COMPLETE refresh is unavoidable and using the ENABLE PARALLEL DML makes the refresh run a lot faster than without the ALTER SESSION.
    Gary

    This forum only is for questions relating to the use of OLAP Option. I would post your question on the database forum.
    Keith Laker
    Oracle Data Warehouse Product Management
    OLAP Blog: http://oracleOLAP.blogspot.com/
    OLAP Wiki: http://wiki.oracle.com/page/Oracle+OLAP+Option
    DM Blog: http://oracledmt.blogspot.com/
    OWB Blog : http://blogs.oracle.com/warehousebuilder/
    OWB Wiki : http://wiki.oracle.com/page/Oracle+Warehouse+Builder
    DW on OTN : http://www.oracle.com/technology/products/bi/db/11g/index.html

  • How to speed up fast refresh of materialized view without primary key

    Thought I'd share this info, as I couldn't find anything on here to help me diagnose the issue:
    I had a materialized view that was taking longer to perform a fast refresh than it took to perform a complete refresh. My mview had no primary key, as the base table had no primary key.
    I created a trace file for the session and saw references to a column M_ROW$$ in my mview. Nowhere in the data dictionary could I find a reference to the m_row$$ column in my mview, but apparently it exists and is created automatically. After creating the index below, the fast refresh took 6 minutes to add 500k rows to the materialized view. (versus 4+ hours without the index) When I looked in the trace file, I noticed that for each row in the mview log, it first tries to update the mview with an UPDATE statement, then it performs an insert of the new data. Seems like it should be able to determine whether to perform an update or insert based on the DMLTYPE$$ column of the mview log. What was killing my performance was the UPDATE phase. Since I had no primary key on the mview, and no index on the m_row$$ column, the UPDATE phase was performing a full table scan of my mview for every row in the mview log. I was expecting it to be smart enough to only perform inserts, as the only transactions against the base table were inserts.
    In summary: If you have a materialized view without a primary key, create an index on the m_row$$ column of the mview, even though no such column displays in the data dictionary.
    ex:
    CREATE MATERIALIZED VIEW mv_minidrr ...
    CREATE INDEX pk_mv_minidrr ON mv_minidrr(m_row$$) ...

    Well, there indeed is a column called M_ROW$$
    Your MLOG$_EMP is nothing but the materialized view log on the base table.
    SQL> create  materialized view log on emp with rowid ;
    Materialized view log created.
    SQL> create materialized view emp_mview refresh fast on demand with rowid as select * from emp ;
    Materialized view created.
    SQL> desc mlog$_emp
    Name                                                  Null?    Type
    M_ROW$$                                                        VARCHAR2(255)
    SNAPTIME$$                                                     DATE
    DMLTYPE$$                                                      VARCHAR2(1)
    OLD_NEW$$                                                      VARCHAR2(1)
    CHANGE_VECTOR$$                                                RAW(255)
    SQL> select table_name, column_name from user_tab_columns where column_name = 'M_ROW$$' ;
    TABLE_NAME                     COLUMN_NAME
    MLOG$_EMP                      M_ROW$$
    1 row selected.
    SQL>

  • How can I create a materialized view based on hierarchical cube query?

    Hi,
    database version 10gR2.
    When i try to create MV for sql below, i got error .
    I tried creating MV log in several ways, but still, keep getting the same error.
    SQL Error: ORA-12015: cannot create a fast refresh materialized view from a complex query
    12015. 00000 -  "cannot create a fast refresh materialized view from a complex query"
    *Cause:    Neither ROWIDs and nor primary key constraints are supported for
               complex queries.
    *Action:   Reissue the command with the REFRESH FORCE or REFRESH COMPLETE
               option or create a simple materialized view.So, I wonder if it is possible to create MV based on sql below?
    if yes, how should I do it?
    if no, what is the alternative?
    select
          coalesce(UP_ORG_ID_6, UP_ORG_ID_5, UP_ORG_ID_4, UP_ORG_ID_3, UP_ORG_ID_2, UP_ORG_ID_1) as ORG_ID,
          a.day_id as day_id,     
          a.TRADE_TYPE_ID as TRADE_TYPE_ID,
          a.CUST_ID,
          coalesce(UP_CODE_6, UP_CODE_5, UP_CODE_4, UP_CODE_3, UP_CODE_2, UP_CODE_1) as product_id,
          QUANTITY_UNIT,
          COST_UNIT,
          A.SOURCE_ID as SOURCE_ID,
          SUM(CONTRACT_AMOUNT) as CONTRACT_AMOUNT,
          SUM(CONTRACT_COST) as CONTRACT_COST,
          SUM(SALE_AMOUNT) as SALE_AMOUNT,
          SUM(SALE_COST) as SALE_COST,
          SUM(ACTUAL_AMOUNT) as ACTUAL_AMOUNT,
          SUM(ACTUAL_COST) as ACTUAL_COST,
          SUM(TRADE_COUNT) as TRADE_COUNT     
    from DM_F_LO_SALE_DAY a, DM_D_ALL_ORG_FLAT B, DM_D_ALL_PROD_FLAT D
    where a.ORG_ID=B.ORG_ID
          and a.PRODUCT_ID=D.CODE
          and a.day_id=20110201
    group by rollup(UP_ORG_ID_1, UP_ORG_ID_2, UP_ORG_ID_3, UP_ORG_ID_4, UP_ORG_ID_5, UP_ORG_ID_6),
          a.TRADE_TYPE_ID,
             a.day_id,
          A.CUST_ID,
          rollup(UP_CODE_1, UP_CODE_2, UP_CODE_3, UP_CODE_4, UP_CODE_5, UP_CODE_6),
          a.QUANTITY_UNIT,
          a.COST_UNIT,
          a.SOURCE_ID;Thanks in advance.

    Rob vanWjik has an excellent series of fast refresh materialized views starting here:
    http://rwijk.blogspot.com/2009/05/fast-refreshable-materialized-view.html
    Part three specifically on aggregate MVs is here:
    http://rwijk.blogspot.com/2009/06/fast-refreshable-materialized-view.html

  • MM50 : add new column in the material view

    Dear guru.
    I need to add a new column of material master in the material view of MM50.
    Do you have a solution (exit) in order to solve my problem ?
    Thanks.

    > I need to add a new field in the MM50 transaction not in MM02.
    Der Friend,
    Pls be specific about your query. As you know MM50 is for material view extension which is a std SAP trxn to help extend the views set by standard SAP pack and if you are referring new field as a new view then it is not so easily approachable.
    Shiva

  • Error While Creating Fast Refresh Materialized view.

    Table Scripts:
    CREATE TABLE CONTRACT_MASTER
      CONTRACT_SEQ                    NUMBER(10)    NOT NULL,
      PDN                             CHAR(5)       NOT NULL,
      APPID                           NUMBER(10)    NOT NULL,
      CONTRACT_LOB_DESC               VARCHAR2(20)  NOT NULL,
      CUSTOMER_NAME                   VARCHAR2(57)  NOT NULL,
      CONTRACT_DT                     DATE          NOT NULL,
      CONTRACT_RECD_DT                DATE          NOT NULL,
      HELD_OFFERING_DT                DATE          NOT NULL,
      DRAFT_AMT                       NUMBER(15,2)  NOT NULL,
      STATUS_DESC                                   VARCHAR2(20)  NOT NULL,
      GIF_UPLOAD_TM                                            TIMESTAMP     NOT NULL
    CREATE table CONTRACT_COMMENTS
      CONTRACT_COMMENTS_SEQ           NUMBER(10)     NOT NULL,
      APPID                           NUMBER(10)     NOT NULL,
      COMMENTS                        VARCHAR2(1000) NOT NULL,
      GIF_UPLOAD_TM                                            TIMESTAMP      NOT NULL
    Constraints on tables
    ALTER TABLE CONTRACT_MASTER ADD
      CONSTRAINT XPKCONTRACT_MASTER PRIMARY KEY (CONTRACT_SEQ) USING INDEX ;
    ALTER TABLE CONTRACT_COMMENTS ADD
      CONSTRAINT XPKCONTRACT_COMMENTS PRIMARY KEY (CONTRACT_COMMENTS_SEQ) USING INDEX ;
    alter table CONTRACT_MASTER add CONSTRAINT XUIAPPCONTRACT_MASTER UNIQUE (APPID) USING INDEX;
    CREATE INDEX XUIAPPCONTRACT_COMMENTS ON
    CONTRACT_COMMENTS(APPID) ;
    Materialized View Creation:
    CREATE MATERIALIZED VIEW LOG ON CONTRACT_MASTER WITH PRIMARY KEY,ROWID;
    CREATE MATERIALIZED VIEW LOG ON CONTRACT_COMMENTS WITH PRIMARY KEY, ROWID;
    CREATE MATERIALIZED VIEW MV_CONTRACT_COMMENTS_HELDOFFERING
    REFRESH FAST
    ENABLE QUERY REWRITE AS
    SELECT APPID,COMMENTS FROM CONTRACT_COMMENTS  WHERE APPID IN (
    SELECT APPID FROM CONTRACT_MASTER WHERE STATUS_DESC = 'Held Offering' )
    Errors generated:
    ERROR at line 4:
    ORA-12015: cannot create a fast refresh materialized view from a complex query
    _*Afer That I have changed the query but still it was not created like:*_
    CREATE  MATERIALIZED VIEW MV_CONT_COMMNTS_HELDOFFERNG
    REFRESH FAST
    ENABLE QUERY REWRITE AS
    SELECT CONTRACT_COMMENTS_SEQ,c.APPID,COMMENTS
    FROM CONTRACT_COMMENTS c,CONTRACT_MASTER  m 
    WHERE m.APPID = c.APPID and m.STATUS_DESC = 'Held Offering'
    *even though error displayed:
    SQL> CREATE  MATERIALIZED VIEW MV_CONT_COMMNTS_HELDOFFERNG*
       2  REFRESH FAST
       3  ENABLE QUERY REWRITE AS
       4  SELECT CONTRACT_COMMENTS_SEQ,c.APPID,COMMENTS
       5  FROM CONTRACT_COMMENTS c,CONTRACT_MASTER  m
       6  WHERE m.APPID = c.APPID and m.STATUS_DESC = 'Held Offering';
    FROM CONTRACT_COMMENTS c,CONTRACT_MASTER  m
    ERROR at line 5:
    ORA-12052: cannot fast refresh materialized view GSSIO.MV_CONT_COMMNTS_HELDOFFERNG
    *Again I have done "Analyzing Materialized Views for Fast Refresh" as follows:*
    1: exec dbms_mview.explain_mview('MV_CONT_COMMNTS_HELDOFFERNG');
    2: SELECT capability_name,  possible, SUBSTR(msgtxt,1,60) AS msgtxt
               FROM mv_capabilities_table
               WHERE capability_name like '%FAST%';
    Output is :
    CAPABILITY_NAME                               P              MSGTXT                                                            
    REFRESH_FAST                                   N                                                                   
    REFRESH_FAST_AFTER_INSERT            N  the SELECT list does not have the rowids of all the detail t      
    REFRESH_FAST_AFTER_ONETAB_DML   N  see the reason why REFRESH_FAST_AFTER_INSERT is disabled          
    REFRESH_FAST_AFTER_ANY_DML         N  see the reason why REFRESH_FAST_AFTER_ONETAB_DML is disabled      
    REFRESH_FAST_PCT                            N  PCT is not possible on any of the detail tables in the mater      
    Please suggest what to do to implement fast refresh materialized view for same.Edited by: dba on Sep 20, 2010 12:00 AM

    If the two MVs have to be consistent with each other as of a specific time, put them into a Refresh Group and refresh them with DBMS_MVIEW.REFRESH
    If an MV is dependent on another, use DBMS_MVIEW.REFRESH_DEPENDENT
    See the "Oracle® Database PL/SQL Packages and Types Reference" documentation pages for DBMS_MVIEW.
    Hemant K Chitale
    http://hemantoracledba.blogspot.com --- this is NOT a documentation site.
    Edited by: Hemant K Chitale on Sep 20, 2010 5:19 PM

Maybe you are looking for

  • Help!....I'm going nutz!  I can't sync......

    This has been an ongoing problem. First some facts: Computer: MacPro tower, 2 x 2.8 GHz Quad-Core Intel Xeon Memory: 2 GB 800 MHz DDR2 FB-DIMM OS: 10.5.8 iTunes: 9.2.1 iPod: 5th gen, 60 gig, ver 1.3 Software Update says everything is up to date. Prev

  • Configuring the sound on my tascam interphase

    Im new to the apple community and I've upgraded my studio monitors to jbl playing through my tascam interphase. iTunes play but nothing on safari. all videos pause after .5secs. can somebody help i can't enjoy my christmas gift ?

  • How to install a newer version when I already have an older version?

    I have an older version of Firefox. How do I install the latest version? If I follow the instructions for installing Firefox will it automatically upgrade my current version? Why is Firefox not automatically installing newer versions?

  • How can update my mac from 10.5.8

    How can I update it from 10.5.8 Do I need to buy something or is there a direct download

  • Please bring back Page Setup...

    Is there any way to get back the little popup window at the bottom of Document windows showing the current page layout? As it is now, I have to go into the new-style Print dialogue which takes forever to open, is vastly confusing, and does not rememb