我有一个使用Connect By
SELECT <lots of fields>
FROM Group g
<joins>
WHERE <where>
CONNECT BY PRIOR g.ID = g.ParentID
START WITH g.ID = 1337
ORDER SIBLINGS BY g.Name
;
数字1337
是此过程的参数,如果此值为0
,我想忽略connect by
代码并执行其他所有操作。
我该如何处理?
答案 0 :(得分:2)
最明显的答案是在connect by
子句中测试异常值:
SELECT <lots of fields>
FROM Group g
<joins>
WHERE <where>
CONNECT BY PRIOR g.ID = g.ParentID and :param <> 0
START WITH g.ID = :param or :param = 0
ORDER SIBLINGS BY g.Name;