Ora-13226 when performing spatial query on view

Hi,
in my database I have a view with spatial column. The view is based on UNION ALL select. When I try to run spatial query on the view, the database returns ora-13226 error. When I recreate the view to consist only one select (without UNION ALL) the spatial query return correct result. Could you pls help me how to do a spatial query on spatial view whose definition contains UNION ALL select?
Thanks
Andrew

Hi,
it's quite simple:
create view test_view as
select id, geometry from table_a
union all
select id, geometry from table_b;
When I try for example:
select *
from test_view
where sdo_relate(geometry, (select geometry from table_c where id=1316),'mask=anyinteract') = 'TRUE';
it throws ora-13226 error.
Interesting is that following query where the geometry is directly included runs well:
select *
from test_view
where sdo_relate(geometry, MDSYS.SDO_GEOMETRY (....),'mask=anyinteract') = 'TRUE';
also when I recreate the test_view as
create view test_view as
select id, geometry from table_a;
then also the first query (with inner select) returns no error.
It's a little bit strange isn't it?
Andrew

Similar Messages

  • ORA-01555 when performing refresh of materialized views via DBMS_JOB

    All,
    With this project needing to be finished soon and an issue occuring on the local database, I am hopefuly one of you will have the answer or resolution so that I may complete this project soon....
    Here is the setup..
    10g database (remote)
    9i database (local
    DB Link from local to remote database
    103 materialized views in local database that are refreshed by pulling data from dblink to remote database.
    A PL/SQL procedure has been created which sets the v_failures variable = 0 and then performs a check to see if the current job has a failure and if so, inserts that value into the v_failures variable. When that reaches "1", then the procedure does nothing and closes out. If the failures are equal to "0" then it performs a DBMS_MVIEW.REFRESH procedure for each materialized view.
    This worked the first time but its continually failing now with the ORA-01555 error (snapshot too old). From what I can tell, the dbms_job duration is 4 seconds and the Last_Exec is 2m 7s after it starts (8:30 PM). With that said, our DBAs working o nthe project have increased the Undo_Retention settings and assure us that shouldn't be the problem. Odd thing is, this never happened in the dev environment when we were developing/testing - only in the production environment once it got migrated.
    I am looking for possible causes and possible solutions to the ORA-01555 error. A sample of the code in my procedure is below:
    CREATE OR REPLACE PROCEDURE Ar_Mviews IS
    V_FAILURES NUMBER := 0;
    BEGIN
    BEGIN
              SELECT FAILURES INTO V_FAILURES FROM USER_JOBS WHERE SCHEMA_USER = 'CATEBS' AND WHAT LIKE '%DISCO_MVIEWS%';
              IF V_FAILURES = 1 THEN NULL;
              ELSE
    DBMS_MVIEW.REFRESH ('AR_BATCH_RECEIPTS_V', 'C');
              DBMS_OUTPUT.PUT_LINE(V_FAILURES); END IF;
    END;
    BEGIN
         SELECT FAILURES INTO V_FAILURES FROM USER_JOBS WHERE SCHEMA_USER = 'CATEBS' AND WHAT LIKE '%DISCO_MVIEWS%';
              IF V_FAILURES = 1 THEN NULL;
              ELSE
    DBMS_MVIEW.REFRESH ('AR_BATCHES_ALL_V', 'C');
              DBMS_OUTPUT.PUT_LINE(V_FAILURES); END IF;
    END;
    END Ar_Mviews;
    ---------------------------------------------------------------------------------------------------------------

    We are doing complete refreshes and doing it that way for consistency in the data presented. Because some materialized views are dependent upon data in other materialized views, we have them ordered in a procedure so that when one finishes, the next starts and they are also in a specific order as to ensure accurate data.
    The condition for v_failures is done so that the job doesn't get, lets say, 90% finished and hit an error and start over again. We do the IF statement which results in NULL (do nothing) so that the job doesn't repeat itself over and over again. If one MV fails, we have to consider the job a failure and do nothing else because the one MV that failed may have been a dependency of another MV down the line. (i.e. MV7 calls MV3 and MV3 fails, so the whole job fails because MV7 can't be accurate without the most current data from MV3).
    As well, this is being performed in off-business hours after backup to tape, etc. and prior to start of business so that no one is using the system when we run this job. That won't always be the case when we move to high availability with this system for varying time-zone end-users.
    I hope I have answered your question and look forward to continued feedback.
    Thanks!

  • Spatial query on view to another schema

    Hi,
    I am getting the following error on this query :
    select ufi from cadastre where
    sdo_filter(geometry,
    mdsys.sdo_geometry(2003,8311,NULL,
    sdo_elem_info_array(1,1003,3),
    sdo_ordinate_array(130.967,-12.510,131.000,-12.486))) = 'TRUE';
    ORA-13226: interface not supported without a spatial index
    Cadastre is a view of a table stored in another schema.
    This query works :
    select ufi from sdo_owner.parcel where
    sdo_filter(geometry,
    mdsys.sdo_geometry(2003,8311,NULL,
    sdo_elem_info_array(1,1003,3),
    sdo_ordinate_array(130.967,-12.510,131.000,-12.486))) = 'TRUE';
    I have an entry in user_sdo_geom_metadata for CADASTRE , do i also need an entry in user_sdo_index_info for the query to work.
    Does any one have any ideas ?
    James

    Dan,
    I have worked out why it happens. We have a parcel table that is made up of polygons and points. The points are parcel's that have no legal boundary or survey boundary, just a point where a house might be located.
    What i had forgotten was that i had created a function to convert these points into a polygon on the fly. This buffer function is called from the view.
    example
    create view cadastre
    as
    select
    ufi,
    parcel_key,
    buffer(geometry) "GEOMETRY"
    from sdo_owner.parcel;
    I am guessing that because the geometry is no longer geometry from a table but created geometry it does not have a spatial index associated with it.
    Here is the buffer function
    CREATE OR REPLACE FUNCTION buffer
    geometry MDSYS.SDO_GEOMETRY,
    layer_name VARCHAR2
    RETURN MDSYS.SDO_GEOMETRY
    AS
    temp_geom MDSYS.SDO_GEOMETRY;
    diminfo MDSYS.SDO_DIM_ARRAY;
    start_x FLOAT;
    start_y FLOAT;
    end_x FLOAT;
    end_y FLOAT;
    BEGIN
    SELECT u.diminfo INTO diminfo
    FROM user_sdo_geom_metadata u
    WHERE u.table_name = UPPER(layer_name);
    IF geometry.GET_GTYPE() = 1 THEN
    temp_geom := sdo_geom.sdo_buffer(geometry,diminfo,4,'units=m arc_tolerance=0.005');
    return temp_geom;
    END IF;
    IF geometry.GET_GTYPE() = 2 THEN
    temp_geom := sdo_geom.sdo_buffer(geometry,diminfo,4,'units=m arc_tolerance=0.005');
    RETURN temp_geom;
    END IF;
    IF geometry.GET_GTYPE() = 6 THEN
    temp_geom := sdo_geom.sdo_buffer(geometry,diminfo,4,'units=m arc_tolerance=0.005');
    RETURN temp_geom;
    END IF;
    RETURN geometry;
    END;
    James

  • Improving performance of query with View

    Hi ,
    I'm working on a stored procedure where certain records have to be eleminated , unfortunately tables involved in this exception query are present in a different database which will lead to performance issue. Is there any way in SQL Server to store this query
    in a view and store it's execution plan and make it work like sp.While I beleive it's kinda crazy thought but is there any better way to improve performance of query when accessed across databases.
    Thanks,
    Vishal.

    Do not try to solve problems that you have not yet confirmed to exist.  There is no general reason why a query (regardless of whether it involves a view) that refers to a table in a different database (NB - DATABASE not INSTANCE) will perform poorly. 
    As a suggestion, write a working query using a duplicate of the table in the current database.  Once it is working, then worry about performance.  Once that is working as efficiently as it can , change the query to use the "remote" table rather
    than the duplicate. Then determine if you have an issue.  If you cannot get the level of performance you desire with a local table, then you most likely have a much larger issue to address.  In that case, perhaps you need to change your perspective
    and approach to accomplishing your goal. 

  • Undocumented error number when doing Spatial Query

    Can anyone tell me why I get these errors?
    ERROR at line 1:
    ORA-29902: error in executing ODCIIndexStart() routine
    ORA-13236: internal error in R-tree processing: [failed to allocate memory]
    ORA-06512: at "MDSYS.SDO_INDEX_METHOD", line 83
    ORA-06512: at line 1
    This is the query that was ran:
    SELECT DISTANCE FROM DIST_PTS
    WHERE (CLLI = 'CHCGILCL') AND (MDSYS.SDO_NN (GEOLOC,
    MDSYS.SDO_GEOMETRY (2001, NULL,
    MDSYS.SDO_POINT_TYPE (-87.63804626464844, 41.879520416259766, NULL),
    NULL, NULL), 'SDO_NUM_RES=1') = 'TRUE').
    I am using 8.1.6 and the error number ORA-13236 doesn't appear to be documented. I have tried reindexing the spatial indexes but to no avail.
    Thanks
    Bryan
    null

    Hi,
    R-tree indexes were field test in 8.1.6. The error you are seeing doesn't look familiar in terms of fixes that were made for the first production ship in 8.1.7.
    You should try upgrading, and it should be fine.
    dan

  • Error ORA-29900 when tuning spatial sql statement for tuning task

    I am trying to tune a SQL statement and getting ORA-29900: operating binding does not exist and PLS-306 wrong number of arguments in call to SDO_FILTER. Oracle Version 11.1.
    Query trying to tune:
    Select ROUTE_LINK_ID,ROUTE_ID,ROUTE_SYSTEM_ID,ROUTE_SYSTEM_NAME,ASSIGNED_ROUTES_ID,
    GEOGRAPHIC_EXTENT_ID,GEOGRAPHIC_EXTENT_NAME,ROUTE_NAME,ROUTE_DIRECTION,FULL_NAME,
    OFFICIAL_NAME,ROUTE_LINK_ID,ORDINAL,DISTANCE,RELATIVE_DIRECTION,TRANSPORT_LINK_ID,
    GEOMETRY_GA_TW From IDOTLRS.ROUTE_DETAIL A where (ROUTE_SYSTEM_ID=8) AND
    MDSYS.SDO_FILTER(A.GEOMETRY_GA_TW, :GeometryFilter, 'querytype=window') = 'TRUE';
    Example query with bind variable populated:
    Select ROUTE_LINK_ID,ROUTE_ID,ROUTE_SYSTEM_ID,ROUTE_SYSTEM_NAME,ASSIGNED_ROUTES_ID,
    GEOGRAPHIC_EXTENT_ID,GEOGRAPHIC_EXTENT_NAME,ROUTE_NAME,ROUTE_DIRECTION,FULL_NAME,
    OFFICIAL_NAME,ROUTE_LINK_ID,ORDINAL,DISTANCE,RELATIVE_DIRECTION,TRANSPORT_LINK_ID,
    GEOMETRY_GA_TW From IDOTLRS.ROUTE_DETAIL A where (ROUTE_SYSTEM_ID=1) AND
    MDSYS.SDO_FILTER(A.GEOMETRY_GA_TW, SDO_GEOMETRY (2003, 1050010, NULL, sdo_elem_info_array (1, 1003, 3), sdo_ordinate_array (288325, 222066, 326949, 245295 )), 'querytype=window') = 'TRUE';
    --Tuning Task that throws error ORA-29900
    DECLARE
    my_task_name VARCHAR2(30);
    my_sqltext CLOB;
    BEGIN
    GeometryFilter := 'MDSYS.SDO_GEOMETRY(2003,1050010,NULL,MDSYS.sdo_elem_info_array(1,1003,3),mdsys.sdo_ordinate_array(288325,222066,326949,245295))';
    my_sqltext := 'Select ROUTE_LINK_ID,ROUTE_ID,ROUTE_SYSTEM_ID,ROUTE_SYSTEM_NAME,ASSIGNED_ROUTES_ID, GEOGRAPHIC_EXTENT_ID,GEOGRAPHIC_EXTENT_NAME,ROUTE_NAME,ROUTE_DIRECTION,FULL_NAME, OFFICIAL_NAME,ROUTE_LINK_ID,ORDINAL,DISTANCE,RELATIVE_DIRECTION,TRANSPORT_LINK_ID,GEOMETRY_GA_TW From IDOTLRS.ROUTE_DETAIL A where (ROUTE_SYSTEM_ID=1) AND MDSYS.SDO_FILTER(A.GEOMETRY_GA_TW, :GeometryFilter,''MASK=INSIDE'') = ''TRUE'' ';
    my_task_name := DBMS_SQLTUNE.CREATE_TUNING_TASK(
    sql_text => my_sqltext,
    bind_list => sql_binds(anyData.convertChar('MDSYS.SDO_GEOMETRY(2003,1050010,NULL,MDSYS.sdo_elem_info_array(1,1003,3),mdsys.sdo_ordinate_array(288325,222066,326949,245295))')),
    user_name => 'IDOTLRS',
    scope => 'COMPREHENSIVE',
    time_limit => 240,
    task_name => 'lrs_tuning_task_27',
    description => 'Task to tune a query on delete');
    END;
    BEGIN
    DBMS_SQLTUNE.EXECUTE_TUNING_TASK( task_name => 'lrs_tuning_task_27' );
    END;
    any advice would be appreciated to get the tuning task functioning.
    thanks in advance.

    convertObject allowed EXECUTE_TUNING_TASK to run, but stops with an end of file communication. I need to look and see why.
    ORA-03113: end-of-file on communication channel
    Process ID: 4676
    Session ID: 510 Serial number: 60166
    I will try the other option and see what happens.
    Will file a bug....
    Edited by: Eric Abrams on Sep 27, 2011 7:33 AM
    Appears to be logged.
    ORA-03113 reported when Enequeueing an ADT which contains a SYS.ANYDATA type [ID 799393.1], unpublished Bug 6830995
    Edited by: Eric Abrams on Sep 27, 2011 7:41 AM
    Edited by: Eric Abrams on Sep 27, 2011 7:42 AM

  • Performance of query using view - what is happening here

    Hi,
    I can't explain the difference in performance between two queeries.
    For a datawarehouse I have 3 tables from 3 different sources, named source1, source2 and
    source3 they all have the identical columns:
    client_key
    ,client_revenue
    source1 has 90.000.000 rows, source2 1.000.000 rows and source3 50.000 rows
    I also made a view say, all_clients which is the union of the 3 tables plus a constant column called 'source'
    which corresponds to the table_name.
    If I run a query which shows the number of records it takes 15-20 minutes:
    select source,count(*)
    from all_clients
    group by source.
    If i run the following query it takes about 5 minutes!
    select 'source1',count(*)
    from source1
    union
    select 'source2',count(*)
    from source2
    union
    select 'source3',count(*)
    from source3.
    What makes the difference?

    Hmmm... Interesting. In my small example things seem pretty similar. Have you done the explain plans?
    An observation is that you are using a UNION rather than a UNION ALL which would be better as you may be incurring an unnecessary SORT UNIQUE.
    create table tab1 as(select object_id, object_type from all_objects);
    create table tab2 as(select object_id, object_type from all_objects);
    create table tab3 as(select object_id, object_type from all_objects);
    analyze table tab1 estimate statistics;
    analyze table tab2 estimate statistics;
    analyze table tab3 estimate statistics;
    create view v_tab123 as(select 'source1' source,count(*) cnt
    from tab1
    union
    select 'source2',count(*)
    from tab2
    union
    select 'source3',count(*)
    from tab3);
    select 'source1' source,count(*) cnt
    from tab1
    union
    select 'source2',count(*)
    from tab2
    union
    select 'source3',count(*)
    from tab3;
    Operation     Object Name     Rows     Bytes     Cost     TQ     In/Out     PStart     PStop
    SELECT STATEMENT Hint=CHOOSE          3           180                     
    SORT UNIQUE          3           180                     
    UNION-ALL                                        
    SORT AGGREGATE          1           60                     
    TABLE ACCESS FULL     TAB1     38 K          10                     
    SORT AGGREGATE          1           60                     
    TABLE ACCESS FULL     TAB2     38 K          10                     
    SORT AGGREGATE          1           60                     
    TABLE ACCESS FULL     TAB3     38 K          10                     
    -- Union
    select source, cnt from(
    select 'source1' source,count(*) cnt
    from tab1
    union
    select 'source2',count(*)
    from tab2
    union
    select 'source3',count(*)
    from tab3)
    Operation     Object Name     Rows     Bytes     Cost     TQ     In/Out     PStart     PStop
    SELECT STATEMENT Hint=CHOOSE          3           180                     
    VIEW          3      54      180                     
    SORT UNIQUE          3           180                     
    UNION-ALL                                        
    SORT AGGREGATE          1           60                     
    TABLE ACCESS FULL     TAB1     38 K          10                     
    SORT AGGREGATE          1           60                     
    TABLE ACCESS FULL     TAB2     38 K          10                     
    SORT AGGREGATE          1           60                     
    TABLE ACCESS FULL     TAB3     38 K          10                     
    -- Union ALL
    select source, cnt from(
    select 'source1' source,count(*) cnt
    from tab1
    union ALL
    select 'source2',count(*)
    from tab2
    union ALL
    select 'source3',count(*)
    from tab3)
    Operation     Object Name     Rows     Bytes     Cost     TQ     In/Out     PStart     PStop
    SELECT STATEMENT Hint=CHOOSE          3           180                     
    VIEW          3      54      180                     
    SORT UNIQUE          3           180      <<<<============== Unnecessary           
    UNION-ALL                                        
    SORT AGGREGATE          1           60                     
    TABLE ACCESS FULL     TAB1     38 K          10                     
    SORT AGGREGATE          1           60                     
    TABLE ACCESS FULL     TAB2     38 K          10                     
    SORT AGGREGATE          1           60                     
    TABLE ACCESS FULL     TAB3     38 K          10                     
    analyze table tab1 delete statistics;
    analyze table tab2 delete statistics;
    analyze table tab3 delete statistics;
    Now with RBO - the SORT UNIQUE goes away for the above query.
    Operation     Object Name     Rows     Bytes     Cost     TQ     In/Out     PStart     PStop
    SELECT STATEMENT Hint=CHOOSE                                        
    VIEW                                        
    UNION-ALL                                        
    SORT AGGREGATE                                        
    TABLE ACCESS FULL     TAB1                                   
    SORT AGGREGATE                                        
    TABLE ACCESS FULL     TAB2                                   
    SORT AGGREGATE                                        
    TABLE ACCESS FULL     TAB3                                   

  • ORA-25175 when trying to create materialized view, organization index SOLV

    Hi,
    I'm trying to create a materialized view to compensate for non-normalized table.
    I have table anormal, and mv is to be on distinct agency, company in that table.
    Here goes:
    SQL> select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bi
    PL/SQL Release 10.2.0.3.0 - Production
    CORE    10.2.0.3.0      Production
    TNS for IBM/AIX RISC System/6000: Version 10.2.0.3.0 - Productio
    NLSRTL Version 10.2.0.3.0 - Production
    SQL> create table anormal (company varchar2(8) not null
      2                       ,dept varchar2(8) not null
      3                       ,agency varchar2(8) not null
      4                       ,constraint anormal_pk primary key (company,dept));
    Table created.
    SQL> insert into anormal values('c1', 1, 'Ajax');
    1 row created.
    SQL> insert into anormal values('c1', 2, 'Ajax');
    1 row created.
    SQL> insert into anormal values('c1', 3, 'Acme');
    1 row created.
    SQL> insert into anormal values('c2', 1, 'Acme');
    1 row created.
    SQL> insert into anormal values('c2', 2, 'Acme');
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> select * from anormal;
    COMPANY  DEPT     AGENCY
    c1       1        Ajax
    c1       2        Ajax
    c1       3        Acme
    c2       1        Acme
    c2       2        Acme
    SQL> create materialized view agency_comp_mv
      2  organization index --primary key (agency, company)
      3  build deferred
      4  refresh on demand
      5  as
      6  select distinct agency, company from anormal
      7  /
    select distinct agency, company from anormal
    ERROR at line 6:
    ORA-25175: no PRIMARY KEY constraint found
    SQL>The error tells me that there is no primary key, but is there any way to add such?
    - or is my problem rather that I cannot use DISTINCT with organization index?
    Regards
    Peter
    bump
    Message was edited by:
    Peter Gjelstrup
    <SOLVED>
    Message was edited by:
    Peter Gjelstrup

    Thanks William,
    I tried with ON PREBUILT TABLE, just to see what happens.
    Building on my OP:
    SQL> create table iot(agency varchar2(8) not null, company varchar2(8) not null
      2                  ,constraint iot_pk primary key (agency,company))
      3  organization index;
    Table created.
    SQL> insert into iot select distinct agency, company from anormal;
    4 rows created.
    SQL> commit;
    Commit complete.
    SQL> create materialized view iot on prebuilt table
      2  as
      3  select distinct agency, company from anormal;
    Materialized view created.
    SQL> select * from iot;
    AGENCY   COMPANY
    Acme     c1
    Acme     c2
    Ajax     c1
    SQL> insert into anormal values('c3', 2, 'Foo');
    insert into anormal values('c3', 2, 'Foo')
    1 row created
    SQL> select * from anormal;
    COMPANY  DEPT     AGENCY
    c1       1        Ajax
    c1       2        Ajax
    c1       3        Acme
    c2       1        Acme
    c2       2        Acme
    c3       2        Foo
    6 rows selected.
    SQL> select * from iot;
    AGENCY   COMPANY
    Acme     c1
    Acme     c2
    Ajax     c1
    3 rows selectedNow, try to refresh and MV
    SQL> alter materialized view iot refresh complete;
    Materialized view altered.
    SQL> select object_type, to_char(last_ddl_time, 'hh:mi:ss'), status
      2    from user_objects where object_name = 'IOT';
    OBJECT_TYPE         DDL_TIME STATUS
    TABLE               10:40:42 VALID
    MATERIALIZED VIEW   10:41:13 VALID
    SQL> select * from iot;
    AGENCY   COMPANY
    Acme     c1
    Acme     c2
    Ajax     c1Agency "Foo" is not in MV,
    Looks like that IOT select'ed from is indeed the MV:
    SQL> drop table iot;
    drop table iot
    ERROR at line 1:
    ORA-12083: must use DROP MATERIALIZED VIEW to drop "STIK"."IOT"
    SQL>So, seems that Maxim is right, it just can't be done. And it seems my options are:
    Create HEAP organized MV or
    Create and maintain IOT
    Regards
    Peter

  • ORA-07445 When executing a query.

    Hello,
    I am executing a query that contains a lot of ansi inner join and one left join, whenever I try to execute this query I get an error. By looking at the alert log I can detect the following oracle error
    ORA-07445: encontrada excepção: core dump [kkqstcrf()+1541] [ACCESS_VIOLATION] [ADDR:0x71] [PC:0x4C8E699] [UNABLE_TO_READ] []
    We are using Oracle 11.2.0.1.
    If someone can help me on this, I would appreciate it
    Regards
    Edited by: user2934071 on 21-Jun-2011 06:52

    user2934071 wrote:
    Hello,
    I am executing a query that contains a lot of ansi inner join and one left join, whenever I try to execute this query I get an error. By looking at the alert log I can detect the following oracle error
    ORA-07445: encontrada excepção: core dump [kkqstcrf()+1541] [ACCESS_VIOLATION] [ADDR:0x71] [PC:0x4C8E699] [UNABLE_TO_READ] []
    After some research I have found the following bug description in Metalink:
    Doc ID 9050716.8, Bug 9050716 “Dumps on kkqstcrf with ANSI joins and Join Elimination”, affects Oracle Database release versions below 11.2.0.2
    As we are using Oracle 11.2.0.1, this seems to be what I am looking for. If someone can provide me this document since I do not have a metalink account, I woud appreciate it.
    RegardsDistribution of MetaLink content is a violation of the usage agreement. Anyone providing it would be in violation and at risk of having their contract terminated. The only way to legally get it is to have an account.

  • Ora-07445 When tried to select a view using where clause it got disconnectd

    select * from v_my_view;
    plan group_name plan_id
    plan_one group_one 101
    1 row selected.
    when I tried
    select * from v_my_view where plan_id='101';
    It got disconnected and show to end of communication error
    Current verson of database I am working with is 10.2.0.1.0
    Please help, niether i have metalink access nor I have any patch to install.
    Thanks and Regards in advance,

    First don't create Multiple thread I guess you created 3 thread for the same problem.
    Coming back to your problem did you check your Alert log, is your server running in shared/Dedicated mode whats your OS.

  • Why do i get ORA-03113 when doing a spatial query against union all view?

    Hi, i created the following view
    CREATE OR REPLACE FORCE VIEW cola_markets_v
    AS
      (SELECT mkt_id, NAME, shape shape_a, NULL shape_b, NULL shape_c,
              NULL shape_d
         FROM COLA_MARKETS
        WHERE NAME = 'cola_a')
       UNION ALL
      (SELECT mkt_id, NAME, NULL shape_a, shape shape_b, NULL shape_c,
              NULL shape_d
         FROM COLA_MARKETS
        WHERE NAME = 'cola_b')
       UNION ALL
      (SELECT mkt_id, NAME, NULL shape_a, NULL shape_b, shape shape_c,
              NULL shape_d
         FROM COLA_MARKETS
        WHERE NAME = 'cola_c')
       UNION ALL
      (SELECT mkt_id, NAME, NULL shape_a, NULL shape_b, NULL shape_c,
              shape shape_d
         FROM COLA_MARKETS
        WHERE NAME = 'cola_d');added the necessary entries in USER_SDO_GEOM_METADATA and created a spatial index on COLA_MARKETS (SHAPE). However, when i do a spatial query against this view, i get ORA-03113. A spatial query against the base table works fine. Any ideas why this happens? (This is Oracle 10.2.0.3.0)
    Thanks in advance, Markus
    PS: This is my spatial query
    SELECT *
      FROM cola_markets_v t
    WHERE sdo_filter (t.shape_a,
                             SDO_GEOMETRY (2003,
                                           NULL,
                                           NULL,
                                           sdo_elem_info_array (1, 1003, 3),
                                           sdo_ordinate_array (1, 1, 2, 2)
                             'querytype=window'
                            ) = 'TRUE';

    Thank you for your reply. I have tried it with 11.1.0.6.0 today and it works. This might be an issue with 10.2.0.3.0.

  • Poor performance with Oracle Spatial when spatial query invoked remotely

    Is anyone aware of any problems with Oracle Spatial (10.2.0.4 with patches 6989483 and 7003151 on Red Hat Linux 4) which might explain why a spatial query (SDO_WITHIN_DISTANCE) would perform 20 times worse when it was invoked remotely from another computer (using SQLplus) vs. invoking the very same query from the database server itself (also using SQLplus)?
    Does Oracle Spatial have any known problems with servers which use SAN disk storage? That is the primary difference between a server in which I see this poor performance and another server where the performance is fine.
    Thank you in advance for any thoughts you might share.

    OK, that's clearer.
    Are you sure it is the SQL inside the procedure that is causing the problem? To check, try extracting the SQL from inside the procedure and run it in SQLPLUS with
    set autotrace on
    set timing on
    SELECT ....If the plans and performance are the same then it may be something inside the procedure itself.
    Have you profiled the procedure? Here is an example of how to do it:
    Prompt Firstly, create PL/SQL profiler table
    @$ORACLE_HOME/rdbms/admin/proftab.sql
    Prompt Secondly, use the profiler to gather stats on execution characteristics
    DECLARE
      l_run_num PLS_INTEGER := 1;
      l_max_num PLS_INTEGER := 1;
      v_geom    mdsys.sdo_geometry := mdsys.sdo_geometry(2002,null,null,sdo_elem_info_array(1,2,1),sdo_ordinate_array(0,0,45,45,90,0,135,45,180,0,180,-45,45,-45,0,0));
    BEGIN
      dbms_output.put_line('Start Profiler Result = ' || DBMS_PROFILER.START_PROFILER(run_comment => 'PARALLEL PROFILE'));  -- The comment name can be anything: here it is related to the Parallel procedure I am testing.
      v_geom := Parallel(v_geom,10,0.05,1);  -- Put your procedure call here
      dbms_output.put_line('Stop Profiler Result = ' || DBMS_PROFILER.STOP_PROFILER );
    END;
    SHOW ERRORS
    Prompt Finally, report activity
    COLUMN runid FORMAT 99999
    COLUMN run_comment FORMAT A40
    SELECT runid || ',' || run_date || ',' || run_comment || ',' || run_total_time
      FROM plsql_profiler_runs
      ORDER BY runid;
    COLUMN runid       FORMAT 99999
    COLUMN unit_number FORMAT 99999
    COLUMN unit_type   FORMAT A20
    COLUMN unit_owner  FORMAT A20
    COLUMN text        FORMAT A100
    compute sum label 'Total_Time' of total_time on runid
    break on runid skip 1
    set linesize 200
    SELECT u.runid || ',' ||
           u.unit_name,
           d.line#,
           d.total_occur,
           d.total_time,
           text
    FROM   plsql_profiler_units u
           JOIN plsql_profiler_data d ON u.runid = d.runid
                                         AND
                                         u.unit_number = d.unit_number
           JOIN all_source als ON ( als.owner = 'CODESYS'
                                   AND als.type = u.unit_type
                                   AND als.name = u.unit_name
                                AND als.line = d.line# )
    WHERE  u.runid = (SELECT max(runid) FROM plsql_profiler_runs)
    ORDER BY d.total_time desc;Run the profiler in both environments and see if you can see where the slowdown exists.
    regards
    Simon

  • Spatial query inside the exists clause return ora-13226

    The following does not work:
    select b.state, b.county from counties b where exists
    (select 's' from states a where a.state = 'New Jersey'
    and mdsys.sdo_relate (b.geom, a.geom, 'mask=INSIDE querytype=WINDOW' ) = 'TRUE');
    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 302
    ORA-06512: at line 1
    The following does work:
    select b.* from states a,
    counties b where a.state = 'New Jersey'
    and mdsys.sdo_relate (b.geom, a.geom, 'mask=INSIDE querytype=WINDOW') = 'TRUE';
    I found bug 1243095 telling that this is not a bug but a limitation of the spatial operator. It cannot be invoked on a table that is not spatially indexed. In fact, the table is indexed but oracle cannot find the spatial index because table b(counties) is declared outside the EXISTS clause.
    In my case, I use object table. I cannot use the workaround specified above because I should use the DISTINCT clause but I cannot define the MAP and ORDER function (this is a general query).
    I've found another workaround :
    select b.state, b.county from counties b where exists
    (select 's' from states a where a.state = 'New Jersey'
    and mdsys.sdo_relate (a.geom, b.geom, 'mask=CONTAINS querytype=WINDOW') = 'TRUE');
    but sdo_relate still doesn't use the spatial index of table b (even if I specify it explicitely in the operator) and the query is very slow (more than 15 minutes).
    Is there a better workaround ?

    OK but I work in object model.
    And if I don't use the EXISTS clause, I must use the distinct clause.(I used the exists because of that)
    If I will to retrieve all the country that have at least a state beginning with the C letter, I will wrote :
    select c.* from country c, table(c.states) s where s.column_value.name like 'C%';
    (It is a simplified request to express the problem)
    In this case, I must use the distinct clause to select one occurence of each country objet (one country may contains more than one state beginning with C).
    select distinct c.* from country c, table(c.states) s where s.column_value.name like 'C%';
    For that, I must define a MAP or ORDER function for EACH type used in the country object.
    My first question is : I must retrieve all different country objects. Why the request doesn't use the MAP or ORDER function of the country type to distinct them ? Is there another syntax (or a hint) to express that ?
    In this case, it will make an ORA-00932 : incoherent datatype because the type of the nested table column cannot contain map or order method.
    Any suggestion ?
    Thanks in advance.

  • ORA-21700 Error when running C# stored procedure to do a spatial query

    Hi All
    I'm having trouble running a C# stored procedure that (via another object) that falls over running a spatial query with the following error.
    OAR-21700 object does not exist or is marked for delete
    If I take the sql of the spatial query out and run it separately in SqlPlus it runs as expected.
    If I use the object that executes the spatial query via NUnit (i.e. executed on the client, rather than the server) it also works as expected.
    Can anyone help? Is there some issue using Oracle Spatial queries with the Oracle Database Extensions for .NET?

    I can indeed. Here is a slightly simplified version:
    SELECT secondary_catch.mi_prinx AS primarykey
    FROM mapinfo_data.secondary_catch
    WHERE sdo_relate (secondary_catch.geoloc,
    (SELECT geoloc
    FROM training_6.building_polygons
    WHERE building_id = 10002507117),
    'mask=anyinteract querytype=WINDOW'
    ) = 'TRUE'
    Interestingly, if I attempt to run this query inside a C# stored procedure using the implicit context connection (i.e. OracleConnection.ConnectionString = "context connection=true") it fails with the error I described above.
    If however I create a new connection and connect as a regular user on my database, the query works correctly.
    So in that sense I have a workaround, but I'd like to avoid using it if I can as creating a new explicit connection is an overhead I can do without.

  • How to create spatial query (sdo_relate) on 2 views

    Hi, I want to create a spatial query in the form of:
    select /*+ORDERED*/ column1,column2
    from view1,view2
    where sdo_relate(view2.geometry,view1.geometry,'mask= ... ')Both views are very fast and return a smal number of rows out of a large dataset. I would expect that running the spatial query on this selection should be fast but when performing the above query it takes quite some time.
    It seems that the spatial query is performed on the underlying tables before the views make their selection.
    What is a good way to handle this kind of problem? How to make the spatial query to be executed on the resultset of the views?
    thanks Rene

    Hi Udo,
    Let me tell you a bit more about the requirements of the application.
    We have a table with geometries. Some geometries are buildings, others are roads, trees, parking areas, etc.
    We let users specify what geometries they are interested in. This can be the type (tree, building) or a list of types, plus some other selection such as type of tree, name of road etc. Based on the specifications the application creates a view that returns exactly the geometries the user is interested in.
    Users may not only be interested in just a tree but may be looking for a tree located inside a building, or a building within a certain distance from a road. This then would be the query I am talking about in this post. Two views and a spatial relationship between them.
    Depending on the definition of the views and the data currently loaded the number of rows returned by the views will vary. I can't be there all the time making sure that the correct table is queried first and the correct hints are given. This is why we have the CBO. But it seems to do a poor job when it comes to spatial queries.
    Rene

Maybe you are looking for

  • Camera and photo booth is disappeared

    Camera and photo booth is disappeared

  • Function keys are not working?

    hi all i am using dv-10G(10-1...) can anyone guide me how we can use our desire keys in forms. example For commit form my function keys should be look like this. commit form-----F10 Execute Query...........F11 etc plz help me sarah

  • Ineed on add-on for php api files

    to view and open php api files

  • MX LB / HA / Cluster ESA 380

    We go to deploy our new ESA (2 devices) as per mentioned below plan, ESA01 is primary for company A and ESA02 is primary for company B. If ESA01 is down ESA02 will receive mail for company A using MX load balance. The same method for company B. We ar

  • How to upgade to 4.1.1?

    I've got 3.0.5 on my computer and when I do a version check, it says that is the latest. I'm running OSX 10.5. Am I missing something? Thanks in advance!