DBMS_METADATA.GET_DDL and Materialized View

hi gurus,
In 10gR2, i have created a materialized view EMP_MV with a simple structure.
I wanted to get the DDL of EMP_MV.
I used DBMS_METADATA to get the DDL,
select DBMS_METADATA.GET_DDL('MATERIALIZED_VIEW','EMP_MV','TARGET') into v_return from dual;
Output
CREATE MATERIALIZED VIEW "TARGET"."EMP_MV"
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 "TARGET_TS_01"
BUILD IMMEDIATE
USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
TABLESPACE "TARGET_TS_01"
REFRESH FAST ON DEMAND
WITH PRIMARY KEY USING DEFAULT LOCAL ROLLBACK SEGMENT
DISABLE QUERY REWRITE
AS select empid,empname,address from web.emp
Is there any way to get only SELECT part of this MV, ie select empid,empname,address from web.emp directly from dictionary without any string manipulation?
tia,
newbie

Yes you can do it. By using INSTR and SUBTR against the result of GET_DDL function
Try this:
select substr(DBMS_METADATA.GET_DDL('MATERIALIZED_VIEW','EMP_MV','TARGET'),instr(DBMS_METADATA.GET_DDL('MATERIALIZED_VIEW','EMP_MV','TARGET'),'select'),1000)
into v_return from dual;- - - - - - - - - - - - - - - - - - - - -
Kamran Agayev A. (10g OCP)
http://kamranagayev.wordpress.com
[Step by Step install Oracle on Linux and Automate the installation using Shell Script |http://kamranagayev.wordpress.com/2009/05/01/step-by-step-installing-oracle-database-10g-release-2-on-linux-centos-and-automate-the-installation-using-linux-shell-script/]

Similar Messages

  • Table and Materialized View in different namespaces?

    I've just faced something completly new for me. It appears that there are two objects with the same name and owner. Table and Materialized View have the same names and when I look into system dictionary I can se sth. like that:
    OWNER OBJECT_NAME OBJECT_ID DATA_OBJECT_ID OBJECT_TYPE NAMESPACE
    USER_A USER_TABLE 159381 159381 TABLE 1
    USER_A USER_TABLE 159382 MATERIALIZED VIEW 19
    (I couldn't find how to write above with const length font).
    Two object in different namespace? I thought that Tables and Materialized Vievs have the same namespace.
    Can you please tell me how can I create objects to achieve above result? I would also be grateful if you tell me where to find that topic in documentation.

    Perfectly normal.
    SQL> select object_name, object_type from user_objects where object_name = 'TEST_MV';
    no rows selected
    SQL>
    SQL> create materialized view test_mv
      2  as
      3  select sysdate from dual;
    Materialized view created.
    SQL>
    SQL> select object_name, object_type from user_objects where object_name = 'TEST_MV';
    OBJECT_NAME                                        OBJECT_TYPE
    TEST_MV                                            TABLE
    TEST_MV                                            MATERIALIZED VIEW
    SQL>
    SQL> drop materialized view test_mv;
    Materialized view dropped.
    SQL>
    SQL> select object_name, object_type from user_objects where object_name = 'TEST_MV';
    no rows selected
    SQL>

  • Authorization for material type and material views

    Hello all,
    I would need to restrict a user group, in creation (MM01) and modification of material master, based of type material and material views.
    The authorization, for each user should be:
    - view, modify and create of all views, except accounting (B) for type material ZFER;
    - view, modify and create of all views for type material ZOFF.
    I tried to create 2 roles in PFCG with the following authorization objects:
    1) M_MATE_MAR (Material Master: Material Types)  ACTVT = *, BEGRU = ZFER and M_MATE_STA (Maintenance Statuses) ACTVT = *, STATM = A,C, D, E, F, G,K, L, P, Q, S, V, X, Z (excluding B)
    2) ) M_MATE_MAR  ACTVT = *, BEGRU = ZFER and M_MATE_STA ACTVT = *, STATM = B
    but the effect is to be authorized, to all view for material type ZFER and ZOFF.
    I have already updated the authorization group of the type materials (OMS2).
    Is there a solution for this problem?
    (component version SAP ECC 6.0)
    Thanks.
    Regards,
    Luca

    I tried to create 2 roles in PFCG with the following authorization objects: 1) M_MATE_MAR (Material Master: Material Types) ACTVT = *, BEGRU = ZFER and M_MATE_STA (Maintenance Statuses) ACTVT = *, STATM = A,C, D, E, F, G,K, L, P, Q, S, V, X, Z (excluding B) 2) ) M_MATE_MAR ACTVT = *, BEGRU = ZFER and M_MATE_STA ACTVT = *, STATM = B
    - Are both these roles assigned to the same user? then your purpose is not solved, It is more or less like giving full authorization.
    - One role should be
    M_MATE_MAR (Material Master: Material Types) ACTVT = *, BEGRU = ZFER and M_MATE_STA (Maintenance Statuses) ACTVT = *, STATM = A,C, D, E, F, G,K, L, P, Q, S, V, X, Z (excluding B) for view, modify and create of all views, except accounting (B) for type material ZFER. This should be assigned to one user
    - Second role should be
    M_MATE_MAR ACTVT = *, BEGRU = ZOFF and M_MATE_STA ACTVT = *, STATM = * for view, modify and create of all views for type material ZOFF. This role should be assigned to the second user.
    Regards,
    Subbu

  • Oracle equals_path condition NOT working with table and materialized view

    The user i am using is xdb with dba role.
    1.When i try to use the statement
    SELECT PATH FROM xdb.path_VIEW
    WHERE
    EQUALS_PATH(res, '/home/OE/PurchaseOrders/2002')=1
    the result is
    /home/OE/PurchaseOrders/2002
    2. When i drop the path_view and recreated it like materialized view with statement
    create MATERIALIZED view path_view as
    select /*+ ORDERED */ t2.path path, t.res res,
    xmltype.createxml(xdb.xdb_link_type(NULL, r2.xmldata.dispname, t.name,
    h.name, h.flags, h.parent_oid, h.child_oid),
    'http://xmlns.oracle.com/xdb/XDBStandard.xsd', 'LINK') link,
    t.resid
    from ( select xdb.all_path(9999) paths, value(p) res, p.sys_nc_oid$ resid,
    p.xmldata.dispname name
    from xdb.xdb$resource p
    where xdb.under_path(value(p), '/', 9999)=1 ) t,
    TABLE( cast (t.paths as xdb.path_array) ) t2,
    xdb.xdb$h_link h, xdb.xdb$resource r2
    where t2.parent_oid = h.parent_oid and t2.childname = h.name and
    t2.parent_oid = r2.sys_nc_oid$
    then the equals_path condition STOP working !!!
    3. The same experiment, but i recreate it like table
    create table path_view as .... using the rest of the statement ...
    Can someone help me to understand why equals_path is NOT working on table and materialized view !

    Thanks Jonah. I was under the impression that I already had it but seems like it has to be a direct priv - thru a role doesn't work.
    I granted the reqd privs and then it worked fine. Thx for your help!

  • Differences between view and materialized view

    Hello,
    Please tell me the Differences between view and materialized view in oracle 9i.
    Thanks and regards
    Madhuri

    How can I create index in a view?
    Please read reply of Justin Sir.
    Regards
    Girish Sharma

  • What is the difference between view and materialized views

    Hi
    What is the difference between view and materialized view ? can we update the base table using views

    can we update the base table using viewsYes:
    VIEWS
    1. an updatable view is one that lets you perform DML on the underlying table
    (see Oracle Database Concepts 10g - 5 Schema Objects)
    2. non-updatable view requires INSTEAD OF Triggers
    (see Oracle Database Concepts 10g - 22 Triggers)
    SNAPSHOTS
    You can have updateable (and writeable) snapshots - in updateable (writeable) MV replication.
    Oracle uses snapshots (Materialized Views - MV) for two different purposes:
    1. replication
    2. automated Query Rewrite facility (first introduced in Oracle Discoverer, later included in Oracle database 8i).
    Replication types in Oracle are:
    a) Basic replication (MV replication)
    - transaction based
    - row-level
    - asynchronous from master table to MV (Materialized View)
    - DML replication only
    - database 7 / 8.0 / 8i / 9i / 10g
    - Standard and Enterprise Edition
    1. Read-only MV replication
    2. Updateable MV replication:
    2.1 asynchronous from MV to master
    2.2 synchronous from MV to master
    3. Writeable MV replication
    b) Multimaster replication
    - transaction based
    - row-level or procedural
    - asynchronous or synchronous
    - DML and DDL replication
    - database 7 / 8.0 / 8i / 9i / 10g
    - Enterprise Edition only
    1. row-level asynchronous replication
    2. row-level synchronous replication
    3. procedural asynchronous replication
    4. procedural synchronous replication
    c) Streams replication
    - (redo) log based
    - row-level
    - asynchronous
    - DML and DDL replication
    - database 9i / 10g (10g has Down Streams Capture)
    - Enterprise Edition only (Standard Edition 10g can execute Apply process)
    Regards,
    Zlatko Sirotic

  • Dbms_metadata.get_ddl and select_catalog_role

    Hi,
    We have been requested to give support staff the ability to see table triggers, stored procedures, etc only for specific schemas and they don't have access to the schema password. We can't give them SELECT_CATALOG_ROLE because they are not allowed to see all schemas. I wish there were a way to grant a version of SELECT_CATALOG_ROLE for only certain schemas......
    I've played around with dbms_metadata.get_ddl with no luck (as per the documentation, but just had to try it anyway). I've even considered the script below, but it requires creating a view under the SYS schema and I can't figure out how to add triggers to the view.
    Any ideas would be greatly appreciated!
    Thanks,
    Susan
    accept 1 prompt "Enter Owner:"
    create or replace view all_dev_source
    (OWNER, NAME, TYPE, LINE, TEXT)
    as
    select u.name, o.name,
    decode(o.type#, 7, 'PROCEDURE', 8, 'FUNCTION', 9, 'PACKAGE',
    11, 'PACKAGE BODY', 13, 'TYPE', 14, 'TYPE BODY',
    'UNDEFINED'),
    s.line, s.source
    from sys.obj$ o, sys.source$ s, sys.user$ u
    where
    u.name = upper('&&1') and
    o.obj# = s.obj#
    and o.owner# = u.user#
    and o.type# in (7, 8, 9, 11, 13, 14)
    and
    o.owner# in (userenv('SCHEMAID'), 1 /* PUBLIC */)
    or
    (o.type# = 7 or o.type# = 8 or o.type# = 9)
    and
    o.obj# in (select obj# from sys.objauth$
    where grantee# in (select kzsrorol from x$kzsro)
    and privilege# = 12 /* EXECUTE */)
    or
    exists
    select null from sys.sysauth$
    where grantee# in (select kzsrorol from x$kzsro)
    and
    /* procedure */
    (o.type# = 7 or o.type# = 8 or o.type# = 9)
    or
    privilege# = -144 /* EXECUTE ANY PROCEDURE */
    or
    privilege# = -141 /* CREATE ANY PROCEDURE */
         or
    /* package body */
    o.type# = 11 or
    privilege# = -141 /* CREATE ANY PROCEDURE */
    or
    /* type */
    o.type# = 13
    or
    privilege# = -184 /* EXECUTE ANY TYPE */
    or
    privilege# = -181 /* CREATE ANY TYPE */
         or
    /* type body */
    o.type# = 14 and
    privilege# = -181 /* CREATE ANY TYPE */
    union
    select u.name, o.name, 'JAVA SOURCE', s.joxftlno, s.joxftsrc
    from sys.obj$ o, x$joxfs s, sys.user$ u
    where
    u.name = upper('&&1') and
    o.obj# = s.joxftobn
    and o.owner# = u.user#
    and o.type# = 28
    and
    o.owner# in (userenv('SCHEMAID'), 1 /* PUBLIC */)
    or
    o.obj# in (select obj# from sys.objauth$
    where grantee# in (select kzsrorol from x$kzsro)
    and privilege# = 12 /* EXECUTE */)
    or
    exists
    select null from sys.sysauth$
    where grantee# in (select kzsrorol from x$kzsro)
    and
    /* procedure */
    privilege# = -144 /* EXECUTE ANY PROCEDURE */
    or
    privilege# = -141 /* CREATE ANY PROCEDURE */
    comment on table all_dev_source is
    'Current source on stored objects that user is allowed to create'
    comment on column all_dev_source.OWNER is
    'Owner of the object'
    comment on column all_dev_source.NAME is
    'Name of the object'
    comment on column all_dev_source.TYPE is
    'Type of the object: "TYPE", "TYPE BODY", "PROCEDURE", "FUNCTION",
    "PACKAGE", "PACKAGE BODY" or "JAVA SOURCE"'
    comment on column all_dev_source.LINE is
    'Line number of this line of source'
    comment on column all_dev_source.TEXT is
    'Source text'
    grant select on all_dev_source to <username>
    /

    user632322 wrote:
    I think I am misunderstanding your reply becauseI had to be more specific. By "privileged user" I meant SYS. SELECT_CATALOG_ROLE is a role itself, so it will be ignored by definer rights SP/SF. That is why it has to be owned by privileged user SYS:
    SQL> select * from v$version
      2  /
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Prod
    PL/SQL Release 10.2.0.4.0 - Production
    CORE    10.2.0.4.0      Production
    TNS for 32-bit Windows: Version 10.2.0.4.0 - Production
    NLSRTL Version 10.2.0.4.0 - Production
    SQL> show user
    USER is "SYS"
    SQL> create user u1 identified by u1 default tablespace users quota unlimited on users
      2  /
    User created.
    SQL> grant create session to u1
      2  /
    Grant succeeded.
    SQL> create or replace
      2    function get_ddl(
      3                     p_type varchar2,
      4                     p_object varchar2,
      5                     p_owner varchar2
      6                    )
      7      return clob
      8      is
      9      begin
    10          return dbms_metadata.get_ddl(p_type,p_object,p_owner);
    11  end;
    12  /
    Function created.
    SQL> grant execute on get_ddl to u1
      2  /
    Grant succeeded.
    SQL> connect u1/u1
    Connected.
    SQL> set serveroutput on
    SQL> exec dbms_output.put_line(dbms_metadata.get_ddl('TABLE','EMP','SCOTT'));
    BEGIN dbms_output.put_line(dbms_metadata.get_ddl('TABLE','EMP','SCOTT')); END;
    ERROR at line 1:
    ORA-31603: object "EMP" of type TABLE not found in schema "SCOTT"
    ORA-06512: at "SYS.DBMS_SYS_ERROR", line 105
    ORA-06512: at "SYS.DBMS_METADATA", line 2806
    ORA-06512: at "SYS.DBMS_METADATA", line 4333
    ORA-06512: at line 1
    SQL> exec dbms_output.put_line(sys.get_ddl('TABLE','EMP','SCOTT'));
      CREATE TABLE "SCOTT"."EMP"
       (    "EMPNO" NUMBER(4,0),
            "ENAME" VARCHAR2(10),
            "JOB" VARCHAR2(9),
            "MGR" NUMBER(4,0),
            "HIREDATE" DATE,
            "SAL"
    NUMBER(7,2),
            "COMM" NUMBER(7,2),
            "DEPTNO" NUMBER(2,0),
             CONSTRAINT
    "PK_EMP" PRIMARY KEY ("EMPNO")
      USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255
    COMPUTE STATISTICS
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS
    2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
    TABLESPACE "USERS"  ENABLE,
             CONSTRAINT "FK_DEPTNO" FOREIGN KEY ("DEPTNO")
    REFERENCES "SCOTT"."DEPT" ("DEPTNO") ENABLE
       ) 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 "USERS"
    PL/SQL procedure successfully completed.
    SQL> Now one more correction to my previous reply. Driver table shoudl not be owned by SYS (that would be bad practice). Create it in some other schema. Just make sure your "support staff" has no access to it.
    SY.

  • Creation of Materialized view and Materialized view log.

    I wanted to create materialized view with 'REFRESH FAST ON COMMIT' option.
    1) Table1 --it is partitioned range + list -- Added primary key
    2) view1   -- having primary keys on view's base table
    Steps:
    1) create materialized view log on Table1 ; -- default primary key
    2) create materialized view log on view1.  --- It is giving below error.
    ORA-00942: table or view does not exist
    i wanted to create Materialized view like below
    create materialized view
    REFRESH fast ON commit
    as
    select ...
    ... from table1
    where c1 in (select c1 from view1 where ... );
    Question:
    1) As i am getting above error while creating MV log on view. Can we create MV log on view or we have to create MV log on view base table?
    2) To create MV with ''REFRESH FAST ON COMMIT' option , do we need to have primary key on master tables? 
    Any pointers on this will really helpful.
    Thanks
    Prasad

    Also created MV LOG on 3 tables and tried with joins ..
    create materialized view
    REFRESH fast ON commit
    as
    select ...
    ... from table1 , tab2 t2,tab3 t3
    where ....
    and ...
    Get same error ORA-12052: cannot fast refresh materialized view AVSYS.EVENT_LOG_MV
    2052. 00000 -  "cannot fast refresh materialized view %s.%s"
    *Cause:    Either ROWIDs of certain tables were missing in the definition or
               the inner table of an outer join did not have UNIQUE constraints on
               join columns.
    *Action:   Specify the FORCE or COMPLETE option. If this error is got
               during creation, the materialized view definition may have be
               changed. Refer to the documentation on materialized views.

  • Dbms_metadata.get_ddl and lob columns

    Good day, all,
    I get the disappointing results, below, when trying to use the 9i dbms_metadata browsing package against a table with a BLOB (or CLOB) column. In other cases, it works fine; so I believe that it is not a "setup" or security problem.
    Do you know any magic to get this to work?
    Thanks!
    Don M.
    SQL> create table x (c1 blob);
    Table created.
    SQL> select dbms_metadata.get_ddl ('TABLE','X','DMAIER') from dual;
    ERROR:
    ORA-19206: Invalid value for query or REF CURSOR parameter
    ORA-06512: at "SYS.DBMS_XMLGEN", line 83
    ORA-06512: at "SYS.DBMS_METADATA", line 345
    ORA-06512: at "SYS.DBMS_METADATA", line 410
    ORA-06512: at "SYS.DBMS_METADATA", line 449
    ORA-06512: at "SYS.DBMS_METADATA", line 615
    ORA-06512: at "SYS.DBMS_METADATA", line 1221
    ORA-06512: at line 1

    I have gone through some errors with invalid XDB objects when wanted to run dbms_metadata.get_ddl too. That was on 10gR2 (10.2.0.1 - though other instance was installed in "same" manner and everything worked ok). I had to drop and recreate XDK objects again - following some metalink note - I have posted the exact steps on metalink, I think I ran following commands from $ORACLE_HOME/RDBMS/ADMIN
    catnomta.sql
    catnodp.sql
    rmxml.sql
    catxml.sql
    utlcxml.sql
    prvtcxml.plb
    catnomta.sql
    dbmsmeta.sql
    dbmsmeti.sql
    dbmsmetu.sql
    catemeta.sql
    prvtmeta.plb
    prvtmeti.plb
    prvtmetu.plb
    initmeta.sql
    catdph.sql
    catdpb.sql
    initmeta.sql

  • Truncate table and materialized view log

    I user oracle 10 R2
    I have a table and on that table a materialized view log.
    I execute in a pl/sql procedure:
    1) execute immediate('drop materialized view log on tab1');
    then:
    2) execute immediate('truncate table tab1');
    3) Now I insert a lot of records in tab1
    4) execute immediate('create materialized view log on tab1 WITH rowid INCLUDING NEW VALUES');
    When I create the materialized view log I recieved this message:
    ora32321: refresh fast on tab2 unsupported after detail table truncate
    Why?

    Refresh fast after truncate operation on container table is not supported, regardless the container table is or is not partitioned.
    Perform a refresh complete.
    ORA-32321 :
    Cause:     A detail table has been truncated and no materialized view
         supports fast refersh after a detail table has been truncated
    Action:     Use REFRESH COMPLETE. Note: you can determine why your
         materialized view does not support fast refresh after TRUNCATE
         using the DBMS_MVIEW.EXPLAIN_MV() API.

  • Help with query rewrite and materialized views

    Hello everybody,
    I'm currently learning how to use Oracle (10G Enterprise) and in particular, Materialized Views.
    I seem to have a problem making the optimizer use a materialized view. I have already set the OPTIMIZER_MODE, QUERY_REWRITE_ENABLED and QUERY_REWRITE_INTEGRITY as needed.
    I need to create a materialized view for the following query:
    Q1:
    SELECT PS_SUPPKEY, PS_PARTKEY, PS_SUPPCOST
    FROM PARTSUPPLIER E, PART WHERE PS_PARTKEY=P_PARTKEY and (lower(P_COMMENT) LIKE ''_o_a\%'' or lower(P_COMMENT) LIKE ''_o_u\%'')
    and PS_SUPPCOST =
    (SELECT min( PS_SUPPCOST)
    FROM PARTSUPPLIER I
    WHERE E.PS_PARTKEY=I.PS_PARTKEY)'
    I created it using the following code:
    CREATE MATERIALIZED VIEW mv_q1
    ENABLE QUERY REWRITE
    AS SELECT PS_SUPPKEY, PS_PARTKEY, PS_SUPPCOST
    FROM PARTSUPPLIER E JOIN PART ON (PS_PARTKEY=P_PARTKEY)
    WHERE lower(P_COMMENT) LIKE '_o_a%' or lower(P_COMMENT) LIKE '_o_u%'
    and PS_SUPPCOST=
    (SELECT min( PS_SUPPCOST)
    FROM PARTSUPPLIER I
    WHERE E.PS_PARTKEY=I.PS_PARTKEY);
    I have created the statistics using:
    execute dbms_stats.gather_table_stats('frandres',' mv_q1');
    execute dbms_stats.gather_table_stats('frandres','PARTSUPPLIER');
    execute dbms_stats.gather_table_stats('frandres','PART');
    Both partsupplier and part are tables and not views.
    When executing Q1, the plan does not use the materialized view. Furthermore, when using explain rewrite:
    DECLARE
    qrytxt VARCHAR2(3000) := 'SELECT PS_SUPPKEY, PS_PARTKEY, PS_SUPPCOST
    FROM PARTSUPPLIER E, PART WHERE PS_PARTKEY=P_PARTKEY and (lower(P_COMMENT) LIKE ''_o_a\%'' or lower(P_COMMENT) LIKE ''_o_u\%'')
    and PS_SUPPCOST =
    (SELECT min( PS_SUPPCOST)
    FROM PARTSUPPLIER I
    WHERE E.PS_PARTKEY=I.PS_PARTKEY)';
    BEGIN
    dbms_mview.EXPLAIN_REWRITE
    (qrytxt,'MV_Q1','MV_Q1');
    END;
    I get the following message:
    MESSAGE
    QSM-01150: query did not rewrite
    QSM-01263: query rewrite not possible when query references a dictionary table o
    r view
    QSM-01219: no suitable materialized view found to rewrite this query
    What I can't understand is why it says I am referencing the dictionary or a view?
    If I remove the (lower(P_COMMENT) LIKE ''_o_a\%'' or lower(P_COMMENT) LIKE ''_o_u\%'') condition to the query (using the same materialized view), I get the following message from EXPLAIN_REWRITE:
    MESSAGE
    QSM-01150: query did not rewrite
    QSM-01219: no suitable materialized view found to rewrite this query
    Which is reasonable.
    I don't know if the like condition is messing up my materialized view. Can anyone please help?
    Thanks a lot in advance.
    Edited by: user12072111 on Oct 29, 2009 9:43 PM

    Bingo!
    The 10.2.0.3 patch set is supposed to fix this ( [List of bugs fixed (MVs)|http://www.dbatools.net/doc/bug10203.html#MVIEW] )
    In particular:
    5052568      Query rewrite does not work for SQL with LIKE clause.
    Thank you very much for your message!
    The downside is that I'm only using Oracle for educational purposes and consequently have no Metalink id, so I can't install the patch. Thanks a lot though!

  • MATERIALIZED VIEW and MATERIALIZED VIEW LOG

    Hello,
    I have the following table
    create table My_price
    (price_id number(10),
    product_id number(10),
    price_date date,
    price_value number(10,2));
    I want to create the following materialized view
    create materialized view Last_Price_Date
    refresh
    on commit complete
    as
    select max(price_date) as max_date, product_id from my_price group by product_id;
    Do I have to create materialized view log ? Will my materialized view be refresh on commit without materialized view log ?

    As a student the requisite first task is always to study. Thus your assignment is to go to http://tahiti.oracle.com and read the concept and architecture docs on Materialized Views so that you can learn about the different types of MVs and how and when they are refreshed. There you will learn about what ON COMMIT means.
    Then please turn your "I want to create" into an "I created it." Then, having read the docs, you will be able to observe how your MV behaves.
    PS: Your SELECT statement is not syntactically correct. Start by fixing it so that it works in SQL*Plus.

  • Instr command in APEX and materialized view

    This worked fine up until we changed it to use a materialized layer. P6080_DEPARTMENT, P6080_TITLE and P6080_ROLE are all Multi-Select lists. ACMV is the materialized view. I have been trying multiple things but nothing works.
    ( instr(':'||:P6080_DEPARTMENT||':',':'||ACMV.DEPARTMENT||':') > 0 or
    :P6080_DEPARTMENT is NULL or :P6080_DEPARTMENT = 'ALL') and
    ( instr(':'||:P6080_TITLE||':',':'||ACMV.TITLE||':') > 0 or
    :P6080_TITLE is NULL or :P6080_TITLE = 'ALL') and
    ( instr(':'||:P6080_ROLE||':',':'||ACMV.ROLE||':') > 0 or
    :P6080_ROLE is NULL or :P6080_ROLE = 'ALL')
    I can run this in a sql window and get the results using the following for Department
    when if use the values from the debugging output.
    select business_name from account_contacts_mv acmv
    where instr(':ADMINISTRATION:COMPLIANCE:ENGINEERING:EXECUTIVE:FINANCE:HR:IT:LEGAL:',':'||ACMV.department||':')>0
    This is a little frustrating and any help will be appreciated.
    KDP

    KDP,
    what is your actual problem. Do you get an error or do you suffer performance problems?
    Patrick
    My APEX Blog: http://inside-apex.blogspot.com
    The ApexLib Framework: http://apexlib.sourceforge.net
    The APEX Builder Plugin: http://sourceforge.net/projects/apexplugin/

  • PL/SQL Proc, execute immediate and materialized view 9.2.0.6

    Hello,
    Environement description: Sun Solaris 8 , Oracle database 9.2.0.6
    I've a problem trying to execute this PL/SQL Procedure:
    I'm loged in with PMU user
    CREATE OR REPLACE PROCEDURE PMU.PROC_TEST_PMU_C035 (part_arrete in integer, part_session in integer) AS
    lv_p_arrete number     := part_arrete;
    lv_p_session number     := part_session;
    lv_stmt     varchar2(31000);
    BEGIN
    lv_stmt := ' ';
    lv_stmt := lv_stmt || 'CREATE MATERIALIZED VIEW 'PMU''.''TEST_PMU_C035'' ';
    lv_stmt := lv_stmt || 'TABLESPACE PMU_8M_DATA ';
    lv_stmt := lv_stmt || 'BUILD IMMEDIATE ';
    lv_stmt := lv_stmt || 'REFRESH COMPLETE AS ';
    lv_stmt := lv_stmt || 'SELECT * FROM ACTION ';
    lv_stmt := lv_stmt || 'WHERE LIBELLE IN ( ''SOCIETE 1'', ''SOCIETE 2'', ''SOCIETE 3'' ) ;';
    dbms_output.put_line ( lv_stmt) ;
    execute immediate ( lv_stmt);
    END;
    When I comment the line : execute immediate ( lv_stmt); It works fine and my statement appear on the screen:
    CREATE MATERIALIZED VIEW PMU.TEST_PMU_C035 TABLESPACE PMU_8M_DATA BUILD
    IMMEDIATE REFRESH COMPLETE AS SELECT LIBELLE FROM ACTION WHERE LIBELLE IN (
    'SOCIETE1', 'SOCIETE2', 'SOCIETE3' ) ;
    When I execute manually this query it works.
    But when I try to do the execute immediate, it gives me this error:
    BEGIN "PMU"."PROC_TEST_PMU_C035" ( 13, 14); END;
    ERROR at line 1:
    ORA-00911: invalid character
    ORA-06512: at "PMU.PROC_TEST_PMU_C035", line 15
    ORA-06512: at line 1
    Action Table has this description and datas:
    SQL> desc action
    Name Null? Type
    ISIN NOT NULL VARCHAR2(20)
    LIBELLE VARCHAR2(100)
    SQL>
    ISIN LIBELLE
    FR1 SOCIETE 1
    FR2 SOCIETE 2
    FR3 SOCIETE 3
    FR4 SOCIETE 4
    FR5 SOCIETE 5
    FR6 SOCIETE 6
    FR7 SOCIETE 7
    FR8 SOCIETE 8
    FR9 SOCIETE 9
    FR10 SOCIETE 10
    FR11 SOCIETE 11
    This is a sample description of my probleme because the real case is on multiple partition tables with million rows, but the problem is the same with this sample.
    My question is why it doesn't work ? Could anybody help me ?
    Thanks In advance.
    Loic

    Yes but you did not show where you want the parametersOK this is my Original Query :
    CREATE OR REPLACE PROCEDURE "PMU"."PROC_TEST_PMU_C035" (part_arrete in integer, part_session in integer)AS
    lv_p_arrete integer := part_arrete;
    lv_p_session integer := part_session;
    lv_stmt varchar2(31000);
    BEGIN
    lv_stmt := 'CREATE OR REPLACE MATERIALIZED VIEW PMU.TEST_PMU_C035 ';
    lv_stmt := lv_stmt || ' TABLESPACE PMU_8M_DATA ';
    lv_stmt := lv_stmt || ' BUILD IMMEDIATE ';
    lv_stmt := lv_stmt || ' REFRESH COMPLETE AS ';
    lv_stmt := lv_stmt || ' select CD_SOCIETE, MONTANT, MOIS, TYPEDET, LIEUCONS, DETPEA, PERSPHYS, SECTDET, PAYSDET, ZONEDET, CSPDET, AGEDET, TRMONT, NATINSFI, MATURITE, MONNAIE, DEVISEISO, SECTEMT, PAYSEMT, ZONEEMT, ENCRSDEB, NBCPTIT, TYPEFLUX, CONTRAT, CODISIN, LIBELTIT, SEUILDET, PAYSCTP, NBTIT, SEUILA1, SEUILA2, SEUILM1, SEUILM2, SEUILB1, SEUILB2, SEUILQ1, SEUILQ2, TXEVOL, NBCPTITPEA, NBCPTITPPP, ';
    lv_stmt := lv_stmt || ' NO_PCI || ''-'' || SECTDET || ''-'' || ZONEDET || ''-'' || MONNAIE || ''-'' || SECTEMT || ''-'' || DETPEA || ''-'' || PERSPHYS || ''-'' || (CASE WHEN TYPEDET IN (''DCL'', ''DCG'') THEN ''DCL'' ';
    lv_stmt := lv_stmt || ' ELSE NVL(TYPEDET,'''') ';
    lv_stmt := lv_stmt || ' END ) || ''-'' || (CASE WHEN NATINSFI in (''OBL'', ''EMT'', ''BTR'', ''CDD'', ''CDE'', ''CPP'', ''BTS'', ''MIB'') THEN ''OBL'' ';
    lv_stmt := lv_stmt || ' ELSE NVL(NATINSFI,'''') ';
    lv_stmt := lv_stmt || ' END) || ''-'' ||(CASE WHEN MATURITE IN (''A0'', ''A1'') THEN ''AC'' ELSE NVL(MATURITE,'''') END) || ''-'' ||(CASE WHEN PAYSEMT IN (''FR'',''MC'') THEN ''F1'' ';
    lv_stmt := lv_stmt || ' WHEN PAYSEMT IN (''DE'',''AT'',''BE'',''ES'',''FI'',''GR'',''IE'',''IT'',''LU'',''NL'',''PT'',''SI'', ''4F'') THEN ''ZE'' ';
    lv_stmt := lv_stmt || ' WHEN PAYSEMT IN (''BG'',''CY'',''DK'',''EE'',''HU'',''LV'',''LT'',''MT'',''PL'',''RO'',''GB'',''SK'',''SE'',''CZ'', ''4C'', ''4D'', ''4H'', ''4E'', ''4Z'', ''JE'') THEN ''ZU'' ';
    lv_stmt := lv_stmt || ' ELSE ''ZR''';
    lv_stmt := lv_stmt || ' END ) AS CLE';
    lv_stmt := lv_stmt || ' from PMU_ESLD_ESTD partition(PMU_M13_S14) e ,';
    lv_stmt := lv_stmt || ' PMU_ESLD_ESTD_SPPRO partition(PMU_M13_S14) a';
    lv_stmt := lv_stmt || ' where e.PART_ARRETE = '||lv_p_arrete ;
    lv_stmt := lv_stmt || ' AND e.PART_ENV = ''BCE''' ;
    lv_stmt := lv_stmt || ' AND e.PART_SESSION = '||lv_p_session ;
    lv_stmt := lv_stmt || ' and e.ID = a.ID_ESTD ';
    lv_stmt := lv_stmt || ' and e.CD_STATUT = ''VE'' ' ;
    lv_stmt := lv_stmt || ' and e.TYP_MONTANT = ''33'' ; ' ;
    execute immediate lv_stmt;
    END;
    Thanks

  • Problem with DBMS_METADATA.GET_DDL and subpartitions

    I have problems with DBMS_METADATA.GET_DDL in a 11gR2 (11.2.0.3) database on Linux. The following example shows the problem:
    CREATE TABLE Test_tbl
    C1 NUMBER(14),
    C2 NUMBER(14),
    C3 NUMBER(14)
    PARTITION BY RANGE (C1)
    SUBPARTITION BY LIST (C2)
    PARTITION Part1 VALUES LESS THAN (1000)
    , PARTITION Part2 VALUES LESS THAN (2000)
    CREATE INDEX Test_idx ON Test_tbl (C3) LOCAL;
    When I execute
    SELECT DBMS_METADATA.GET_DDL('INDEX','TEST_IDX') from dual;
    on a 10g database (10.2.0.2.0) on Solaris Sparc and on a 11.1.0.7 on Windows, it gives the correct DDL statement within some seconds.
    On the 11.2.0.3 database (Linux) it hangs forever.
    SQL> SELECT DBMS_METADATA.GET_DDL('INDEX','TEST_IDX') from dual;
    ^CERROR:
    ORA-01013: user requested cancel of current operation
    This behavior only seems to occur in combination with local indexes and subpartitions.
    Anyone any idea?
    Thx, Carsten

    user592634 wrote:
    I have problems with DBMS_METADATA.GET_DDL in a 11gR2 (11.2.0.3) database on Linux. The following example shows the problem:
    CREATE TABLE Test_tbl
    C1 NUMBER(14),
    C2 NUMBER(14),
    C3 NUMBER(14)
    PARTITION BY RANGE (C1)
    SUBPARTITION BY LIST (C2)
    PARTITION Part1 VALUES LESS THAN (1000)
    , PARTITION Part2 VALUES LESS THAN (2000)
    CREATE INDEX Test_idx ON Test_tbl (C3) LOCAL;
    When I execute
    SELECT DBMS_METADATA.GET_DDL('INDEX','TEST_IDX') from dual;
    on a 10g database (10.2.0.2.0) on Solaris Sparc and on a 11.1.0.7 on Windows, it gives the correct DDL statement within some seconds.
    On the 11.2.0.3 database (Linux) it hangs forever.
    SQL> SELECT DBMS_METADATA.GET_DDL('INDEX','TEST_IDX') from dual;
    ^CERROR:
    ORA-01013: user requested cancel of current operationWhy did you cencel this operation? Usually it takes time. If its taking more then it would be better to gather dictionary stats once.
    SQL>exec DBMS_STATS.GATHER_DICTIONARY_STATS;
    >
    This behavior only seems to occur in combination with local indexes and subpartitions.
    Anyone any idea?
    Thx, CarstenI didn't get any problem in 11.2.0.1 database:
    SQL> CREATE TABLE Test_tbl
      2  (
      3  C1 NUMBER(14),
      4  C2 NUMBER(14),
      5  C3 NUMBER(14)
      6  )
      7  PARTITION BY RANGE (C1)
      8  SUBPARTITION BY LIST (C2)
      9  (
    10  PARTITION Part1 VALUES LESS THAN (1000)
    11  , PARTITION Part2 VALUES LESS THAN (2000)
    12  );
    Table created.
    SQL>
    SQL> CREATE INDEX Test_idx ON Test_tbl (C3) LOCAL;
    Index created.
    SQL>
    SQL> SELECT DBMS_METADATA.GET_DDL('INDEX','TEST_IDX') from dual;
    DBMS_METADATA.GET_DDL('INDEX','TEST_IDX')
      CREATE INDEX "SYS"."TEST_IDX" ON "SYS"."TEST_TBL" ("C3")
      PCTFREE 10 INITRAEdited by: 909592 on Mar 22, 2012 9:01 PM

Maybe you are looking for

  • TS2363 Why do I get a runtime error R6034 message when installing iTunes 11.1.4.62 on my WIn XP (SP3) system?

    iTunes prompted me to download and install the newest version of iTunes (11.1.4.62). I followed all on-screen prompts. iTunes installation gets to the very end, then I get a popup stating that I have a Runtime Error # R6034 "an application has made a

  • Restricting drop down list of sold to party when creating Sample Order

    Hi, I have a requirement to restrict the view of "sold 2 parties" when users are creating sample orders/ SPA contracts. Has anyone implemented such a scenario using ACE? Just wondering if this is the right approach to take as I need to understand per

  • No Systems in "Search in" 7.1SP3

    Hi I tried to import a data service as described in the documentation. However, in the Search (button in task-panel toolbar) in the "Search in" drop-down list is see no systems or WS-Destinations but the following entries: "Business Objects, Portal C

  • Load modules using moduleLoader url property?

    My requirement is to load a module using URL like following '/somthing.swf?a=b&b=c' so that it can load the module and set a few values after it is loaded. But when i create an instance of the moduleLoader and set the Url property nothing is happenin

  • CS4 Serial Problems

    I keep getting the "License expired" message after following the steps the previously posted articles.  What can I do to get things working?