0

嗨,我需要从我的 Oracle 表中获取几何坐标。目前我使用

 (select column_value 
    from (
           select rownum r, 
                  b.* 
            from table(
                       select h.geometry.sdo_ordinates 
                        from hz_locations h 
                       where location_id =
                             (select location_id 
                                from csf_ct_tasks 
                               where task_id = p_task_id)
                       ) b
          )    -- location_id = 973,  task_id = 36420   

   where r =1) as latitude,


  (select column_value 
     from (
           select rownum r, 
                  b.* 
             from table(
                        select h.geometry.sdo_ordinates 
                          from hz_locations h 
                         where location_id =  
                               (select location_id 
                                  from csf_ct_tasks 
                                 where task_id = p_task_id)
                         ) b
            ) 

   where r =2) as longitude

这里p_task_id是用来获取特定纬度、经度的一个任务。但我需要通过在外部查询中指定用户 ID 来获取单个用户的纬度、经度列表。是否可以重写我的查询。

我的实际选择语句是

SELECT all h.location_id,
       h.address1,
       h.address2,
       h.address3,
       h.address4,
       h.house_number,
       h.street_suffix,
       h.apartment_number,
       h.street,
       h.po_box_number,
       h.city,
       h.state,
       h.province,
       h.county,
       h.country,
       h.postal_code as customer_address
  from hz_locations h,
       csf_ct_tasks ct 
 where h.location_id = ct.location_id 
   and ct.owner_id = 10180

提前致谢。

![表格中经纬度存储的示例响应][2]

实际表数据

4

1 回答 1

1

尝试这个

WITH DATASET
    AS (SELECT
             CT.OWNER_ID OWNER_ID,
             ROWNUM R,
             H.GEOMETRY.SDO_ORDINATES VALUE
        FROM
             HZ_LOCATIONS H,
             CSF_CT_TASKS CT
        WHERE
             H.LOCATION_ID = CT.LOCATION_ID
             AND CT.OWNER_ID = 10180)
SELECT
      OWNER_ID,
      REGEXP_REPLACE ( VALUE,
                    '^([^,]*).*$',
                    '\1' )
          AS LAT,
      REGEXP_REPLACE ( VALUE,
                    '^[^,]*,|([^,]*).*$',
                    '\1' )
          AS LON
FROM
      DATASET
WHERE
      ROWNUM = 1;
于 2013-09-23T09:04:10.643 回答