即使在简单存储过程中,DB2 WITH RETURN也会生成“相同定义中的子句无效”,

xggvc2p6  于 2022-11-07  发布在  DB2
关注(0)|答案(1)|浏览(162)

我现在不知所措,因为即使是最简单的声明,

BEGIN 
        DECLARE rs1 CURSOR WITH RETURN FOR  
            select * from table1;
END

WITH RETURN正在生成一个

SQL Error [42613]: [SQL0628] Clauses not valid in same definition.

文档https://www.ibm.com/docs/en/i/7.3?topic=codes-listing-sql-messages指出:

Clauses specified to define the attributes of a column, a sourced function, a procedure, a trigger, or an index are not valid. One of the following has occurred:

WITH RETURN is specified for a cursor in a compound (dynamic) statement.

如果不将此Select语句视为动态语句,该如何为游标调用它?

n53p2ov0

n53p2ov01#

请参阅documentation
WITH RETURN指定要将游标的结果表用作过程结果集。如果过程的源代码中不包含DECLARE CURSOR语句,则忽略该子句。

相关问题