Is this internal Oracle SQL bug ?
Hi,
I think following query should return 'AAAA' also for VAL2 column. Is this a bug in database (12.1.0.2.0 Enterprise - 64bit Linux) or I am wrong ?
select t1.val1,
(select val2
from
(select t2.val2
from
(select null id, 't2' tbl_name, 'BBBB' val2, 0 order_val from dual
union all
select null id, 't2' tbl_name, 'AAAA' val2, 1 order_val from dual
) t2
where
(t1.id is not null and t2.id = t1.id and t2.val2 is null)
or
(t1.id is null and t2.val2 = 'AAAA' /*same as t1.val1*/)
order by t2.order_val
)
where rownum < 2 -- if removed, then ORA-01427 is thrown wrongly also