是否可以在不创建存储过程的情况下在 SQL 中使用循环?

Wil*_*son 2 oracle stored-procedures spatial update

我想循环遍历用户定义数据类型(ESRI 版本)中 SHAPE/GEOMETRY 列中的顶点ST_GEOMETRY。我已在 GIS SE 帖子中发布了详细信息:Update sde.st_geometry M value tocumulative distance (geometric length)

我认为这通常会在存储过程中完成(可能与sde.ST_GEOMETRY函数ST_NumPointsand结合使用ST_PointN)。但是,我没有CREATE PROCEDURE权限,所以无法创建存储过程。

作为创建存储过程的替代方法,是否有一种方法可以使用 SQL 语句来循环遍历顶点?

Oracle 12c (12.1.0.2.0)

小智 6

您可以将 pl/sql 放入匿名块中。像这样的事情可能会有所帮助:

declare
  v_vertices  your_user_defined_data_type;

  cursor your_cursor_c
  is
    select vertices
    from   your_table
    where  your_column = 'A VALUE';

begin
    open your_cursor_c;
    loop
      fetch your_cursor_c
      into  v_vertices;
      exit when your_cursor_c%notfound;

      ST_NumPoints(v_vertices);
      ST_PointN(v_vertices);

      commit;
    end loop;
end;
Run Code Online (Sandbox Code Playgroud)

另外,对于 12c,您还可以执行一些内联​​过程/函数操作。不确定是否有必要,但这里有一个链接: https: //oracle-base.com/articles/12c/with-clause-enhancements-12cr1