DB2将with子句的结果赋给变量

vhmi4jdf  于 2023-01-13  发布在  DB2
关注(0)|答案(1)|浏览(193)

我正在使用DB2 LUW,并希望将With子句的结果赋给存储过程中的变量。
我得到了例外

{0:0} An unexpected token "AS" was found following "l = (WITH BASE".  Expected tokens may include:  "JOIN".. SQLCODE=-104, SQLSTATE=42601, DRIVER=4.28.11

是否可以用这种方式指定结果,或者我必须用光标来求解它?

DECLARE result CLOB(8M); 
SET result = (WITH BASE AS ( 
xxx
) 
SELECT JSON_ARRAY (select json_objects FROM ITEMS format json) FROM SYSIBM.SYSDUMMY1);
jei2mxaa

jei2mxaa1#

请改用以下语法样式:
with ctename AS ( ... ) SELECT ... INTO ... FROM ctename;

相关问题