Can we create a Materialized View with Parameters?

Experts,
Can we create a materialized view by passing parameters to it. so that we change its value dynamically.
If yes, plese provide me the eample also.
Regards
ND

I have below mentioned query to be used in MV :
SELECT ivr_vw.event_type, ivr_vw.event_sub_type,
ivr_vw.channel_cd,
ivr_vw.csg_event_id,
ivr_vw.csg_title,
ivr_vw.itv_title,
ivr_vw.program_id,
ivr_vw.price,
ivr_vw.addt_flag,
(SELECT FROM_TZ(TO_TIMESTAMP (TO_CHAR (to_date(ivr_vw.start_date,'MM/DD/YYYY HH24:MI:SS'), 'MM/DD/YYYY HH24:MI:SS'),
'MM/DD/YYYY HH24:MI:SS' ), 'EST')
AT TIME ZONE 'MST' FROM DUAL) start_date,
(SELECT FROM_TZ(TO_TIMESTAMP (TO_CHAR (to_date(ivr_vw.end_date,'MM/DD/YYYY HH24:MI:SS'), 'MM/DD/YYYY HH24:MI:SS'),
'MM/DD/YYYY HH24:MI:SS' ), 'EST')
AT TIME ZONE 'MST' FROM DUAL) end_date,
(SELECT FROM_TZ(TO_TIMESTAMP (TO_CHAR (to_date(ivr_vw.start_order_window,'MM/DD/YYYY HH24:MI:SS'), 'MM/DD/YYYY HH24:MI:SS'),
'MM/DD/YYYY HH24:MI:SS' ), 'EST')
AT TIME ZONE 'MST' FROM DUAL) start_order_window,
(SELECT FROM_TZ(TO_TIMESTAMP (TO_CHAR (to_date(ivr_vw.end_order_window,'MM/DD/YYYY HH24:MI:SS'), 'MM/DD/YYYY HH24:MI:SS'),
'MM/DD/YYYY HH24:MI:SS' ), 'EST')
AT TIME ZONE 'MST' FROM DUAL) end_order_window,
ivr_vw.dnis_cd, ivr_vw.packaged_event_id, ivr_vw.no_instalments,
ivr_vw.disclaimer_flag, ivr_vw.english_voice_file_name,
ivr_vw.spanish_voice_file_name, ivr_vw.package_flag,
ivr_vw.is_all_day_event, ivr_vw.upsell_data, ivr_vw.dur_guaran_flag,
ivr_vw.cp_profile_id, ivr_vw.high_def_flag
FROM ppv_ivr_vw ivr_vw,
(Select time_diff,
use_daylight
From ppv_zip_timezones ztz
Where ztz.zip_code = 80014
) timeOffset
WHERE NOT EXISTS (
SELECT 'x'
FROM ppv_channels_blackout_vw blk_vw
WHERE ivr_vw.channel_cd = blk_vw.channel_cd
AND blk_vw.zone_type_code = 'Area Code'
AND blk_vw.zone_code = '435');
Here, the column 'ztz.zip_code = 80014' should change dynamically as per the request of the user.
Is it possible. If yes, what is the process of doing so.?
Regards
ND

Similar Messages

  • 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

  • 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

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

  • Create a fast refresh materialized view with partitioned primary index

    Hi,
    I have a materialized view that is based on a table with primary key.
    I want to create a materialized view with a partitioned primary index . do you have any way of doing it?
    I tried to create a materialized view with rowid and then I created a partitioned primary index on it.
    It did not work as what I expected. I could not perform a fast refresh on it. the materialized view can only complete refresh
    thank you

    Hi,
    Here is some info from the Oracle Documentation.
    http://download.oracle.com/docs/cd/E11882_01/server.112/e10706/repmview.htm
    http://download.oracle.com/docs/cd/E11882_01/server.112/e10810/basicmv.htm
    Determining the Fast Refresh Capabilities of a Materialized View
    http://download.oracle.com/docs/cd/E11882_01/server.112/e10706/repmview.htm#BABEDIAH
    Regards,

  • Materialized view with tables in different schemas

    Hello,
    I want to create a materialized view with a table from a different schema in the SELECT statement. For materialized view I would like to apply the "REFRESH COMPLETE ON COMMIT" option.
    Here the code:
    CREATE MATERIALIZED VIEW S1.MV_EXAMPLE
    TABLESPACE TS1
    PCTFREE 0
    BUILD IMMEDIATE
    REFRESH COMPLETE ON COMMIT
    AS
    SELECT T.COLUMN1 COLUMN
    FROM S2.TABLE1 T
    I can't execute this SQL because I get an "insufficient privileges" error to this table:
    FROM S2.TABLE1 T
    FEHLER in Zeile 9:
    ORA-01031: Insufficient privileges
    User S1 has the following privileges:
    CREATE SESSION
    CREATE SNAPSHOT
    CREATE TABLE
    CREATE QUERY REWRITE
    SELECT ANY TABLE
    User S2 has the following privileges:
    CREATE SESSION
    CREATE SNAPSHOT
    CREATE TABLE
    CREATE QUERY REWRITE
    ALTER ANY SNAPSHOT
    Which privileges are missing?
    Thanks, Mathias

    Thanks Kamal for your answer!
    S1 has the grant select directly. But I solveld the problem. The system privilege "ON COMMIT REFRESH" was missing for S1. This has to be set if any of the tables are outside the owner's schema of the materialized view (ORACLE documentation - Data Warehouse Guide).
    But one thing is not clear to me yet and the ORACLE documentation doesn't give me an answer. I can set the refresh-attribute ON COMMIT on a materialized view containing only joins when a group by clause is set. If the group by clause is missing I can't! Why?
    Regards, Mathias

  • Materialized View with Sequence

    Please help!!
    I was wondering if anyone knows how to create a MATERIALIZED VIEW with a generating sequence number (sequence.nextval)???
    This is sort of what I want but it doesn't work:
    create materialized view ORACLE_AUDIT_LOG_MVW
    refresh force start with sysdate
    next sysdate + 1
    with primary key
    as select oracle_seq.nextval,
         'Auditing Information' title,
         ses.tnsname,
         o.obj_owner,
         o.obj_name,
         o.action_name,
         ses.os_username,
         ses.username,
         ses.machine as machine,
         ses.program,
         ses.module,
         ses.client_ip,
         ses.connection_msg,
         to_char(ses.logon_time,'DD-MON-YY HH:MM:SS'),
         to_char(ses.logoff_time,'DD-MON-YY HH:MM:SS')
    from audit_sessions ses, audit_objects o
    where ses.tnsname = o.tnsname
    and ses.sessionid = o.sessionid
    GROUP BY ses.tnsname, O.SESSIONID, o.obj_owner, o.obj_name, o.action_name, ses.os_username, ses.username, ses.machine, ses.program, ses.module, ses.client_ip, ses.connection_msg, ses.logon_time, ses.logoff_time
    UNION all
    select oracle_seq.nextval,
         'Failed Logons' title,
         fl.tnsname,
         fl.os_username,
         fl.username,
         fl.terminal as terminal,
         fl.connection_msg,
         to_char(fl.logon_time,'DD-MON-YY HH:MM:SS'),
    from audit_failed_logons fl
    Can someone PPPLLLLEEEAAAASSSEE help me???
    Thanks so much,
    Mary Lee

    First, "doesn't work" isn't particularly descriptive. Error numbers and error messages would be very helpful.
    Second, does it have to be a sequence value? Could you not use either ROWNUM or one of the analytic functions (RANK, DENSE_RANK, ROW_NUMBER, etc)?
    Third, you'll almost certainly need this MV to be completely refreshed every time...
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • Materialized view with join

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

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

  • Materialized view with date dependencies.

    can I create a materialized view that will depend on sysdate? that means that I have to automaticaly rebuild the mv everymonth (in my case).

    The materialized view would need to be refreshed completely, but there should be no problem defining it and setting up a monthly refresh schedule.
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • How I can create view with parameters?

    I have very big query (2000 rows) and 2 parameters.
    How I can create view with parameters?

    If I use this small part of my query than I have error :
    java.lang.NullPointerException
         at oracle.javatools.db.ora.OracleSQLQueryBuilder.buildQuery(OracleSQLQueryBuilder.java:199)
         at oracle.javatools.db.ora.OracleSQLQueryBuilder.buildQuery(OracleSQLQueryBuilder.java:147)
    What does it means?
    select
    ' Payroll ' as Revenue
    , t.umonth, nvl(p.hmy, 0), nvl(t.sMTD, 0), nvl(a.inormalbalance, 0), nvl(T.sbudget, 0), nvl(a.scode, 0)
    from
    acct a, total t, property p, param par
    where
    nvl(t.hacct, 0) = nvl(a.hmy, 0)
    and nvl(par.hretain, 0) <> nvl(a.hmy, 0)
    and nvl(t.iBook, 0) = 0
    and nvl(a.iacctType, 0) = 0 /*Regular accts*/
    and nvl(t.hppty, 0) = nvl(p.hmy, 0)
    and ( nvl(a.scode, 0) between 60000 and 6009000 )
    union all ---------------------------------------------------------------------------------------------------------------------------------
    select
    ' Payroll Taxes '
    , t.umonth, nvl(p.hmy, 0), nvl(t.sMTD, 0), nvl(a.inormalbalance, 0), nvl(T.sbudget, 0), nvl(a.scode, 0)
    from
    acct a, total t, property p, param par
    where
    nvl(t.hacct, 0) = nvl(a.hmy, 0)
    and nvl(par.hretain, 0) <> nvl(a.hmy, 0)
    and nvl(t.iBook, 0) = 0
    and nvl(a.iacctType, 0) = 0 /*Regular accts*/
    and nvl(t.hppty, 0) = nvl(p.hmy, 0)
    and
    (nvl(a.scode, 0) between 60100 and 60690 )
    union all -------------------------------------------------------------------------------------------------------------------------------
    select
    ' Workers Comp/Disability '
    , t.umonth, nvl(p.hmy, 0), nvl(t.sMTD, 0), nvl(a.inormalbalance, 0), nvl(T.sbudget, 0), nvl(a.scode, 0)
    from
    acct a, total t, property p, param par
    where
    nvl(t.hacct, 0) = nvl(a.hmy, 0)
    and nvl(par.hretain, 0) <> nvl(a.hmy, 0)
    and nvl(t.iBook, 0) = 0
    and nvl(a.iacctType, 0) = 0 /*Regular accts*/
    and nvl(t.hppty, 0) = nvl(p.hmy, 0)
    and
    ( nvl(a.scode, 0) between 61200 and 61260)
    union all -------------------------------------------------------------------------------------------------------------------------------
    select
    ' Pension and Hospitalization '
    , t.umonth, nvl(p.hmy, 0), nvl(t.sMTD, 0), nvl(a.inormalbalance, 0), nvl(T.sbudget, 0), nvl(a.scode, 0)
    from
    acct a, total t, property p, param par
    where
    nvl(t.hacct, 0) = nvl(a.hmy, 0)
    and nvl(par.hretain, 0) <> nvl(a.hmy, 0)
    and nvl(t.iBook, 0) = 0
    and nvl(a.iacctType, 0) = 0 /*Regular accts*/
    and nvl(t.hppty, 0) = nvl(p.hmy, 0)
    and
    ( nvl(a.scode, 0) between 61000 and 61550 )
    union all -------------------------------------------------------------------------------------------------------------------------------
    select
    ' Other Labor Costs '
    , t.umonth, nvl(p.hmy, 0), nvl(t.sMTD, 0), nvl(a.inormalbalance, 0), nvl(T.sbudget, 0), nvl(a.scode, 0)
    from
    acct a, total t, property p, param par
    where
    nvl(t.hacct, 0) = nvl(a.hmy, 0)
    and nvl(par.hretain, 0) <> nvl(a.hmy, 0)
    and nvl(t.iBook, 0) = 0
    and nvl(a.iacctType, 0) = 0 /*Regular accts*/
    and nvl(t.hppty, 0) = nvl(p.hmy, 0)
    and
    ( nvl(a.scode, 0) between 616000 and 616400 )

  • Can create view, but cannot create table / materialized view: Xpath is null

    Hi all,
    We recently moved some XML documents into the database in an XMLType column and want to query the data. I've been writing some queries and turning them into materialized views. I got to one query, and something really strange is happening. My query returns the expected results, but I am getting an error when I try to create a materialized view out of it. Even stranger, I can create a view out of it, and I can manually insert its data into an existing table, but I cannot create a materialized view out of it and I cannot create a table out of it. Here is a brief summary, please let me know if anyone has suggestions.
    Issuing the following commands fails in SQLDeveloper
    -- Creating a materialized view out of the query fails:
    create materialized view element REFRESH COMPLETE ON DEMAND as [query];
    Error at Command Line:1 Column:1 SQL Error: ORA-31063: XPath compilation failed: Xpath is null.
    -- Creating a table out of the query with the following shortcut fails:
    create table element as [query];
    Error at Command Line:1 Column:1 SQL Error: ORA-31063: XPath compilation failed: Xpath is null.
    Issuing the following commands in SQLDeveloper works fine:
    -- Creating a view out of the query works:
    create or replace view element as [query];
    -- Creating a blank table from the query and then inserting data works:
    create table element as select * from [query] where 1 = 2;
    insert into element select * from [query];
    Here is a simplified version of the query...
    I have changed the names around, and cut the query down so maybe it will be a little easier to understand. I did confirm that this query is also having the same symptoms described above. Since I changed the names, executing the query returns no results. However creating a materialized view out of the query still fails with the 'Xpath is null' error.
    create materialized view element REFRESH COMPLETE ON DEMAND as
    select
    m.resource_id,
    xml.*
    from metadata_sources m,
    xmltable(
    'for $i in /metadata/app//*[(self::elem1 or self::elem2) and (parent::form or parent::subform)]
    let $formName := if($i/parent::subform) then $i/../../@name else $i/../@name
    let $subformName := if($i/parent::subform) then $i/../@name else ""
    return <data
    appId="{$i/ancestor::app[1]/idField}"
    formName="{$formName}"
    subformName="{$subformName}"
    elemName="{$i/@name}"></data>' passing m.xml_content
    columns
    app_id NUMBER path '@appId',
    form_name VARCHAR2(50 char) path '@formName',
    subform_name VARCHAR2(50 char) path '@subformName',
    elem_name VARCHAR2(50 char) path '@elemName'
    ) xml;
    Edited by: user11949534 on Feb 22, 2013 1:55 PM

    As far as creating a structured index, I was under the impression that I would need to then register an XSD. No, you can use it without an XML schema.
    How about a regular relational view, with an underlying xml index?
    That way you also eliminate the need for an explicit refresh step as you would then be querying real-time data, as if it were relational data.
    For example :
    Connected to:
    Oracle Database 11g Express Edition Release 11.2.0.2.0 - Production
    SQL> create table tmp_xml of xmltype ;
    Table created.
    SQL> insert into tmp_xml values (
      2    xmlparse(document '<root><item id="1">ABC</item><item id="2">DEF</item></root>')
      3  ) ;
    1 row created.
    SQL> insert into tmp_xml values (
      2    xmlparse(document '<root><item id="3">GHI</item><item id="4">JKL</item></root>')
      3  ) ;
    1 row created.
    SQL> create or replace view tmp_xml_v as
      2  select x.item_id, x.item_val
      3  from tmp_xml
      4     , xmltable(
      5         '/root/item' passing object_value
      6         columns item_id  number      path '@id'
      7               , item_val varchar2(3) path '.'
      8       ) x
      9  ;
    View created.
    SQL> create index tmp_xml_sxi on tmp_xml (object_value)
      2  indextype is xdb.xmlindex
      3  parameters (q'#
      4  XMLTABLE tmp_xml_xtb '/root/item'
      5  COLUMNS item_id  number      path '@id'
      6        , item_val varchar2(3) path '.' #'
      7  ) ;
    Index created.
    SQL> exec dbms_stats.gather_table_stats(user, 'TMP_XML');
    PL/SQL procedure successfully completed.
    SQL> set autotrace on explain
    SQL> set lines 200
    SQL> select * from tmp_xml_v ;
       ITEM_ID ITE
             3 GHI
             4 JKL
             1 ABC
             2 DEF
    Execution Plan
    Plan hash value: 4168126828
    | Id  | Operation                    | Name                   | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT             |                        |     4 |   164 |     3   (0)| 00:00:01 |
    |   1 |  NESTED LOOPS                |                        |       |       |            |          |
    |   2 |   NESTED LOOPS               |                        |     4 |   164 |     3   (0)| 00:00:01 |
    |   3 |    INDEX FULL SCAN           | SYS_C009273            |     2 |    34 |     1   (0)| 00:00:01 |
    |*  4 |    INDEX RANGE SCAN          | SYS30366_30367_OID_IDX |     2 |       |     0   (0)| 00:00:01 |
    |   5 |   TABLE ACCESS BY INDEX ROWID| TMP_XML_XTB            |     2 |    48 |     1   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       4 - access("TMP_XML"."SYS_NC_OID$"="SYS_SXI_0"."OID")

  • Creating Materialized View with the Distinct key word

    Hi
    I need help to create Materialized View with the Distinct key word.
    my query is
    select distinct col1, col2 from t1;
    is there any alternate of DISTINCT because I can not refresh the MV as fast on demand if I am using it and Fast on Demand is a must for me.

    hi
    check out this link
    http://download-west.oracle.com/docs/cd/B12037_01/server.101/b10736/basicmv.htm#i1007299
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14220/intro.htm#sthref183
    hope this helps
    CHeers

  • Can't update master table when creating a materialized view log.

    Hi all,
    I am facing a very strange issue when trying to update a table on which I have created a materialized view log (to enable downstream fast refresh of MV's). The database I am working on is 10.2.0.4. Here is my issue:
    1. I can successfully update (via merge) a dimension table, call it TABLEA, with 100k updates. However when I create a materialized view log on TABLEA the merge statement hangs (I killed the query after leaving it to run for 8 hrs!). TABLEA has 11m records and has a number of indexes (bitmaps and btree) and constraints on it.
    2. I then create a copy of TABLEA, call it TABLEB and re-created all the indexes and constraints that exist on TABLEA. I created a materialzied view log on TABLEB and ran the same update....the merge completed in under 5min!
    The only difference between TABLEA and TABLEB is that the dimension TABLEA is referenced by a number of FACT tables (by FKs on the FACTS) however this surely should not cause a problem. I don't understand why the merge on TABLEA is not completing...even though it works fine on its copy TABLEB? I have tried rebuilding the indexes on TABLEA but this did not work.
    Any help or ideas on this would be most appreciated.
    Kind Regards
    Mitesh
    email: [email protected]

    Thats what I thought, the MVL will only read data that has changed since it was created and wont have the option to load in all the data as though it was made before the table was created.
    From what I have read, the MVL is quicker than a Trigger and I have some free code that prooved to work from a MVL using it as a reference to know what records to update. There is not that much to a MVL, a record ID and type of update, New, Update or Delete.
    I think what I will have to do is work on a the same principle for the MVL but use a Trigger as this way we can do a full reload if required at any point.
    Many thanks for your help.

  • How to create a view with parameters; read the documentation but nothing!

    Hello!
    I'm new to the Oracle world but together with my coworkers we need to very quickly study Oracle to figure out whether we'll add Oracle to our list of supported databases or not.
    Question: How do I create a view with parameters?
    I've read the documentation but I could not find this! I found the sql syntax to create a view but no parameters whatsoever...
    I have found on the web some very complicated way of doing this, but doesn't Oracle support Views with parameters?
    The goal here is to return a recordset, don't forget, so,please don't speak about stored procedures unless you are going to tell me how to get a recordset out of a stored procedure! ;)
    Thanks for all your help and attention!
    Jorge C.

    You can set up a parameterized view via context as follows:
    1. Set up a procedure to set your context values:
    create or replace procedure p_set_context (p_context IN VARCHAR2,p_param_name IN VARCHAR2,p_value IN VARCHAR2)
    as
    BEGIN
    sys.dbms_session.set_context(p_context,p_param_name,p_value);
    END;
    2. Create your context using the procedure you just created
    create or replace context my_ctx using p_set_context
    3. This is the test table I'll use
    create table my_table(col1 number)
    and populate it:
    begin
    for v_index in 1..10
    loop
    insert into my_table values(v_index);
    end loop;
    end;
    and the view that will be parameterised
    create or replace view v_my_table as select col1 from my_table where col1 between sys_context('my_ctx','start_range') and sys_context('my_ctx','end_range')
    4. Now set the parameters using the procedure above.
    begin
    p_set_context('my_ctx','start_range','1');
    p_set_context('my_ctx','end_range','5');
    end;
    5. Selecting from my_table will give you 1 to 10 (no surprise there :-) )
    selectng from v_my_table will give you 1 to 5
    You can use the context to set formats etc using the same principle. A common gotcha to watch for is trying to set the context directly using DBMS_SESSION.SET_CONTEXT instead of creating a procedure. This belongs to SYS and SYS won't have the privileges to set your context so you get an insufficient privileges result leading to much headscratching and unnecessary grants (at least that's my understanding of it).
    Sorry Jorge, as you're new to Oracle I should also have pointed out for completeness sake, that you can change the parameters at any time through recalling the p_set_context, for example, following on from above, after your "select * from v_my_table" and seeing 1 to 5, you could then do
    begin
    p_set_context('my_ctx','start_range','3');
    end;
    and when you requery 'Select * from v_my_table' you will now see rows 3 to 5.
    Bit of a simplistic example, but you can see how easy it is. :-)
    Message was edited by:
    ian512

  • Is it possible to create views with parameters ?

    Hi,
    As MS-Access, is it possible to create views with parameters ?
    Ms-Access syntax : parameters [a] text; select * from table where code = [a]
    If yes, can you give samples ?
    Regards
    Pascal

    I suggest you you write a stored procedure that returns a recordset in oracle. Then execute the stored procedure and loop through the record set.
    Look in in MS Knowledgebase searching on ADO Stored Proceedures for the VB/C++/VBS .. code.
    Look in in Oracle PL/SQL guide for the Stored Proceedure code.

Maybe you are looking for

  • What type of dvd drive enclosure do I need?

    I have a 2008 Macbook Pro PRE unibody that I put a solid state drive in the standard HD and moved the standard HD to the dvd drive slot.   Now its time to buy a DVD drive enclosure but I cant seem to find one/figure out exactly what to buy. I underst

  • Ajax auto-suggest with adf

    Hi.. I am trying to implement ajax auto-suggest using the example @ http://www.oracle.com/technology/products/jdev/tips/mills/AjaxAutoSuggest/AjaxAutoSuggest.html After trying it, i realised the auto-suggest component does not work in firefox, but on

  • Final cut pro event and project missing

    Everytime when I quit FCPX, I found nothing when I open the software next time to edit my video. I have got nothing after spend 10 hours on my editing, whats going on??????????? The event folder and project folder were still there, but I just can't r

  • URGENT iMovie not importing video

    Hi there, I have a really urgent iMovie project I need to have completed by Monday, however I am having extreme difficulty importing my last video file for some reason. I am uploading footage from a SONY HD HANDYCAM (it says HDR-SR11) and I am using

  • HT1386 Can't find my device on iTunes?

    I just installed the latest update iTunes (11.1.4.62) and now it's not showing my device when I plug it into my computer. It was showing my device with a previous version of Itunes and now I don't see where it is at all. Help!