以下查询在通过 db2 命令从控制台运行时有效。但是通过 DBeaver 运行时失败。
BEGIN NOT ATOMIC
FOR R AS C CURSOR WITH HOLD FOR
SELECT ROW_NUMBER() OVER() AS INDEX, ID
FROM A_TABLE a
WHERE a.ID BETWEEN 1 AND 1000
ORDER BY a.ID
DO
UPDATE A_TABLE SET A_COL = 1 WHERE ID = R.ID;--
IF MOD(R.INDEX, 100) = 0 THEN
COMMIT;--
END IF;--
END FOR;--
COMMIT;--
END;
DBeaver 给出以下结果
SQL 错误 [42601]:在“WHERE ID = R.ID”之后发现了意外的标记“END-OF-STATEMENT”。预期的标记可能包括:“<psm_semicolon>”.. SQLCODE=-104, SQLSTATE=42601, DRIVER=4.26.14