【发布时间】:2019-09-07 10:00:40
【问题描述】:
我正在使用带有 oracle 空间的 oracle 11g,如果我在 where 条件中使用如下距离,则此查询有效
mdsys.sdo_nn ( b1.location, l_location , 'SDO_BATCH_SIZE=100 distance='||
c1.tier_radius||' unit=KM', 1) = 'TRUE'
但是我希望根据条件评估距离。下面的查询给出了错误 sdo_nn 无法在没有索引的情况下进行评估,我希望根据类似这样的条件评估距离
select
/*+ first_rows LEADING(c) USE_NL(c1 b1) INDEX(b1 BRANCH_LOCATION_SPIX)*/
b1.BRANCH_ID,
mdsys.sdo_nn_distance(1) branchDistance
from
branch b1, city c1
where
mdsys.sdo_nn ( b1.location, l_location , 'SDO_BATCH_SIZE=100 distance='|| (case when b1.restaurant_id not in (3970,3971,3972) then c1.tier_radius
else 15 end) ||' unit=KM', 1) = 'TRUE'
and b1.city_id = c1.city_id
【问题讨论】:
-
查询是否适用于此?
mdsys.sdo_nn ( b1.location, l_location , 'SDO_BATCH_SIZE=100 distance=15 unit=KM', 1) = 'TRUE'?