I'm not sure if I understand correctly, but you can move the condition to the connect by
clause to filter out inconsistencies along the entire hierarchy (versus for the last parent/child couple)
select connect_by_root(assign_Id), assign_Id desc_assign_Id, code, flag
from my_bom
connect by parent_assign_Id = prior assign_Id
and DECODE( CODE,
'R', 'R', 'NR', 'NR', 'RNR',
:bind_var, NULL) = PRIOR DECODE( CODE,
'R', 'R', 'NR', 'NR', 'RNR',
:bind_var, NULL)
start with parent_assign_Id is null
order by desc_assign_Id;
You may also add where parent_assign_Id is not null
if you don't want the root :
select connect_by_root(assign_Id), assign_Id desc_assign_Id, code, flag
from my_bom
where parent_assign_Id is not null
connect by parent_assign_Id = prior assign_Id
and DECODE( CODE,
'R', 'R', 'NR', 'NR', 'RNR',
:bind_var, NULL) = PRIOR DECODE( CODE,
'R', 'R', 'NR', 'NR', 'RNR',
:bind_var, NULL)
start with parent_assign_Id is null
order by desc_assign_Id;
Compound connect by
condition should work with Oracle 10g, I only tested with 11g