Unable to create spatial index due to ORA-29855 with nested ORA-13203:failed to read USER_SDO_GEOM_METADATA view

415 views Asked by At

I'm new to Oracle Spatial and I've been having some issues with creating a spatial index in Oracle Database 19c. When trying to create the index I keep getting:

SQL Error [29855] [99999]: ORA-29855: error occurred in the execution of ODCIINDEXCREATE routine

ORA-13203: failed to read USER_SDO_GEOM_METADATA view

ORA-13203: failed to read USER_SDO_GEOM_METADATA view

ORA-06512: at "MDSYS.SDO_INDEX_METHOD_10I", line 10

Even though I get this error, the index is created under the table but I'm unable to do any spatial related operation because the state is invalid.
I've tried with multiple data samples, SRID and geometries (Point, line, polygon) and with 2 or 3 dimension data and indexes. However, nothing works.

This is how i created the table, added data, inserted the metadata and tried to create the index:

--Create the table
CREATE TABLE MY_SPATIAL_TABLE (
  ID NUMBER PRIMARY KEY,
  GEOMETRY SDO_GEOMETRY --tried with MDSYS.SDO_GEOMETRY too
);

--Insert sample data
INSERT INTO MY_SPATIAL_TABLE VALUES (
  1,
  SDO_GEOMETRY(
    3001, 
    NULL,
    SDO_POINT_TYPE(4, 6, 2),
    NULL,
    NULL
  )
);

--Insert the metadata into USER_SDO_GEOM_METADATA
INSERT INTO USER_SDO_GEOM_METADATA (TABLE_NAME, COLUMN_NAME, DIMINFO, SRID)
VALUES (
  'MY_SPATIAL_TABLE',
  'GEOMETRY',
  SDO_DIM_ARRAY(
    SDO_DIM_ELEMENT('X', -180, 180, 0.5),
    SDO_DIM_ELEMENT('Y', -90, 90, 0.5),
    SDO_DIM_ELEMENT('Z', -10000, 10000, 0.5)
  ),
  NULL
);

--Create the index
CREATE INDEX MY_SPATIAL_INDEX ON MY_SPATIAL_TABLE (GEOMETRY)
INDEXTYPE IS MDSYS.SPATIAL_INDEX; --Also tried MDSYS.SPATIAL_INDEX_V2

These are some of the reasons I checked that are not the cause of the problem in my case:

  • I've seen this error usually happens when the metadata is not inserted correctly, however I have checked that it exist using:

    SELECT * FROM USER_SDO_GEOM_METADATA WHERE TABLE_NAME = 'MY_SPATIAL_TABLE' AND COLUMN_NAME = 'GEOMETRY';
    

    The result of the query, where you can check the row has been created

  • I followed this lab created by Oracle to create sample data. All of the steps worked fine, but when I tried to create the index the same happened.

  • As said in this question i checked that my column and table names where not the problem, but as you can see all of them are in uppercase to avoid this problem.

Thanks in advance and I hope that my question is well presented, If you need any details let me know.

0

There are 0 answers