我在db2中运行此查询:
with closure (obj_1, obj_2) as (SELECT distinct t.obj_1, t.obj_2 FROM temp4 t
UNION ALL SELECT c.obj_1, t.obj_2 FROM closure c, temp4 t WHERE c.obj_2=t.obj_1)
我一直收到此错误,我不确定如何修复它,因为意外的令牌是预期的令牌?:
SQL0104N An unexpected token ")" was found following "HERE c.obj_2=t.obj_1".
Expected tokens may include: ")". SQLSTATE=42601
答案 0 :(得分:0)
您只使用通用表格表达式(CTE) - 缺少CTE的SELECT(除了D Stanley的评论。
请查看以下内容:
with closure (obj_1, obj_2) as (
SELECT distinct t.obj_1, t.obj_2
FROM temp4 t
UNION ALL
SELECT c.obj_1, t.obj_2
FROM closure c, temp4 t
WHERE c.obj_2=t.obj_1)
SELECT * FROM closure