ORDER BY in a MERGE subselect
I have a merge that follows the basic format
merge into t1 a1
using (select col1, col2 from t2
order by col2) cr
when not matched
insert into t1
when matched
update t1
where a1.code = 'some value'
Does Oracle use the Order By in the subquery select to process the records to the MERGE? I assumed it would but that doesn't appear to be the case as I have records being processed in a different order from the order by. In my example, col2 is a date and I need the data processed in a particular data order.
My data needs to be processed in this order because some records have to be inserted before others because the later records apply updates to those Inserts. I've gotten around this by processing smaller sets of data but I'd prefer not to have to do that. I hope this is clear and that someone can tell me is this expected behavior?
using (select col1, col2 from t2
order by col2) cr
when not matched
insert into t1
when matched
update t1
where a1.code = 'some value'
Does Oracle use the Order By in the subquery select to process the records to the MERGE? I assumed it would but that doesn't appear to be the case as I have records being processed in a different order from the order by. In my example, col2 is a date and I need the data processed in a particular data order.
My data needs to be processed in this order because some records have to be inserted before others because the later records apply updates to those Inserts. I've gotten around this by processing smaller sets of data but I'd prefer not to have to do that. I hope this is clear and that someone can tell me is this expected behavior?
0