If I run the following query:
select B3.bid as id ,B3.bshape as shape
from Buildings B3
where B3.bid in
(
select distinct B1.bid from Buildings B1,
(
select * from Buildings B where B.bname in (select BOF.bname from Buildings_On_Fire BOF)
) B2 where sdo_nn(B1.bshape, B2.bshape, 'distance=100') = 'TRUE' and B1.bname != b2.bname
)
I receive following errors:
ERROR at line 1:
ORA-13249: SDO_NN cannot be evaluated without using index
ORA-06512: at "MDSYS.MD", line 1723
ORA-06512: at "MDSYS.MDERR", line 17
ORA-06512: at "MDSYS.PRVT_IDX", line 9
However if just run the following subquery:
select distinct B1.bid from Buildings B1,
(
select * from Buildings B where B.bname in (select BOF.bname from Buildings_On_Fire BOF)
) B2 where sdo_nn(B1.bshape, B2.bshape, 'distance=100') = 'TRUE' and B1.bname != b2.bname
This executed fine. I have verified the spatial index, they seems to be valid.
I am new to oracle and have no idea what to do next. please help.
If there is solution which doesn't require changing the above query, that would be best.