4
我需要写条件I.e的分层查询。如果条件为真,那么在通过事先条款进行连接时应使用某些列,如果条件为假,则应在该条款中包含其他一些列。通过事先条件连接
伪代码 ...
If col1 is not null then
Connect by prior col1=col1
Else
Connect by prior col2=col2
...
是这样的可能在PLSQL?
我需要写条件I.e的分层查询。如果条件为真,那么在通过事先条款进行连接时应使用某些列,如果条件为假,则应在该条款中包含其他一些列。通过事先条件连接
伪代码 ...
If col1 is not null then
Connect by prior col1=col1
Else
Connect by prior col2=col2
...
是这样的可能在PLSQL?
你只需要正确封装条件:
connect by (col1 is not null and prior col1=col1)
or (col1 is null and prior col2=col2)
尝试CASE EXPRESSION
:
CONNECT BY PRIOR CASE WHEN col1 IS NOT NULL THEN col1 ELSE col2 END
= CASE WHEN col1 IS NOT NULL THEN col1 ELSE col2 END
i'll再加上一点没有'prior'你可能会在一个无限藏汉地选择在这里? (虽然不太确定) – SomeJavaGuy