Replacing a materialized view

Hi ,
How do i actually replace a materialized view ?
i tried create or replace materialized view , when compiling it gave me error
or i can only drop it ?
tks & rdgs

Just drop the mv and re-create it. There is no replace command with mv.
Connected.
SQL> CREATE MATERIALIZED VIEW MY_MV AS
2 SELECT * FROM MYTEST.TIMES;
Materialized view created.
SQL> CREATE OR REPLACE MATERIALIZED VIEW MY_MV_1 AS
2 SELECT * FROM MYTEST.TEST;
CREATE OR REPLACE MATERIALIZED VIEW MY_MV_1 AS
ERROR at line 1:
ORA-00922: missing or invalid option
tHANKS

Similar Messages

  • The data of my materialized view....in the while

    Hello
    We have problems with materialized views
    We have one wich re-build each a short period of time
    ¿Can i avoid the data to dissapear in the time process of refresh?
    Is so annoing to our clients to see that "from time to time" the data just dissapear for one period of time -the time while the materialized view is refreshing-
    Thank you in advance
    Bruno. Madrid. Spain

    > Is so annoing to our clients to see that "from time to time" the data just dissapear for
    one period of time -the time while the materialized view is refreshing-
    Have a similar problem. And dealing with large data volumes that makes the DELETE of the MV a very undesirable feature. Not as much a the resource footprint required, but the time it takes to do this - and the very tight processing windows that exist.
    The solution is a self-rolled and very likely not ideal for most - but it works well enough for us in production.
    No MV. Create a partition table. Create a staging table. Do a manual "full refresh" of the staging table (TRUNCATE and direct path INSERT). Follow this by a partition exchange with the partition table (no validation and including indexes). The result is that the data is replaced in the partitioned table within a second - no long running and expensive DELETE. End-users not effected by having a truncate pulling the data from beneath their reports.

  • Sdo_cs.transform procedure in a materialized view

    Hi all,
    Oracle version :10.2.0.4
    I am trying to do perform reprojection in a materialised view ( refresh on demand, complete mode).
    It seems everytime I refresh the MV ,this error pops up.
    SQL> exec dbms_mview.refresh('SUPER', 'C');
    BEGIN dbms_mview.refresh('SUPER', 'C'); END;
    ERROR at line 1:
    ORA-12008: error in materialized view refresh path
    ORA-06531: Reference to uninitialized collection
    ORA-06512: at "SYS.DBMS_SNAPSHOT", line 2251
    ORA-06512: at "SYS.DBMS_SNAPSHOT", line 2457
    ORA-06512: at "SYS.DBMS_SNAPSHOT", line 2426
    ORA-06512: at line 1
    <code>
    CREATE MATERIALIZED VIEW "SUPER" ORGANIZATION HEAP PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT) TABLESPACE "DATA_DATA" BUILD DEFERRED USING INDEX REFRESH COMPLETE ON DEMAND USING DEFAULT LOCAL ROLLBACK SEGMENT DISABLE QUERY REWRITE
    AS
    SELECT seq_nextval AS PID,
    SITE,
    STATE,
    reproject(geoloc)
    FROM BJON;
    <code>
    The procedure of reproject
    create or replace
    FUNCTION "REPROJECT" (p_coordinates in SDO_GEOMETRY)
         return SDO_GEOMETRY deterministic
         as v_coordinates SDO_GEOMETRY;
         BEGIN
              v_coordinates := sdo_cs.transform (p_coordinates, 4326);
              RETURN v_coordinates;
         end REPROJECT;
    Can anyone let me know hw I can put plug thereprojection in a materialized view.
    Edited by: CrackerJack on May 2, 2012 11:00 PM

    Hi all,
    Any clues?
    I have died of anymore ideas to make this work.
    All I need is a updated table with
    Primary key ,
    GEOMETRY 4326
    spatial index.
    metadata
    Teh materialized view is perfect except I can't do the reprojections.
    ORA-06531: Reference to uninitialized collection means have some null values in the array , but if you remove the Reproject function and just geometry itself , the materialised view works brilliant.
    I tried converting to 0,0 point in the function to tackle the nulls in array if any.. but doesn't work.
    sdo_cs.transform(nvl(geoloc, mdsys.sdo_geometry(2001, 8307, mdsys.sdo_point_type(0,0,NULL),NULL,NULL)),82027).get_wkt()
    Any ideas is much appreciated.
    Edited by: CrackerJack on May 6, 2012 10:27 PM

  • 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;
    /

  • Create a materialized view on a base view

    I want to create a materialized view on a master view (ordinary view, not a mat. view). But i can not make it work. can it work? I have created a primary key on the master view as:
    create or replace force view v_xxx(a, b)
    unique rely disable novalidate,
    constraint a_pk primary key (a) rely disable novalidate)
    as select a ,b
    from xxx
    When I then try to create the mat. view:
    create materialized view mv_xxx refresh complete
    with primary key
    as
    select * from [email protected]
    I get:
    ORA-12014: table 'V_xxx' does not contain a primary key constraint
    What am I doing wrong?

    I suppose OP is on a 9i db (cause I can't reproduce on 11gr2) and the error is because of the database link:
    SQL> create table emp_t
    as
       select * from emp
    Table created.
    SQL> create or replace view v_emp_t
       empno   constraint v_emp_t_pk primary key rely disable novalidate,
       ename
    as
       select empno, ename from emp_t
    View created.
    SQL> create materialized view mv_emp_t refresh complete
    with primary key
    as
    select * from v_emp_t
    Materialized View created.
    SQL> drop materialized view mv_emp_t
    Materialized View dropped.
    SQL> create materialized view mv_emp_t refresh complete
    with primary key
    as
    select * from v_emp_t@loopback
    Error at line 32
    ORA-12014: table 'V_EMP_T' does not contain a primary key constraintYou can wrap the view with the db link in another view though:
    SQL> create or replace view v_emp_t2
       empno   constraint v_emp_t2_pk primary key rely disable novalidate,
       ename
    as
       select empno, ename from v_emp_t@loopback
    View created.
    SQL> create materialized view mv_emp_t refresh complete
    with primary key
    as
    select * from v_emp_t2
    Materialized View created.

  • How to use materialized view in stored procedure

    in my stored procedure I use couple of queries (see the script below). I want to create materialized views to replace these queries. Is it possible to achieve and how to achieve it in my case? thanks in advance
    set serveroutput on
    DECLARE
      v_cur_tid NUMBER(5):=0;
      v_cur_cs_attendance NUMBER(5):=0;
      v_cur_c_tot_enrolments NUMBER(5):=0;
      v_most_enrolments NUMBER(5):=0;
      v_least_enrolments NUMBER(5):=0;
      v_most_pop_cid NUMBER(5):=0;
      v_least_pop_cid NUMBER(5):=0;
      CURSOR class_cursor IS
    select
    id,
    name,
    max_attendees
    from
    class
    where
    id in (select distinct(event_id) from trainer_schedule where event_type='c' and is_active='y')
    order by id;
    BEGIN
    DBMS_OUTPUT.PUT_LINE('==================================================================================================================================');
    --print the report header
    DBMS_OUTPUT.PUT_LINE('Summary Report No.3: Training Class Active Schedules Summary Report');
    FOR r_class IN class_cursor LOOP
    --print the header or subsection
    select sum(enrolments) into v_cur_c_tot_enrolments from class_schedule where class_id = r_class.id;
    IF v_most_enrolments < v_cur_c_tot_enrolments OR v_most_enrolments = 0
    THEN v_most_enrolments := v_cur_c_tot_enrolments; v_most_pop_cid := r_class.id;
    END IF;
    IF v_least_enrolments > v_cur_c_tot_enrolments OR v_least_enrolments = 0
    THEN v_least_enrolments := v_cur_c_tot_enrolments; v_least_pop_cid := r_class.id;
    END IF;
    DBMS_OUTPUT.PUT_LINE('******************************************************************************************');
    DBMS_OUTPUT.PUT_LINE('CLASS_ID: '  || r_class.id ||'     '|| 'CLASS_NAME: '  || r_class.name ||'     '||'CAPACITY: '  || r_class.max_attendees ||'     '||'TOTAL_ENROLMENTS: '  || v_cur_c_tot_enrolments);
    DBMS_OUTPUT.PUT_LINE(rpad('____________', 12) || lpad('____________', 12) || lpad('____________________', 20) || lpad('____________________', 20) || lpad('____________',12) || lpad('____________',12));
    DBMS_OUTPUT.PUT_LINE(rpad('SCHEDULE_ID', 12) || lpad('TRAINER_ID',12) || lpad('START_TIME', 20) || lpad('END_TIME',20) || lpad('ENROLMENTS',12) || lpad('ATTENDANCE',12));
    DBMS_OUTPUT.PUT_LINE(rpad('____________', 12) || lpad('____________',12) || lpad('____________________', 20) || lpad('____________________', 20) || lpad('____________',12) || lpad('____________',12));
    FOR r_cs IN (select id,to_char(start_time,'DD-MM-YYYY HH24:Mi') as start_time, to_char(end_time,'DD-MM-YYYY HH24:Mi') as end_time, enrolments from class_schedule where class_id = r_class.id order by id)
    LOOP
    select trainer_id into v_cur_tid from trainer_schedule where event_type='c' and event_id = r_cs.id;
    select count(training_session.id) into v_cur_cs_attendance
    from training_session, class_schedule
    where training_session.attended = 'y' and
    training_session.type='c'and
    to_char(training_session.start_time,'DD-MM-YYYY HH24:Mi') = to_char(class_schedule.start_time,'DD-MM-YYYY HH24:Mi') and
    class_schedule.id = r_cs.id;
    DBMS_OUTPUT.PUT_LINE(rpad(r_cs.id, 12) || lpad(v_cur_tid,12) || lpad(r_cs.start_time, 20) || lpad(r_cs.end_time,20) || lpad(r_cs.enrolments,12) || lpad(v_cur_cs_attendance,12));
    END LOOP;
    END LOOP;
    DBMS_OUTPUT.PUT_LINE('******************************************************************************************');
    DBMS_OUTPUT.PUT_LINE('******************************************************************************************');
    DBMS_OUTPUT.PUT_LINE('MOST_POPULAR_CLASS:  '||v_most_pop_cid||'      TOTAL_ENROLMENTS_TO_DATE: '||v_most_enrolments);
    DBMS_OUTPUT.PUT_LINE('LEAST_POPULAR_CLASS: '||v_least_pop_cid||'      TOTAL_ENROLMENTS_TO_DATE: '||v_least_enrolments);
    DBMS_OUTPUT.PUT_LINE('==================================================================================================================================');
    END;
    /

    Hi,
    you could use Dynamic SQL /Execute immediate to run DDL from a stored procedure.
    http://download-uk.oracle.com/docs/cd/B10501_01/appdev.920/a96624/11_dynam.htm
    Could you please tell why do you want to create a materialized view in stored procedure ?
    How frequently you will runt this procedure . It would is better to create a MV once and use it.
    thanks

  • Materialized view with synonym

    HI,
    I created a materialized view that is based on a synonym, depending on the table you want to modify using the synonym to point to another table, but to cool it still uses the original referenced table synonym.
    Is there a way, without deleting the materialized view, that the refresh will change the definition?
    Example Post
    CREATE OR REPLACE SYNONYM DWH.SYN_CCBCON4 FOR DWHADC.CCBCON4D;
    CREATE MATERIALIZED VIEW DWH.VWM_CTO_INFO_0 (CONTRATO,FCH_ENTRADA)
    TABLESPACE TS_DWH_01
    NOCACHE
    LOGGING
    NOCOMPRESS
    NOPARALLEL
    BUILD IMMEDIATE
    USING INDEX
    REFRESH COMPLETE ON DEMAND
    WITH PRIMARY KEY
    AS
    SELECT contrato contrato, MIN (fch_entrada) fch_entrada
    FROM syn_ccbcon4
    WHERE NVL (fecha_modificacion, TO_DATE (fch_entrada, 'YYYYMMDD')) >=
    f_calc_max_fch_modif ('CTO_INFO', 'FCH_MODIF', '0')
    AND posic_actual NOT IN ('030', '050')
    GROUP BY contrato;
    --> REFRESH MV
    Change SYNONYM
    CREATE OR REPLACE SYNONYM DWH.SYN_CCBCON4 FOR DWHADC.CCBCON5D;
    --> REFRESH MV
    But the data is of the table CCBCON4D.
    thankx
    Jorge.

    Hi,
    Sorry for my previous response, I am editing this now.
    I don't think you can do this because Oracle seems to store the original definition in internal table SYS.SNAP$ and it will not allow you to do so unless you recreate your MV after changing the synonym definition. Reason is because physical structure of Mview is present and changing synonym definition means that now structure of mview can be compromised by new definition of synonym and hence makes things inconsistent.
    In SYS.SNAP$ you can see original table where you synonym was pointing to when you created the MVIEW.
    Salman
    Edited by: Salman Qureshi on Dec 11, 2012 5:29 PM

  • Updatable Materialized View with Union ALL

    (please don't ask about db structure)
    DB: 11gR2
    create table table_1  (
        id number primary key,
        val varchar2(100)
    create table table_2  (
        id number primary key,
        val varchar2(100)
    insert into table_1(id) values (0);
    insert into table_1(id) values (2);
    insert into table_1(id) values (3);
    insert into table_1(id) values (4);
    insert into table_1(id) values (5);
    insert into table_2(id) values (10);
    insert into table_2(id) values (12);
    insert into table_2(id) values (13);
    insert into table_2(id) values (14);
    insert into table_2(id) values (15);
    update table_1 set val='Table1 val:'||id;
    update table_2 set val='Table2 val:'||id;
    create view v_table_all as
    select * from table_1
    view V_TABLE_ALL created.
    select * from v_table_all;
    ID                     VAL                                                                                                 
    0                      Table1 val:0                                                                                        
    2                      Table1 val:2                                                                                        
    3                      Table1 val:3                                                                                        
    4                      Table1 val:4                                                                                        
    5                      Table1 val:5                                                                                        
    select column_name, updatable, insertable, deletable
    from user_updatable_columns
    where table_name = 'V_TABLE_ALL'
    COLUMN_NAME                    UPDATABLE INSERTABLE DELETABLE
    ID                             YES       YES        YES      
    VAL                            YES       YES        YES      
    update v_table_all set val='XXX changed' where id = 3;
    1 row updated.
    select * from table_1;
    ID                     VAL                                                                                                 
    0                      Table1 val:0                                                                                        
    2                      Table1 val:2                                                                                        
    3                      XXX changed                                                                                         
    4                      Table1 val:4                                                                                        
    5                      Table1 val:5                                                                                        
    rollback;
    select * from table_1;
    ID                     VAL                                                                                                 
    0                      Table1 val:0                                                                                        
    2                      Table1 val:2                                                                                        
    3                      Table1 val:3                                                                                        
    4                      Table1 val:4                                                                                        
    5                      Table1 val:5                                                                                        
    create or replace view v_table_all as
    select * from table_1
    union select * from table_2;
    view V_TABLE_ALL created.
    select * from v_table_all;
    ID                     VAL                                                                                                 
    0                      Table1 val:0                                                                                        
    2                      Table1 val:2                                                                                        
    3                      Table1 val:3                                                                                        
    4                      Table1 val:4                                                                                        
    5                      Table1 val:5                                                                                        
    10                     Table2 val:10                                                                                       
    12                     Table2 val:12                                                                                       
    13                     Table2 val:13                                                                                       
    14                     Table2 val:14                                                                                       
    15                     Table2 val:15  
    select column_name, updatable, insertable, deletable
    from user_updatable_columns
    where table_name = 'V_TABLE_ALL'
    COLUMN_NAME                    UPDATABLE INSERTABLE DELETABLE
    ID                             NO        NO         NO       
    VAL                            NO        NO         NO       
    trying update:
    update v_table_all set val='XXX changed' where id = 3;
    SQL-Fehler: ORA-01732: Datenmanipulationsoperation auf dieser View nicht zulässig
    01732. 00000 -  "data manipulation operation not legal on this view"
    *Cause:   
    *Action:
    drop view v_table_all;
    view V_TABLE_ALL dropped.all is ok before this point.
    now we want create a new materialized view with some query
    create  materialized view v_table_all
    as
    select * from table_1
    union all select * from table_2 ;
    materialized view V_TABLE_ALL created.
    select column_name, updatable, insertable, deletable
    from user_updatable_columns
    where table_name = 'V_TABLE_ALL'
    COLUMN_NAME                    UPDATABLE INSERTABLE DELETABLE
    ID                             YES       YES        YES      
    VAL                            YES       YES        YES       it seems to be ok with update.
    but...
    update v_table_all set val='XXX changed' where id = 3;
    SQL-Fehler: ORA-01732: Datenmanipulationsoperation auf dieser View nicht zulässig
    01732. 00000 -  "data manipulation operation not legal on this view"
    *Cause:   
    *Action:How can solve this issue??
    Any suggestion

    Looks like user_updatable_columns sort of thinks the MV is just a table - I don't know about that...
    An MV on a single table can be updated - I tried that and it works:
    create materialized view mv_table_1 for update
    as
    select * from table_1;I noticed [url http://download.oracle.com/docs/cd/E11882_01/server.112/e16579/advmv.htm#sthref294]examples stating the UNION ALL needs a "marker" so Oracle can know from the data which source table a row in the MV originates from - like this:
    create materialized view v_table_all for update
    as
    select 'T1' tab_id, table_1.* from table_1
    union all
    select 'T2' tab_id, table_2.* from table_2 ;But that also fails (the "marker" requirement was specifically for FAST REFRESH, so it was just a long shot ;-) )
    What are you planning to do?
    <li>Create the MV.
    <li>Update records in the MV - which then is no longer consistent with the source data.
    <li>Schedule a complete refresh once in a while - thereby overwriting/losing the updates in the MV.
    If that is the case, I suggest using a true table rather than an MV.
    <li>Create table t_table_all as select ... .
    <li>Update records in the table - which then is no longer consistent with the source data.
    <li>Schedule a job to delete table and insert into table select ... once in a while - thereby overwriting/losing the updates in the table.
    In other words a kind of "do it yourself MV".
    I cannot see another way at the moment? But perhaps try in the data warehousing forum - the people there may have greater experience with MV's ;-)

  • Synonym problem with external table in materialized view

    I have a materialized view that includes selects on two external tables.
    However, no matter how I try to access the external tables, the creation fails with a "Synonym Translation Is No Longer Valid" (ORA-00980) error.
    This happens even when I replace the tablename with the full table name, including the link.
    I can create a view just fine, but if I then try something like CREATE MATERIALIZED VIEW mvw_my_view AS SELECT * FROM vw_my_view (where vw_my_view is the view in question), it still throws the Synonym Translation exception.

    00980, 00000, "synonym translation is no longer valid"
    // *Cause: A synonym did not translate to a legal target object. This
    //         could happen for one of the following reasons:
    //         1. The target schema does not exist.
    //         2. The target object does not exist.
    //         3. The synonym specifies an incorrect database link.
    //         4. The synonym is not versioned but specifies a versioned
    //            target object.
    // *Action: Change the synonym definition so that the synonym points at
    //          a legal target object.It is really, Really, REALLY difficult to fix a problem that can not be seen.
    use COPY & PASTE so we can see what you do & how Oracle responds.

  • Error when Create Materialized View

    Hi
    When I tried to create MV show me error :
    SQL> @CRIA_MV_ARC_BW.SQL
    AND INDUSTRIAL.CD_FABRICA = SUBSTR(ARC.DS_ARC, 1, 3)
    ERROR at line 88:
    ORA-01031: insufficient privilegesI am using Oracle 9.02 and there are Grant for all Tablles , my query of creation is:
    CREATE MATERIALIZED VIEW CLIBGF.MV_ARC_BW
    NOCACHE
    LOGGING
    NOPARALLEL
    BUILD IMMEDIATE
    REFRESH FORCE
    START WITH TO_DATE('26-nov-2009 02:00:00','dd-mon-yyyy hh24:mi:ss')
    NEXT trunc(sysdate) + 1/12
    ENABLE QUERY REWRITE
    AS
    SELECT     MAX(NVL((SELECT  DECODE(A.T$CDNG$O,'F',DECODE(TRIM(B.T$CALC$O),'S','C',A.T$CDNG$O),A.T$CDNG$O)
                     FROM TRITON.TTDFAT995501 A, TRITON.TTDFAT996501 B
                    WHERE A.T$OCOM$O + 0 = ARC.CD_UNIDADE_EXPEDIDORA
                      AND A.T$NDOC$O = NOTAS.CD_NOTA
                      AND (A.T$OCOM$O = B.T$OCOM$O AND A.T$NREF$O = B.T$NREF$O)
                                        AND ROWNUM =1),
                   0)) NEGOCIO,
           ARC.CD_CLIENTE CD_CLIENTE,
           CLIENTE.T$NAMA DS_CLIENTE,
           ARC.CD_ARC,
           ARC.CD_STATUS,
           ARC.CD_STATUS || ' - ' || STATUS.DS_STATUS STATUS,
           TO_CHAR(ARC.DT_EMISSAO, 'DD/MM/YYYY') DT_EMISSAO,
           TO_CHAR(ACAO_INV.DT_REALIZADO, 'DD/MM/YYYY') DT_REALIZADO_INVESTIGACAO,
           ARC.CD_MARCA || ' - ' || MARCA.T$DSMA$O MARCA,
           ARC.CD_PRODUTO CD_PRODUTO,
           EMBALAGEM.T$CDAC$O || ' - ' || EMBALAGEM.T$DESC$O DS_EMBALAGEM,
           SUBSTR(ARC.DS_ARC, 1, 3) CD_COMPANHIA_PRODUTORA,
            ARC.CD_MOTIVO_RECLAMACAO CD_MOTIVO_RECLAMACAO,
            MOTIVO.DS_ITEM DS_MOTIVO_RECLAMACAO,
           DECODE(ARC.FL_PROCEDENCIA, 0, 'PROCEDENTE', 1, 'IMPROCEDENTE', ' ') PROCEDENCIA,
           SUM(NVL((SELECT SUM(NVL(T$IQUA$O, 0))
                     FROM TRITON.TTDFAT995501 A, TRITON.TTDFAT996501 B
                    WHERE A.T$OCOM$O + 0 = ARC.CD_UNIDADE_EXPEDIDORA
                      AND A.T$NDOC$O = NOTAS.CD_NOTA
                      AND (A.T$OCOM$O = B.T$OCOM$O AND A.T$NREF$O = B.T$NREF$O)),
                   0)) NR_QUANTIDADE_VENDIDA,
               ARC.NR_QUANTIDADE_AFETADA NR_QUANTIDADE_AFETADA,     
           ARC.NR_QUANTIDADE_AFETADA_REAL NR_QUANTIDADE_AFETADA_REAL,
           DS_JUSTIFICATIVA DSJUST
      FROM ARCTB_ARC                 ARC,
           ARCTB_NOTAS               NOTAS,
           ARCTB_TABELA_MOTIVO       MOTIVO,
           ARCTB_ACAO_IMEDIATA       ACAO_INV,
           ARCTB_ACAO_IMEDIATA       ACAO_IME,
           ARCTB_STATUS              STATUS,
           TRITON.TTCCOM010501       CLIENTE,
           TRITON.TTCCOM936501       CIDADE,
           TRITON.TTIITM001810       D,
           TRITON.TTIITM983501       PRODUTO,
           TRITON.TTFGLD010806       CC,
           TRITON.TTCCOM983501       MARCA,
           TRITON.TTCCOM000501       CIA,
           TRITON.TTIITM982501       NAT,
           SEI.SIBTB_MULTIMARCA      MULTIMARCA,
           SEI.SIBTB_DIRETORIA_DEPTO DIRETORIA,
           TRITON.TTCCOM994501       USUARIO,
           ARCTB_GERENCIA_INDUSTRIAL INDUSTRIAL,
           TRITON.TTIITM984501       EMBALAGEM
    WHERE ARC.CD_ARC = NOTAS.CD_ARC(+)
       AND ARC.CD_ARC = ACAO_INV.CD_ARC(+)
       AND ACAO_INV.CD_TIPO_ACAO(+) = 0
       AND ACAO_INV.CD_ACAO_IMEDIATA(+) = 999
       AND ARC.CD_ARC = ACAO_IME.CD_ARC(+)
       AND ACAO_IME.CD_TIPO_ACAO(+) = 1
       AND ACAO_IME.CD_ACAO_IMEDIATA(+) = 999
       AND ARC.CD_CLIENTE = CLIENTE.T$CUNO(+)
       AND CLIENTE.T$ESTA$L = CIDADE.T$ESTA$L(+)
       AND CLIENTE.T$CDMU$L = CIDADE.T$MUNI$L(+)
       AND TRIM(REPLACE(ARC.CD_PRODUTO, '-', '')) =
           TRIM(REPLACE(D.T$ITEM(+), '-', ''))
       AND TRIM(REPLACE(ARC.CD_PRODUTO, '-', '')) =
           TRIM(REPLACE(PRODUTO.T$ITEM$O(+), '-', ''))
       AND PRODUTO.T$PROC$O = NAT.T$PROC$O(+)
       AND EMBALAGEM.T$CDAC$O(+) = PRODUTO.T$CDAC$O
       AND ARC.CD_MOTIVO_RECLAMACAO = MOTIVO.CD_ITEM(+)
       AND ARC.CD_MARCA = MARCA.T$CDMA$O(+)
       AND SUBSTR(ARC.DS_ARC, 1, 3) = CIA.T$NCMP(+)
       AND ARC.CD_STATUS = STATUS.CD_STATUS(+)
       AND TRIM(ARC.CD_CENTRO_CUSTO) = TRIM(CC.T$DIMX(+))
       AND CC.T$DTYP(+) = 2
       AND CC.T$SUBL(+) = 0
       AND ARC.CD_DEPTO_MULTIMARCA = MULTIMARCA.CD_MULTIMARCA(+)
       AND ARC.CD_DEPTO = DIRETORIA.CD_DEPTO(+)
       AND ARC.CD_USUARIO = TRIM(USUARIO.T$CDUS$O(+))
       AND ARC.CD_STATUS IS NOT NULL
       AND ARC.CD_MOTIVO_RECLAMACAO = MOTIVO.CD_ITEM(+)
       AND INDUSTRIAL.CD_FABRICA = SUBSTR(ARC.DS_ARC, 1, 3)
       GROUP BY TO_CHAR(ARC.DT_EMISSAO, 'YYYY'),
              TO_CHAR(ARC.DT_EMISSAO, 'MM'),
              ARC.CD_ARC,
              ARC.DS_ARC,
              ARC.DS_SUPERVISOR,
              ARC.CD_STATUS,
              STATUS.DS_STATUS,
              TO_CHAR(ARC.DT_EMISSAO, 'DD/MM/YYYY'),
              TO_CHAR(ACAO_INV.DT_ORIGINAL, 'DD/MM/YYYY'),
              TO_CHAR(ACAO_INV.DT_REALIZADO, 'DD/MM/YYYY'),
              TO_CHAR(ACAO_IME.DT_ORIGINAL, 'DD/MM/YYYY'),
              TO_CHAR(ACAO_IME.DT_REALIZADO, 'DD/MM/YYYY'),
              TO_CHAR(ARC.DT_PROCEDENCIA, 'DD/MM/YYYY'),
              TO_CHAR(ARC.DT_RECEBIMENTO, 'DD/MM/YYYY'),
              TO_CHAR(NVL(ARC.DT_APROVACAO_INDUSTRIAL,
                          ARC.DT_APROVACAO_COMERCIAL),
                      'DD/MM/YYYY'),
              ARC.CD_CLIENTE,
              CLIENTE.T$NAMA,
              CIDADE.T$DSCA$L,
              ARC.CD_MARCA,
              MARCA.T$DSMA$O,
              ARC.CD_PRODUTO,
              D.T$SEAK,
              EMBALAGEM.T$CDAC$O || ' - ' || EMBALAGEM.T$DESC$O,
              NAT.T$DESC$O,
              ARC.NR_LOTE,
              ARC.DT_FABRICACAO,
              SUBSTR(ARC.DS_ARC, 1, 3),
              CIA.T$CITY,
              ARC.CD_MOTIVO_RECLAMACAO,
              MOTIVO.DS_ITEM,
              DECODE(ARC.FL_PROCEDENCIA,
                     0,
                     'PROCEDENTE',
                     1,
                     'IMPROCEDENTE',
              ARC.DS_DISPOSICAO,
              ARC.CD_CENTRO_CUSTO,
              CC.T$DESC,
              ARC.NR_QUANTIDADE_AFETADA,
              DS_JUSTIFICATIVA,
              DS_DISPOSICAO,
              CD_RESPONSAVEL_CAUSA,
              ARC.NR_QUANTIDADE_AFETADA_REAL,
              ARC.DT_ATENDIMENTO,
              MOTIVO.CLASSIFICACAO,
              ARC.DS_COORDENADOR,
              ARC.FL_ATENDIMENTO,
              TO_CHAR(ARC.DT_ATENDIMENTO, 'DD/MM/YYYY'),
              ARC.DS_COORDENADOR_INVESTIGACAO,
              INDUSTRIAL.REGIAO
    ORDER BY ARC.CD_ARC DESC;
    Edited by: muttleychess on Nov 25, 2009 10:25 AM

    Please see my privilege
    GRANTEE PRIVILEGE ADM
    CLIBGF CREATE TABLE NO
    CLIBGF CREATE ANY VIEW NO
    CLIBGF CREATE SNAPSHOT NO
    CLIBGF SELECT ANY TABLE NO
    CLIBGF CREATE ANY TRIGGER NO
    CLIBGF CREATE ANY SNAPSHOT NO

  • Using oracle text on a non-materialized view

    I'm having trouble tracking down an error when using oracle text on a non-materialized view (indexes are on the referenced columns). My database has a users table and a user history table which saves the old values when a user profile changes. My view performs a "union all" so I can select from both at once.
    I would like to use oracle text to perform a "contains" on the view whenever someone signs up to see if any current users or historical entries contain the desired username.
    The following works fine:
    contains(user_history_view, 'bill')but when I reference anything in the contains clause, i get a "column is not indexed" error:
    contains(user_history_view, signup.user_name) --signup.username is 'bill'Here is a stripped-down demonstration (I am using version 10.2.0.4.0)
    create table signup (
      signup_id   number(19,0) not null,
      signup_name varchar2(255),
      primary key (signup_id)
    create table users (
      user_id   number(19,0) not null,
      user_name varchar2(255),
      primary key (user_id)
    create table user_history (
      history_id number(19,0) not null,
      user_id    number(19,0) not null,
      user_name  varchar2(255),
      primary key (history_id),
      foreign key (user_id) references users on delete set null
    create index user_name_index on users(user_name)
    indextype is ctxsys.context parameters ('sync (on commit)');
    create index user_hist_name_index on user_history(user_name)
    indextype is ctxsys.context parameters ('sync (on commit)');
    create index signup_name_index on signup(signup_name)
    indextype is ctxsys.context parameters ('sync (on commit)');
    create or replace force view user_history_view
    (user_id, user_name, flag_history) as
    select user_id, user_name, 'N' from users
    union all
    select user_id, user_name, 'Y' from user_history;
    --user bill changed his name to bob, and there is a pending signup for another bill
    insert into users(user_id, user_name) values (1, 'bob');
    insert into user_history(history_id, user_id, user_name) values (1, 1, 'bill');
    insert into signup(signup_id, signup_name) values(1, 'bill');
    commit;
    --works
    select * from user_history_view users, signup new_user
    where new_user.signup_id = 1
    and contains(users.user_name, 'bill')>0;
    --fails
    select * from user_history_view users, signup new_user
    where new_user.signup_id = 1
    and contains(users.user_name, new_user.signup_name)>0;I could move everything into a materialized view, but querying against real-time data like this would be ideal. Any help would be greatly appreciated.

    Hi,
    this is to my knowledge not possible. It is hard for Oracle to do, think about a table with many rows, every row with that column must be checked. So I think only a single varchar2 is possible. Maybe for you will a function work. It is possible to give a function as second parameter.
    function return_signup
    return varchar2
    is
      l_signup_name signup.signup_name%type;
    begin
      select signup_name
      into l_signup_name
      from signup
      where signup_id = 1
      and rownum = 1
      return l_signup_name;
    exception
      when no_data_found
      then
        l_signup_name := 'abracadabra'; -- hope does not exist
        return l_signup_name;
    end;Now you can use above function in the contains.
    select * from user_history_view users --, signup new_user
    --where new_user.signup_id = 1
    where contains(users.user_name, return_signup)>0;I didn't test the code! Maybe you have to adjust the function for your needs. But it is a idea how this can be done.
    Otherwise you must make the check by normaly check the columns by simple using a join:
    select * from user_history_view users, signup new_user
    where new_user.signup_id = 1
    and users.user_name = new_user.signup_name;Herald ten Dam
    htendam.wordpress.com

  • Do I need to tune the base query of my materialized view ?

    Hi gurus,
    We implement materialized view (FAST REFRESH ON COMMIT) on base table used in OLTP system. In fact the MV itself is also queried by the OLTP system itself, interactively.
    Currently user complain that after they input transaction, they see that the MV is not refresh as soon as they commit the transaction.
    (it takes 5 to 10 minutes before they see the update on the MV)
    The query of the MV is attached below, it consists of union all of two queries but actually the real query has 13 queries on a UNION ALL.
    The question is :
    Do I need to tune the query that forms the MV ?
    Does it impact the refresh time of the MV ?
    Thank you for your help,
    xtanto
    SELECT GRNH.DOC_CODE ||' '|| GRNH.GRN_NO, GRNH.GRN_DATE, GRNH.REGS_CODE,
    F_Convert_Qty_K(GRND.PRODUCT, GRND.QTY, GRND.UOM) QTY_IN, 0 QTY_OUT, 0 QTY_ADJ, 'N/A'.....
    FROM GRN_LOCAL_D GRND
              JOIN GRN_LOCAL_H GRNH ON GRNH.GRNH_ID = GRND.GRNH_ID
              WHERE GRND.PRODUCT IS NOT NULL AND GRNH.WH_CODE IS NOT NULL
    UNION ALL
    SELECT GRNH.DOC_CODE ||' '|| GRNH.GRN_NO, GRNH.GRN_DATE, GRNH.REGS_CODE,
    F_Convert_Qty_K(GRND.PRODUCT_B, GRND.QTY_B, GRND.UOM_B) QTY_IN, 0 QTY_OUT, 0 QTY_ADJ, 'N/A'...
    FROM GRN_LOCAL_D GRND
    JOIN GRN_LOCAL_H GRNH ON GRNH.GRNH_ID = GRND.GRNH_ID
    WHERE GRND.PRODUCT_B IS NOT NULL AND GRNH.WH_CODE IS NOT NULL
    UNION ALL
         ......

    Hi Justin & APC,
    Are they seeing a 5-10 minute delay in being able to commit their transaction?NO, the commit itself is completed normally, but after that when they go to the page (this is webbased app) that display data from the MV, the newly committed transactionis not there yet. Only after 5-10 minutes we can see the new data.
    What does the F_Convert_Qty_K() function do?It is a function that convert the quantity from whatever Unit Of Measurement (UOM) into the smallest UOM. Below is the code.
    So the question remains:
    why intermittently theere is delay before the new data visible in the MV ?
    Thanks you,
    xtanto
    CREATE OR REPLACE FUNCTION F_Convert_Qty (pProduct VARCHAR2, pQty NUMBER, pUOM VARCHAR2)
    RETURN NUMBER
    IS
    vQtyBase NUMBER(13,5);
    BEGIN
    SELECT CASE WHEN pUOM = ( SELECT UOM_BASE FROM PRODUCTS WHERE PRODUCT = pProduct)
              THEN pQty
         ELSE
                   SELECT ROUND(pQty * Coefficient / Divisor, 5)
                   FROM (
                             SELECT Coefficient, Divisor FROM CONVERT_UOM
                             WHERE PRODUCT = pProduct AND UOM_CONVERT = pUOM
                             ) tmp
              END INTO vQtyBase FROM DUAL;
    --RETURN (vQtyBase) ;
    RETURN ( NVL(vQtyBase,0) ) ;
    END F_Convert_Qty;
    /

  • How to create materialized  view with parameter and index ?

    Hi all,
    i am using oracle 11g.
    i want to create  parameter materialized view  with two parameter (STORED_VALUE, LOV_NAME) with  an index .
    i have below view
    CREATE OR REPLACE FORCE VIEW SR_MY_TEST(DISPLAYED_VALUE, STORED_VALUE, LOV_NAME) AS
      SELECT  DISPLAYED_VALUE , LOVVALUE.STORED_VALUE , lovname.lov_name
               FROM (SELECT T.LOV_VALUE_ID,
          T.LOV_ID,
          T.ORG_ENTITY_ID,
          T.STORED_VALUE,
          T.DISPLAYED_VALUE,
          T.ENTERPRISE_ID
         FROM MS_QS_LIST_OF_VALUES_T T) lovvalue, ms_qs_lov_names lovname
              WHERE lovvalue.lov_id = lovname.lov_id
                AND lovvalue.org_entity_id = 1
                and LOVVALUE.ENTERPRISE_ID = 100000
                AND LOVNAME.ENTERPRISE_ID = 100000;
    i want to create index on   STORED_VALUE, LOV_NAME
    Thanks
    Damby

    No.AFAIK, there's nothing called as "parameterized MV".
    Materialized View store data like tables (and not like Views). So, does it make sense when you say - "table with parameters" ?
    Could you please explain your business requirement?
    What is the purpose behind those 2 parameters?

  • Material View Refresh Slow under 10.2.0.4?

    I have several material views that refreshed in minutes under 9.2.0.6, but are now taking hours under 10.2.0.4. I'm thinking it's in my initialization parameters. I remember the upgrade process making at least one of the HASH parameters obsolete.
    Can anyone point me in a direction quickly?
    A little more info... If I drop and recreate the materialized view from scratch it take just a few minutes to build.
    Thank you.
    Edited by: golflover1 on Jan 3, 2009 7:32 AM
    Edited by: golflover1 on Jan 3, 2009 7:33 AM

    What type of refresh you use to refresh the Materialized Views? (COMPLETE, FAST, FORCE)
    Since you migrated to 10g there is a slight difference in how Oracle does the refresh.
    Prior to 10g, when a materialized view is completely refreshed the base table was truncated and then populated with a data.
    Starting from 10g, the default behavior is changed and truncate is replaced with delete which results in longer refresh times.
    This is expected behavior, even though there was a bug associated with it Bug#4132133 which was closed as NOT A BUG.
    However, if you still want to do a truncate instead of delete, you should set atomic_refresh=>FALSE in your DBMS_MVIEW.REFRESH command. This will do a truncate and refresh will complete faster.
    You should be careful about this since there will be a time when the MV will contain no data.
    golflover1 wrote:
    A little more info... If I drop and recreate the materialized view from scratch it take just a few minutes to build.
    This just confirms what I have written above. When you drop and recreate the MV, it doesn't do the DELETE so it completes faster.
    I would say, go ahead and try to refresh the view with atomic_refresh=>FALSE and compare the execution times.
    begin
             dbms_mview.refresh(list=>'your mv name',method=>'C',atomic_refresh=>FALSE);
    end;For more about DBMS_MVIEW.REFRESH check the reference docs on this link</link>.
    Cheers,

  • Memory Leak in Materialized View !!

    Hi,
    I'm facing memory leak problem while
    creating/refreshing materialized view
    with geometry object.
    Platform Win NT 4.0
    Oracle: 8.1.7.0.0
    Details:
    Step 1:
    I'm converting lat/long (Point data) to cartesian using user defined albers projection.
    Step 2:
    Following is the function.
    +++
    create or replace function get_projected_long_lat (Long in Number,Lat in Number)
    Return MDSYS.SDO_GEOMETRY
    DETERMINISTIC
    IS
    LatDec Number;
    LongDec Number;
    Geom MDSYS.SDO_GEOMETRY := mdsys.sdo_geometry(null,null,null,null,null);
    LatLongProj MDSYS.SDO_GEOMETRY;
    Diminfo_array MDSYS.SDO_DIM_ARRAY := MDSYS.SDO_DIM_ARRAY(
    MDSYS.SDO_DIM_ELEMENT('X', -79.5, -88, .00000005),
    MDSYS.SDO_DIM_ELEMENT('Y', 24, 31.5,.00000005));
    Begin
    LongDec := -(substr(long,1,2) + substr(long,3,2) * (1/60) +
    substr(long,5) * (1/60) * (1/60));
    LatDec := (substr(lat,1,2) + substr(lat,3,2) * (1/60) +
    substr(lat,5) * (1/60) * (1/60));
    Geom.sdo_gtype := 2001;
    Geom.sdo_srid := 8307;
    Geom.sdo_point := NULL;
    Geom.sdo_elem_info := mdsys.sdo_elem_info_array(1,1,1);
    Geom.sdo_ordinates := mdsys.sdo_ordinate_array(LongDec,LatDec);
    LatLongProj := SDO_CS.TRANSFORM(Geom, Diminfo_array, 600000);
    Return(LatLongProj);
    End get_projected_long_lat;
    +++
    Step 3:
    Creating materialized view
    ++
    CREATE MATERIALIZED VIEW GPTEST
    BUILD IMMEDIATE
    REFRESH COMPLETE START WITH SYSDATE NEXT SYSDATE + 1
    WITH ROWID
    AS
    (select rownum sdo_gid,
    get_projected_long_lat (a.longitude,a.latitude) geometry
    from br@dblnk a, gr@dblnk b
    ++++
    - Each time i refresh the view memory increase linearly, And I get the following error at some point after memory is full.
    ERROR at line 9:
    ORA-00600: internal error code, arguments: [kghfrf1], [0], [], [], [], [], [],
    ORA-04030: out of process memory when trying to allocate 25100 bytes (pga
    heap,control file cache)
    ORA-04030: out of process memory when trying to allocate 16396 bytes (koh-kghu
    sessi,kgmtgob)
    ORA-04030: out of process memory when trying to allocate 16396 bytes (koh-kghu
    sessi,kolcpcon kolcol)
    ORA-04030: out of process memory when trying to allocate 16396 bytes (koh-kghu
    sessi,kolcalm coll)
    ORA-04030: out of process memory when trying to allocate 16396 bytes (koh-kghu
    sessi,kolcalm coll)
    or
    *** 2001-07-25 15:07:42.087
    ksedmp: internal or fatal error
    ORA-04030: out of process memory when trying to allocate 33292 bytes (cursor work he,kllcqas:kllsltba)
    ORA-04030: out of process memory when trying to allocate 20012 bytes (callheap,KQL tmpbuf)
    ORA-04030: out of process memory when trying to allocate 16396 bytes (koh-kghu sessi,kolcalm coll)
    Can anyone help??
    Thanks
    null

    this may be related to pl/sql memory leak. The bug number is 1371158, and it is fixed in 9i.
    dan

Maybe you are looking for