代码之家  ›  专栏  ›  技术社区  ›  Stepan

Oracle12 sdo_nn无法返回最短距离对象

  •  0
  • Stepan  · 技术社区  · 7 年前

    我有一张桌子 NODES RESTAURANTS 用他们的 GEOLOC 和坐标。

    select n.geoloc.sdo_point.y as node_y, n.geoloc.sdo_point.x as node_x,
    r.state as r_state, r.geoloc.sdo_point.y as r_y, r.geoloc.sdo_point.x as r_x,
    sdo_nn_distance(1)  as distance_mi
    from   DC_NODE n,  RESTAURANTS r
    where   sdo_nn (n.geoloc, r.geoloc, 'Unit = MILE sdo_num_res = 1',1) ='TRUE'
    
    NODE_Y NODE_X   R_state  R_Y   R_X   distance_mi
    38.      -77.       AK   56.  -132.  2752.
    

    sdo_nn_distance(1) 和 where sdo_nn(...) 应该将结果集约束到一组节点和相应的最近餐馆。甲骨文似乎忽略了最短距离子句。

        --DC Restaurants are in the table
        select r.STATE, r.geoloc.sdo_point.y as r_y, r.geoloc.sdo_point.x as r_x
          from RESTAURANTS rwhere r.state = 'DC'
    
        DC  38. -77.
        DC  38. -76.
        DC  38. -77.
    

    为什么Oracle忽略了“find the nearest”子句以及如何修复它?

    1 回复  |  直到 7 年前
        1
  •  0
  •   Stepan    7 年前

    更改了参数序列以解决问题
    sdo_nn (from_these_objects_to_choose.geoloc, for_each_of_these_objects.geoloc, 'Unit = MILE sdo_num_res = 1',1) ='TRUE'