数据类型不一致:预期的游标获得CLOB

wtzytmuj  于 2022-10-04  发布在  Oracle
关注(0)|答案(1)|浏览(171)

在将这段代码编译为Oracle存储的过程时,我收到错误“不一致的数据类型:期望的游标得到CLOB”。我不知道如何将CLOB变量放入输出游标中。

CREATE OR REPLACE PROCEDURE sp_getPolygon 
(
    CityId IN INT,
    Out_CUR OUT SYS_REFCURSOR
) AS 
BEGIN
DECLARE
  cola_b_geom SDO_GEOMETRY;
  returned_json CLOB;
    BEGIN
    open Out_CUR for
        With cte as(SELECT GEOMETRY FROM GISBRANCHES WHERE "FBranchesId" IN (SELECT "Id" FROM "CreBranches" WHERE "FCitiesId" = CityId))
        SELECT GEOMETRY into cola_b_geom FROM cte;
        returned_json := SDO_UTIL.TO_GEOJSON(cola_b_geom);
        --dbms_output.put_line( returned_json );
        SELECT returned_json into Out_CUR FROM DUAL;
    END;
END sp_getPolygon;
fnvucqvd

fnvucqvd1#

不完全是这样;我不能测试它,因为我没有您的表,但是-程序应该是这样的:

CREATE OR REPLACE PROCEDURE sp_getpolygon 
(
    cityid  IN  INT,
    out_cur OUT SYS_REFCURSOR
) AS 
  returned_json CLOB;
BEGIN
  OPEN out_cur FOR
    WITH cte AS
        (SELECT geometry 
         FROM gisbranches 
         WHERE "fbranchesid" IN (SELECT "id" 
                                 FROM "crebranches" 
                                 WHERE "fcitiesid" = cityid
                                )
        )
  SELECT sdo_util.to_geojson (geometry) as geometry_out  
  FROM cte;
END sp_getpolygon;

相关问题