我试图使用以下语句更新bplustree表的深度列,该语句在MYSQL上运行良好,但在oracle上我有以下错误:
BEGIN
WHILE EXISTS (SELECT * FROM bplustree WHERE depth IS NULL)
LOOP
UPDATE T SET T.depth = P.depth + 1
FROM bplustree AS T INNER JOIN bplustree AS P
ON (T.parent_node_id = P.node_id)
WHERE P.depth >= 0 AND T.depth IS NULL;
END LOOP;
END;
错误报告- ORA-06550:第4行,第3栏: PL/ SQL : ORA-00933: SQL命令未正确结束 ORA-06550:第3行,第2栏: PL/ SQL :忽略SQL语句 06550。00000 -“行%s,列%s:\n%s” *原因:通常是PL/SQL编译错误。
发布于 2018-01-07 21:50:11
您可以在update
和select
的帮助下组合merge
,如下所示:
MERGE INTO bplustree t1
USING
(
SELECT P.depth + 1 depth, p.node_id
FROM bplustree T INNER JOIN bplustree P
ON (T.parent_node_id = P.node_id)
WHERE P.depth >= 0 AND T.depth IS NULL
) t2
ON ( t1.node_id = t2.node_id )
WHEN MATCHED THEN UPDATE SET
t1.depth = t2.depth;
德梅奥
https://stackoverflow.com/questions/48141339
复制相似问题