我有这个问题:
SELECT PAI, FILHO
FROM
(
SELECT PAI, FILHO
FROM
(
SELECT 'CT_'||SUBSTR(TRIM(TBP.CTS_ORDEM), -10) PAI,
'CT_'||SUBSTR(TRIM(TBC.CTS_ORDEM), -10) FILHO
FROM PETROSUAPE_P10.CTS010@DBL_DWHYP_TOTVS TBC,
PETROSUAPE_P10.CTS010@DBL_DWHYP_TOTVS TBP
WHERE TBC.CTS_CODPLA = 'AVD'
AND TBP.CTS_CODPLA = 'AVD'
AND TBC.D_E_L_E_T_ <> '*'
AND TBP.D_E_L_E_T_ <> '*'
AND TBC.CTS_CTASUP = TBP.CTS_CONTAG
)
)
START WITH PAI = 'CT_0000000001'
CONNECT BY NOCYCLE PRIOR FILHO = PAI;
那只是回归:
CT_0000000001 CT_0000000011
CT_0000000001 CT_0000000101
CT_0000000001 CT_0000000141
但如果我跑:
SELECT 'CT_'||SUBSTR(TRIM(TBP.CTS_ORDEM), -10) PAI,
'CT_'||SUBSTR(TRIM(TBC.CTS_ORDEM), -10) FILHO
FROM PETROSUAPE_P10.CTS010@DBL_DWHYP_TOTVS TBC,
PETROSUAPE_P10.CTS010@DBL_DWHYP_TOTVS TBP
WHERE TBC.CTS_CODPLA = 'AVD'
AND TBP.CTS_CODPLA = 'AVD'
AND TBC.D_E_L_E_T_ <> '*'
AND TBP.D_E_L_E_T_ <> '*'
AND TBC.CTS_CTASUP = TBP.CTS_CONTAG
AND 'CT_'||SUBSTR(TRIM(TBP.CTS_ORDEM), -10) = 'CT_0000000141'
它让我回来......
CT_0000000141 CT_0000000161
CT_0000000141 CT_0000000191
CT_0000000141 CT_0000000201
CT_0000000141 CT_0000000231
CT_0000000141 CT_0000000151
CT_0000000141 CT_0000000211
CT_0000000141 CT_0000000891
CT_0000000141 CT_0000000261
CT_0000000141 CT_0000000901
CT_0000000141 CT_0000000272
CT_0000000141 CT_0000000273
CT_0000000141 CT_0000000171
CT_0000000141 CT_0000000181
CT_0000000141 CT_0000000221
CT_0000000141 CT_0000000251
CT_0000000141 CT_0000000271
CT_0000000141 CT_0000000274
我需要它让我的成员CT_0000000001
及其子女,儿童的孩子,孩子的孩子,等等......
有人可以帮助我发现它为什么不起作用吗?
提前致谢!