从Oracle中的纬度和经度对创建单个GeoJSON值

时间:2019-06-18 23:19:34

标签: oracle geojson sdo

我想将点的纬度和经度值存储为Oracle DB中的GeoJSON格式。我有带有纬度和经度值的SDO_GEOMETRY类型列。我想创建一个GeoJSON格式值,并将该值存储在同一表的另一列中。

我可以使用字符串连接生成下面给出的JSON格式,但是我想知道是否可以使用SDO_UTIL包。 根据Oracle文档https://docs.oracle.com/en/database/oracle/oracle-database/18/spatl/SDO_UTIL-reference.html#GUID-DB459897-729F-41D6-A2F3-DD39F22D8F63,SDO_UTIL.TO_GEOJSON(SDO_GEOMETRY)应该为我提供JASON格式。 以下是我正在尝试的代码示例,但可能是我走错了路!!有人尝试过类似的成功尝试吗?

DECLARE aTst clob;
aTst = SDO_UTIL.TO_GEOJSON(SDO_GEOMETRY(2001, 4326, SDO_POINT_TYPE(latitude, longitude, NULL), NULL, NULL));
select aTst;

给出以下错误:

Error starting at line : 1 in command -
DECLARE aTst clob;
aTst = SDO_UTIL.TO_GEOJSON(SDO_GEOMETRY(2001, 4326, SDO_POINT_TYPE(latitude, longitude, NULL), NULL, NULL));
select aTst;
Error report -
ORA-06550: line 2, column 6:
PLS-00103: Encountered the symbol "=" when expecting one of the following:

   constant exception <an identifier>
   <a double-quoted delimited-identifier> table long double ref
   char time timestamp interval date binary national character
   nchar
ORA-06550: line 2, column 124:
PLS-00103: Encountered the symbol ";" when expecting one of the following:

   . ( ) , * % & - + / at mod remainder rem <an exponent (**)>
   and or || multiset
06550. 00000 -  "line %s, column %s:\n%s"
*Cause:    Usually a PL/SQL compilation error.
*Action:

我的预期结果如下:

{
  "type": "Feature",
  "geometry": {
    "type": "Point",
    "coordinates": [longitude, latitude]
  },
  "properties": {
    "name": "The Place"
  }
}

0 个答案:

没有答案