1

我有一个使用的程序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代码并执行其他所有内容。

我该如何处理?

4

1 回答 1

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;
于 2011-09-21T18:37:40.433 回答