Creating a combined view of two spatially indexed tables

Hi All,
I'm using oracle 10g and C++ occi to store and retrieve data. I have two tables that are identical in structure, they have an SDO_GEOM column where I store lat/long/altitude info. When I store the data using a stored procedure, the data is put into the correct table. I now want to retrieve the data using a spatial operator - I use SDO_NN to retrive data within a given distance of a lat/long/altitude point. This works fine for a single or multiple tables as I use a stored function to give me the data back as an object. I now have a requirement to list all the data from both tables - I thought I could do this by creating a combined view but I understand this cannot be done with spatial data - I habe also tried using the join operator but I am having problems since the columns for each table are identical. Is there any workaround for this - the combined view will not have any spatial operators run on it, I just need to return each row (the spatial data can be returned as individual lat/long/alt instead of as a SDO_GEOM. A second idea I had would be to return all the data using a ref cursor - this works for a single table but I do not understand how I can open the cursor with a select from two tables with identical column names.
Unfortunately it is a requirement that the tables are seperate so combining the two tables into one is not an option.
Thanks in advance for any help anyone can offer,
Cheers,
Rob

You can create a UNION ALL view:
CREATE TABLE cola_markets_1 (
mkt_id NUMBER PRIMARY KEY,
name VARCHAR2(32),
shape SDO_GEOMETRY);
CREATE TABLE cola_markets_2 (
mkt_id NUMBER PRIMARY KEY,
name VARCHAR2(32),
shape SDO_GEOMETRY);
CREATE VIEW v1 AS
SELECT * FROM cola_markets_1 UNION ALL SELECT * FROM cola_markets_2;
If both tables have a spatial index on their shape column, a query plan will look
like:
explain plan for SELECT c.mkt_id, c.name FROM v1 c WHERE SDO_NN(c.shape, SDO_GEOMETRY(2003, NULL, NULL, SDO_ELEM_INFO_ARRAY(1,1003,3), SDO_ORDINATE_ARRAY(4,6, 8,8)) , 'sdo_num_res=1') = 'TRUE';
0 SELECT STATEMENT     |           |
1 VIEW               | V1          |
2 UNION-ALL          |           |
3 TABLE ACCESS BY INDEX ROWID| COLA_MARKETS_1
4 DOMAIN INDEX     | COLA_SPATIAL_IDX_1
5 TABLE ACCESS BY INDEX ROWID| COLA_MARKETS_2
6 DOMAIN INDEX     | COLA_SPATIAL_IDX_2
However, the above SDO_NN query will return 2 rows (one from each table),
because it can only work on one table, it won't return the nearest neighbor
from the combined view without some tweaks. For example, to return the
top one, you may try:
select * from (SELECT c.mkt_id, c.name FROM v1 c WHERE SDO_NN(c.shape, SDO_GEOMETRY(2003, NULL, NULL, SDO_ELEM_INFO_ARRAY(1,1003,3), SDO_ORDINATE_ARRAY(4,6, 8,8)) , 'sdo_num_res=1') = 'TRUE' order by sdo_geom.sdo_distance(c.shape, SDO_GEOMETRY(2003, NULL, NULL, SDO_ELEM_INFO_ARRAY(1,1003,3), SDO_ORDINATE_ARRAY(4,6, 8,8)), 0.0001)) where rownum < 2;
Note that you can only pass literals or bind variables into the second input parameter
of spatial operators (including SDO_NN), when a UNION ALL view is used. i.e. the following
query won't work right now:
SELECT c.* FROM v1 c, another_table b WHERE b.id =1 and SDO_NN(c.shape, b.shape, 'sdo_num_res=1')= 'TRUE';

Similar Messages

  • View joining two spatial tables and strange CBO behaviour

    Hi all,
    I've following view in my database:
    CREATE OR REPLACE VIEW my_view AS
    SELECT id, 'table1' AS source, location FROM my_table1
    UNION ALL
    SELECT id, 'table2' AS source, location FROM my_table2;
    When I execute query:
    SELECT * FROM my_view WHERE SDO_RELATE(location, SDO_GEOMETRY(...), 'mask=anyinteract') = 'TRUE';
    It works as expected.
    When running query like (getting location with subquery):
    SELECT * FROM my_view WHERE SDO_RELATE(location, (SELECT location FROM my_table3 WHERE id = 123, 'mask=anyinteract') = 'TRUE';
    It doesn't work. Oracle Throws "DatabaseError: ORA-13226: interface not supported without a spatial index"
    Further investigation revealed strange behaviour of CBO:
    In first case Oracle CBO uses Spatial index just fine and as expected.
    But second query and CBO get's a bit strange - unique index scan is used for subselect, but for view tables is full table scan is used and SDO_RELATE is not happy with that since no spatial index is used.
    How I can use spatial indexes regardless of that subselect?

    Hi folks,
    Looking over these responses and not finding a lot of clarity yet in terms of leaving a trail for future readers to glean an answer from.  I was just looking through the back-and-forth and curious myself about the issue  First of all I think Jani's observations are quite on target.  This CBO reaction is weird and does not work they way most Oracle users would expect it to work.  Secondly, Jani really should tell us his Oracle version and folks providing answers should as well - the CBO is always being tweaked.  Thirdly, Stefan provides a solution though it's a rather expensive solution to my taste.  And finally, I think we as a group need to spend a bit more time reproducing things in code.  I will give it a shot, feel free to correct anything I got wrong.
    So first of all, I wrote this up quick on 12.1.0.2 and verified it was the same on 11.2.0.4
    DROP TABLE my_table1 PURGE;
    CREATE TABLE my_table1(
        objectid INTEGER NOT NULL
       ,tsource  VARCHAR2(30 Char)
       ,shape    MDSYS.SDO_GEOMETRY
       ,PRIMARY KEY(objectid)
    DROP TABLE my_table2 PURGE;
    CREATE TABLE my_table2(
        objectid INTEGER NOT NULL
       ,tsource  VARCHAR2(30 Char)
       ,shape    MDSYS.SDO_GEOMETRY
       ,PRIMARY KEY(objectid)
    DROP TABLE my_table3 PURGE;
    CREATE TABLE my_table3(
        objectid INTEGER NOT NULL
       ,tsource  VARCHAR2(30 Char)
       ,shape    MDSYS.SDO_GEOMETRY
       ,PRIMARY KEY(objectid)
    CREATE OR REPLACE PROCEDURE seeder(
       p_count IN NUMBER
    AS
       sdo_foo MDSYS.SDO_GEOMETRY;
       int_counter NUMBER := 1;
       FUNCTION random_line
       RETURN MDSYS.SDO_GEOMETRY
       AS
          num_x1 NUMBER;
          num_y1 NUMBER;
          num_offx NUMBER;
          num_offy NUMBER;
       BEGIN
          num_x1 := dbms_random.value(-179,179);
          num_y1 := dbms_random.value(-89,89);
          RETURN MDSYS.SDO_GEOMETRY(
              2002
             ,8265
             ,NULL
             ,MDSYS.SDO_ELEM_INFO_ARRAY(1,2,1)
             ,MDSYS.SDO_ORDINATE_ARRAY(
                  num_x1
                 ,num_y1
                 ,num_x1 + 0.0001
                 ,num_y1 + 0.0001
       END random_line;
    BEGIN
       FOR i IN 1 .. p_count
       LOOP
          sdo_foo := random_line();
          INSERT INTO my_table1
          VALUES (
              int_counter
             ,'table1'
             ,sdo_foo
          int_counter := int_counter + 1;
          sdo_foo := random_line();
          INSERT INTO my_table2
          VALUES (
              int_counter
             ,'table2'
             ,sdo_foo
          int_counter := int_counter + 1;
          sdo_foo := random_line();
          INSERT INTO my_table3
          VALUES (
              int_counter
             ,'table3'
             ,sdo_foo
          int_counter := int_counter + 1;
       END LOOP;
       INSERT INTO my_table1
       VALUES (
           0
          ,'table1'
          ,MDSYS.SDO_GEOMETRY(
               2002
              ,8265
              ,NULL
              ,MDSYS.SDO_ELEM_INFO_ARRAY(1,2,1)
              ,MDSYS.SDO_ORDINATE_ARRAY(
                   -87.8211111
                  ,42.5847222
                  ,-87.8212
                  ,42.5848
       INSERT INTO my_table3
       VALUES (
           0
          ,'table3'
          ,MDSYS.SDO_GEOMETRY(
               2002
              ,8265
              ,NULL
              ,MDSYS.SDO_ELEM_INFO_ARRAY(1,2,1)
              ,MDSYS.SDO_ORDINATE_ARRAY(
                   -87.8211111
                  ,42.5848
                  ,-87.8212
                  ,42.5847222
       COMMIT;
    END seeder;
    BEGIN
       seeder(100000);
    END;
    SELECT 'my_table1: ' || COUNT(*) AS invalid_count FROM my_table1 WHERE MDSYS.SDO_GEOM.VALIDATE_GEOMETRY_WITH_CONTEXT(shape,0.05) <> 'TRUE'
    UNION ALL
    SELECT 'my_table2: ' || COUNT(*) AS invalid_count FROM my_table2 WHERE MDSYS.SDO_GEOM.VALIDATE_GEOMETRY_WITH_CONTEXT(shape,0.05) <> 'TRUE'
    UNION ALL
    SELECT 'my_table3: ' || COUNT(*) AS invalid_count FROM my_table3 WHERE MDSYS.SDO_GEOM.VALIDATE_GEOMETRY_WITH_CONTEXT(shape,0.05) <> 'TRUE';
    BEGIN
       INSERT INTO user_sdo_geom_metadata(
           table_name
          ,column_name
          ,diminfo
          ,srid
       ) VALUES (
           'MY_TABLE1'
          ,'SHAPE'
          ,MDSYS.SDO_DIM_ARRAY(MDSYS.SDO_DIM_ELEMENT('X',-180,180,.05),MDSYS.SDO_DIM_ELEMENT('Y',-90,90,.05))
          ,8265
       COMMIT;
    EXCEPTION
       WHEN OTHERS
       THEN
          NULL;
    END;
    BEGIN
       INSERT INTO user_sdo_geom_metadata(
           table_name
          ,column_name
          ,diminfo
          ,srid
       ) VALUES (
           'MY_TABLE2'
          ,'SHAPE'
          ,MDSYS.SDO_DIM_ARRAY(MDSYS.SDO_DIM_ELEMENT('X',-180,180,.05),MDSYS.SDO_DIM_ELEMENT('Y',-90,90,.05))
          ,8265
       COMMIT;
    EXCEPTION
       WHEN OTHERS
       THEN
          NULL;
    END;
    BEGIN
       INSERT INTO user_sdo_geom_metadata(
           table_name
          ,column_name
          ,diminfo
          ,srid
       ) VALUES (
           'MY_TABLE3'
          ,'SHAPE'
          ,MDSYS.SDO_DIM_ARRAY(MDSYS.SDO_DIM_ELEMENT('X',-180,180,.05),MDSYS.SDO_DIM_ELEMENT('Y',-90,90,.05))
          ,8265
       COMMIT;
    EXCEPTION
       WHEN OTHERS
       THEN
          NULL;
    END;
    CREATE INDEX my_table1_spx ON my_table1
    (shape)
    INDEXTYPE IS MDSYS.SPATIAL_INDEX
    NOPARALLEL;
    CREATE INDEX my_table2_spx ON my_table2
    (shape)
    INDEXTYPE IS MDSYS.SPATIAL_INDEX
    NOPARALLEL;
    CREATE INDEX my_table3_spx ON my_table3
    (shape)
    INDEXTYPE IS MDSYS.SPATIAL_INDEX
    NOPARALLEL;
    BEGIN
       dbms_stats.gather_table_stats(USER, 'MY_TABLE1');
       dbms_stats.gather_index_stats(USER, 'MY_TABLE1_SPX');
       dbms_stats.gather_table_stats(USER, 'MY_TABLE2');
       dbms_stats.gather_index_stats(USER, 'MY_TABLE2_SPX');
       dbms_stats.gather_table_stats(USER, 'MY_TABLE3');
       dbms_stats.gather_index_stats(USER, 'MY_TABLE3_SPX');
    END;
    CREATE OR REPLACE VIEW my_view
    AS
    SELECT
    objectid
    ,'table1' AS tsource
    ,shape
    FROM
    my_table1
    UNION ALL
    SELECT
    objectid
    ,'table2' AS tsource
    ,shape
    FROM my_table2;
    set timing on;
    -- QUERY #1
    -- Jani's original setup, works as expected
    SELECT
    COUNT(*) AS single_geom_counter
    FROM
    my_view a
    WHERE
    MDSYS.SDO_RELATE(
        a.shape
       ,MDSYS.SDO_GEOMETRY(
            2002
           ,8265
           ,NULL
           ,MDSYS.SDO_ELEM_INFO_ARRAY(1,2,1)
           ,MDSYS.SDO_ORDINATE_ARRAY(
                -87.8211111
               ,42.5848
               ,-87.8212
               ,42.5847222
       ,'mask=anyinteract'
    ) = 'TRUE';
    -- QUERY #2
    -- Now the problem statement
    SELECT
    COUNT(*) AS table_problem_counter
    FROM
    my_view a
    WHERE
    MDSYS.SDO_RELATE(
        a.shape
       ,(SELECT b.shape FROM my_table3 b WHERE b.objectid = 0)
       ,'mask=anyinteract'
    ) = 'TRUE';
    -- QUERY #3
    -- Stefan's solution
    SELECT  /*+ ORDERED */
    COUNT(*) AS stefans_solution
    FROM
    my_table3 a
    ,my_view b
    WHERE
    a.objectid = 0
    AND MDSYS.SDO_RELATE(
        a.shape
       ,b.shape
       ,'mask=anyinteract'
    ) = 'TRUE';
    Anyhow, so the hard coded query #1 that Jani provided works exactly the way most folks would expect, the second item in the relate is applied to each spatial index participating in the view.  I think we can agree this is what we want.
    Now when we move on to the problem, well its all goes off the rails as I think its looks to apply the spatial filter to the view itself which lacks an index (not sure really)
    So as Stefan says, you can work around this by rewriting things as query #3 does above though now its a full table scan of both tables in the view.  This is a long way performance wise from Query #1!
    So on my 12c test box
       query #1 Elapsed: 00:00:00.016
       query #3 Elapsed: 00:00:33.534
    On 11g production box
       query #1 Elapsed: 00:00:00.49
       query #3 Elapsed: 00:02:31.45   (ouch!)
    So hopefully someone else can jump in with more information on better solutions?  
    I overall tend to avoid the kind of unioned views that Jani is using here.  I have a hard time recalling why but I must have been burned similarly many years ago when I was first starting with Oracle spatial.  I tend to always want my spatial indexes right there where I can keep a grim stink eye on them.  It may be that a unioned view with multiple spatial indexes behind it might just be a bad practice better done with a materialized view?  Or maybe a lesser term?  Unprofitable practice?  fraught?  "Best if you don't do that"?
    Anyhow, I would be interested in what others have as input on the matter.
    Cheers,
    Paul

  • Performance issue when inserting into spatial indexed table with JDBC

    We have a table named 'feature' which has a "sdo_geometry" column, and we created spatial index on that column,
    CREATE TABLE feature ( id number, desc varchar, oshape sdo_gemotry)
    CREATE INDEX feature_sp_idx ON feature(oshape) INDEXTYPE IS MDSYS.SPATIAL_INDEX;
    Then we executed the following SQL to insert about 800 records into that table(We tried this by using DB visualizer and
    our Java application, both of them were using JDBC driver to connect to the oracle 11gR2 database) .
    insert into feature(id,desc,oshape) values (1001,xxx,xxxxx);
    insert into feature (id,desc,oshape) values (1002,xxx,xxxxx);
    insert into feature (id,desc,oshape) values (1800,xxx,xxxxx);
    We encoutered the same problem as this topic
    Performance of insert with spatial index
    It takes nearly 1 secs for inserting one record,compare to 50 records inserted per sec without spatial index,
    which is 50x drop in peformance when doing insertion with spatial index.
    However, when we copy and paste those insertion scripts into Oracle Client(same test and same table with spatial index), we got a totally different performance result:
    more than 50 records inserted in 1 secs, just as fast as the insertion without building spatial index.
    Is it because Oracle Client is not using JDBC? Perhaps JDBC was got something wrong when updating those spatial indexed tables.
    Edited by: 860605 on 19/09/2011 18:57
    Edited by: 860605 on 19/09/2011 18:58
    Edited by: 860605 on 19/09/2011 19:00

    Normally JDBC use auto-commit. So each insert can causes a commit.
    I don't know about Oracle Client. In sqlplus, insert is just a insert,
    and you execute "commit" to explicitly commit your changes.
    So maybe this is the reason.

  • How to create a relational view base on an xmltype table which included sev

    Hi,
    I am using oracle 11.2.0.1.0.
    how to create a relational view base on an xmltype table which content several different .xml files?
    Thanks.
    for examle:
    SQL> SELECT OBJECT_VALUE FROM document;
    Edited by: Cow on Jan 6, 2011 7:57 PM

    For example I already have these three xml files inserted into the document xmltype table.
    These xml files have same schemas. I have attached below.
    I want to show all elements/attribute values in xml files to relational view.
    Is this possible to create one big relational view to show everything
    or I have to create three separate relation views then use UNION to put together? Thanks a lot. Cow
    <?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet href="http://www.accessdata.fda.gov/spl/stylesheet/spl.xsl" type="text/xsl"?>
    <document xmlns="urn:hl7-org:v3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:hl7-org:v3 http://localhost:8080/home/DEV/xsd/spl.xsd">
    <id root="5ca4e3cb-7298-4948-8cc2-58e71ad32694"/>
    </component>
    </document>
    <?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet href="http://www.accessdata.fda.gov/spl/stylesheet/spl.xsl" type="text/xsl"?>
    <document xmlns="urn:hl7-org:v3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:hl7-org:v3 http://localhost:8080/home/DEV/xsd/spl.xsd">
    </component>
    </document>
    Edited by: Cow on Jan 4, 2011 9:51 AM

  • Partioning spatially indexed tables

    I am a complete novice when it comes to partitioning, so can someone tell me any advantages/disadvantages/problems in partitioning a large RTREE spatially indexed table (using an SDO_GEOMETRY column) containing several million rows?

    Just to make sure you understand what is and isn't possible:
    When partitioning a table with spatial data, you cannot partition based on the geometry column.
    Spatial index partitioning is only available on a table that has been partitioned by range.
    All of the manageability benefits associated with partitioning data applies to data with a spatial column as well. If the index has been built using partitioning, you can do things like store different index partitions in different tablespaces, index partition rebuilds, index partition archives, exchange, split, merge partitions, etc.
    In terms of performance, there are several benefits that can be achieved:
    If the partition key can be specified as a predicate on the query, then there can be a large performance improvement.
    If you can't specify a partition key in the query, then if the index is stored across different tablespaces then concurrency can improve if multiple sessions are accessing the index.
    Single stream performance can be improved through the use of parallelism as well.
    Most of the above is available in 9iR1, although exchange partition and parallelism both were available as of 9iR2.
    If there is no parallelism, and no partition key predicate can be specified in spatial queries, and there is only single session access to the database, and you don't need the manageability benefits, then partitioning probably isn't for you.

  • Materialized view issue with spatial index and UNION all.

    Hi guys,
    I'm trying to build the following materialized view:
    create materialized VIEW MV_ElectricalStuffs
      refresh fast
      AS
      SELECT jb.ROWID,
        jb.FID,
        JB.NAME_NUMBER
      FROM EL_BUS_BAR jb
      UNION ALL
      SELECT INC.ROWID,
        INC.FID,
        NULL,
        INC.NAME_NUMBER
      FROM EL_INTERNAL_CELL INC;
    I have this error showing up:
    ORA-12015: cannot create a fast refresh materialized view from a complex query
    This is because the table EL_INTERNAL_CELL has a SDO_GEOMETRY column that has a spatial index, whose ddl is
    CREATE INDEX EL_INTERNAL_CELL_S ON EL_INTERNAL_CELL (GEOM) INDEXTYPE IS MDSYS.SPATIAL_INDEX
    PARAMETERS('SDO_INDX_DIMS=2 TABLESPACE=USERS LAYER_GTYPE=COLLECTION');
    When I remove the spatial index from EL_INTERNAL_CELL column GEOM, Oracle is very happy and creates the view.
    Is there a mean however to keep the spatial index in the materialized view?

    I've managed to drop the spatial index prior to create the materialized view and it is ok. After the materialized view creation, I've recreated the spatial index on the table and all ran smooth. Hope nothing will go bad in the future because of this trick on spatial index..

  • Creating Compound lay out with two different pivot tables OBIEE 11g?

    Hello,
    I am trying to add two different pivot tables in one compound lay out and add a view selector to it, so that i can choose one at a time. Please advice how can i do this.
    Thanks

    First of all, the expression is "please advise" not "please advice." I thought I'd mention it because I see it so much in the forum. :) (Freebie.)
    Okay, on the surface, your question seems so basic that it makes me wonder what you mean. If you are absolutely brand-new to OBIEE than consult the manual:
    http://download.oracle.com/docs/cd/E14571_01/bi.1111/e10544/creatingviews.htm#BACCBCBA
    If you are stuck on a particular step, then describe the problem in detail.

  • Key in View  for two primary keys tables

    Hi
    I have some view joining LIKP and LIPS:
    LIKP -   Primary Key MANDT, VBELN
    LIPS -   Primary Key MANDT, VBELN, POSR
    The Key for the LIKP-LIPS View is:
    MANDT      LIKP
    VBELN       LIKP
    MANDT_I    LIPS
    VBELN_I    LIPS
    POSNR_I   LIPS
    So, for that Key, if i need to acces a specify LIPS detail record , must i fill all the keys in the where  (filling VBELN twice) like this:
    WHERE VBELN =  vbvalue AND VBELN_I =  vbvalue AND POSNR_I = posvalue ?
    How must i make the Select for acces this View using its Key ?
    Regards
    Frank

    Hi
    Just as I said:
    SELECT SINGLE * FROM Z<VIEW> WHERE VBELN = <VBELN>
                                                                AND POSNR_I = <POSNR>.
    Anyway it's should be better you correct the view deleting the field MANDT_I, VBELN_I, if you can't, I believe the select above works fine.
    VIEW FIELDS:
    View Field Table Field Key
    MANDT LIKP MANDT Yes
    VBELN LIKP VBELN Yes
    <b>MANDT_I LIPS MANDT Yes <----- WRONG
    VBELN_I LIPS VBELN Yes      <----- WRONG</b>
    POSNR_I LIPS POSNR Yes
    ERNAM LIKP ERNAM
    ERDAT LIKP ERDAT
    VKORG LIKP VKORG
    PSTYV_I LIPS PSTYV
    MATNR_I LIPS MATNR
    WERKS_I LIPS WERKS
    LGORT_I LIPS LGORT
    By this defintion the field MANDT and VBELN are only twice, but it doesn't mean the record is double in the VIEW.
    So it you have the delivery 100 with 3 items in the client 200, in the view you'll see:
    Record 1: MANDT   = 200
                   VBELN    = 0000000100
                   MANDT_I = 200
                   VBELN_I  = 0000000100
                   POSNR_I = 000010
    Record 2: MANDT   = 200
                   VBELN    = 0000000100
                   MANDT_I = 200
                   VBELN_I  = 0000000100
                   POSNR_I = 000020
    Record 3: MANDT   = 200
                   VBELN    = 0000000100
                   MANDT_I = 200
                   VBELN_I  = 0000000100
                   POSNR_I = 000030
    Max

  • 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 View with two BEx Queries in BEx

    Hi Experts,
    I have got a scenario where in I have to create a single view on two BEx queries. Can any one give me the necessary steps to create the View?
    Awaiting for your reply,
    Thanks in advance,
    With kind regards,
    Shreeem

    Hi Shreem,
      I think that can be easily done. Check the below thread
    WAD - Integration of multiple queries
    Also see If you can include the two queries in a workbook and maybe later you can try creating a view on it?
    Thanks

  • Specifying nologging while creating spatial indexes

    Hello
    Is it possible to specify NOLOGGING parameter while creating spatial indexes? When i am trying to specify this i get the following error message
    SQL> create index BUSH_sx on BUSH(BUSHLOCATION) indextype is mdsys.spatial_index nologging;
    create index BUSH_sx on BUSH(BUSHLOCATION) indextype is mdsys.spatial_index nologging
    ERROR at line 1:
    ORA-29850: invalid option for creation of domain indexes
    Even i cannot alter the index with NOLOGGING option. Does Oracle allow this option in spatial indexes?
    Regards
    sam

    I am looking into the logging issues.
    SDO_COMMIT_INTERVAL determines the number records in a commit chunk during index BUILD, I noted this was not documented raised doc BUG 6414510 for this
    and SDO_DML_BATCH_SIZE manual entries....
    Specifies the number of index updates to be processed in each batch of updates after a commit operation. The default value is 1000. For example, if you insert 3500 rows into the spatial table and then perform a commit operation, the updates to the spatial index table are performed in four batches of insert operations (1000, 1000, 1000, and 500).
    The sdo_dml_batch_size parameter can improve application performance, because Spatial can preallocate system resources to perform multiple index updates more efficiently than successive single index updates; however, to gain the performance benefit, you must not perform commit operations after each insert operation or at intervals less than or equal to the sdo_dml_batch_size value. You should not specify a value greater than 10000 (ten thousand), because the cost of the additional memory and other resources required will probably outweigh any marginal performance increase resulting from such a value.
    ====================================
    I have found if you are doing repeated inserts/updates etc of 100,000 plus records despite the above, there is an advantage or appears to be! ;-) for setting it to 50,000.
    it can be adjusted for an index that has been built
    update SDO_INDEX_METADATA_TABLE
    set SDO_DML_BATCH_SIZE = <Desired Value>
    where sdo_index_owner = <INDEX/SCHEMA Owner>
    and sdo_index_name = 'INDEX_NAME';
    Clearly every system will be different experiment on test systems only....
    Another area which can generally impact DML is undo_retention holding blocks when
    you just don't care.
    good settings when you dont wish to hold it
    Look at SQL> show parameter undo
    undo_management string AUTO
    undo_retention integer 1 <<<< One second
    undo_tablespace string MAKE Sure its big enough
    with 10.2.0.x seems to be an issue with setting it to 0 but I've not had time to investigate
    will do later. Also at 10.2.0.2 VERY large DML can sometimes hit ORA-600's the reasons are complex if you do hit them open a service request with support. There is a patch to cope with 95% of the issues. The other 5% I'm in the process of nailing and for those the current workaround is
    update SDO_INDEX_METADATA_TABLE
    set SDO_DML_BATCH_SIZE = 1
    where sdo_index_owner = <INDEX/SCHEMA Owner>
    and sdo_index_name = 'INDEX_NAME';
    ========================================
    Dont do this without checking the 600 with support....
    ========================================
    rather rambling....regarding the redo watch this space...

  • How to get a value from  select one choice (created by static view)

    Hi,
    Whene ever Iam trying to get value from select one choice which is created by static view iam getting only index.How to get the actual value in 11g .please help me anybody .Thanx in advance....
    Edited by: 874530 on Jul 22, 2011 11:05 PM

    Thnax for your quick reply..
    Iam using 11.1.1.3.0 version.
    My code is
    <af:selectOneChoice value="#{bindings.DenialLevel.inputValue}"
    label="#{bindings.DenialLevel.label}"
    required="#{bindings.DenialLevel.hints.mandatory}"
    shortDesc="#{bindings.DenialLevel.hints.tooltip}"
    id="soc2"
    valuePassThru="true"
    binding="#{backing_denialcomment.denialLevelList}">
    <f:selectItems value="#{bindings.DenialLevel.items}" id="si6"/>
    </af:selectOneChoice>
    and in bean am not able to get value of attribute .Iam getting only index...

  • Spatial Index problem with query

    I created a spatial index with user A. When i do a spatail query, i receive a good result. But, when i execute the same query with user B, i receive the following error :
    ERROR at line 1:
    ORA-13226: interface not supported without a spatial index
    ORA-06512: at "MDSYS.MD", line 1723
    ORA-06512: at "MDSYS.MDERR", line 8
    ORA-06512: at "MDSYS.SDO_3GL", line 58
    I don't understand why user B seems not to be able to see or use the spatal index created by user A.

    Hi,
    What version of spatial are you using? You might have to grant select access on the spatial index table to user b in older versions of spatial.

  • How to create a triangle view with a select query?

    I need help to build a select query that will create a triangle view.
    Below is the table I have to query
    *{color:#ff0000}INITIAL TABLE{color}*
    *{color:#008000}AMOUNT | TRANSACTION_DATE | OPEN_DATE | TYPE{color}*
    5 | 30-JAN-09 | 10-JAN-09 | A
    10 | 12-JAN - 09 | 30-NOV-08 | A
    20 | 30 - DEC - 08 | 15-OCT-08 | A
    10 | 30 - DEC - 08 | 8 - OCT - 08 | A
    *{color:#ff0000}THE FINAL TABLE I HAVE TO CREATE:{color}*
    DEV_PERIOD - TO_CHAR(TRUNC(TRANSACTION_DATE,'Q'),'YYYY-Q') AS DEV_PERIOD
    OPEN PERIOD - TO_CHAR(TRUNC(OPEN_DATE,'Q'),'YYYY-Q') AS OPEN_PERIOD
    {color:#008000}*SUM of AMOUNT | DEV_PERIOD | OPEN_PERIOD | TYPE*{color}
    5 | 2009 - 1 | 2009 - 1 | A
    40 | 2009 - 1 | 2008 - 4 | A
    30 | 2008 - 4 | 2008 - 4 | A
    {color:#ff0000}*This is another view of the table (The triangle view)*{color}
    | Dev_Period 2008- 1 | 2008 - 2| 2008 -3 | 2008 - 4 | 2009 -1 |
    Open_Period |
    2008 - 1..................... 0.......... 0............ 0........... 0.......... 0
    2008 - 2 ..................................0............ 0........... 0.......... 0
    2008 - 3................................................. 0........... 0.......... 0
    2008 - 4 ..............................................................30......... 40
    2009 - 1 .............................................................................5
    Any ideas will be appreaciated.
    Thank you!

    I think the first thing you need to do is look up "pivot query" in this newsgroup. And how complicated your query gets to be will depend on your database version (11 natively supports pivot queries). You have a variable number of columns in your result set (depending on how many quarters you have in your data.
    I think once you get the columns sorted out, working out the numbers to put in each column will be relatively easy.
    Jon

  • A quicker way to create a materialized view?

    Hi,
    I'm new to replication and have been reading doco on it. Basically I want to set up read-only materialized views in oracle 11g.
    So on the replicated database I created a db link that points to the master db.
    Then I created a materialized view that does "select * from table@dblink" and that is forced refresh every 10 minutes.
    Problem is that the table on the master db is large and the network link is slow, so the "create materialized view" statement would take a long time to complete.
    So I think to speed up the process I would export/import the table from master to replicated db, then make this imported table a materialized view somehow.
    Is this possible, and if so, how?
    Thanks.
    Long

    If you are able to use other means (exp-imp, expdp/impdp, unload-sqlldr, externalfile etc) to copy the data faster (as a normal table in the target database), you can then use the "ON PREBUILT TABLE" clause in the CREATE MATERAILIZED VIEW statement.
    See
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_6002.htm#i2063793
    Alternatively, you must first verify if the CREATE is slow only because of SQL Query performance on the source, rather than because of network bandwidth/latency. If query execution needs to be tuned, that would be a cleaner solution, because the Refresh can then be automatically handled by Oracle.
    Remember that you can use Materialized View Log(s) on the source tables to enable FAST Refresh's as well.

Maybe you are looking for