我有一个非常复杂的查询,其中包含一个“With”子句。在 DB2 Client 上执行该查询时可以正常工作。但是,如果在 PL SQL 存储过程的 For 循环游标内使用相同的查询,则它不起作用。在尝试将存储过程应用于数据库时,它会给出如下所示的语法错误。
SQL0104N An unexpected token "AS" was found following "col5 )
for 循环如下图所示。
FOR records AS cursors CURSOR FOR
(
WITH
temp1
(
col1, col2, col3, col4, col5
)
AS
(
SELECT
col1, col2, col3, col4, col5
FROM
table1
)
WITH
temp2
(
col6, col7, col8, col9, col10
)
AS
(
SELECT
col6, col7, col8, col9, col10
FROM
table2
)
SELECT col1, col2, col3, col4, col5, col6, co7, col8, col9, col10
FROM temp1, temp2
)
DO
-- Do Something here.
END FOR;
你能帮忙解决这个问题吗?提前致谢。