我们在删除父节点时需要删除子节点,子节点的子节点也要删除,这样就需要循环调用该函数,直到没有子节点的时候。
如下打印出某一节点下的所有子节点
表结构就是一个树形结构的传统结构。
CREATE OR REPLACE
PROCEDURE "DeleteNode" (deleteNodeID IN VARCHAR2)
AS
CURSOR children_cursor IS
SELECT "NodeID" FROM "Organize" WHERE "ParentID" = deleteNodeID;
BEGIN
FOR childIDs IN children_cursor LOOP
--调用本身
declare
BEGIN
SYS."DeleteNode"(childIDs."NodeID");
END;
--调用本身
DBMS_OUTPUT.PUT_LINE(childIDs."NodeID");
delete FROM "Organize" WHERE "NodeID"=childIDs."NodeID";
delete FROM "Node" WHERE "ID"=childIDs."NodeID";
END LOOP;
delete FROM "Organize" WHERE "NodeID"=deleteNodeID;
delete FROM "Node" WHERE "ID"=deleteNodeID;
END;oracle 过程 调用本身
原文:http://blog.csdn.net/yuexin2/article/details/43883867