PL/SQL (MOSC)

MOSC Banner

ORDER BY in a MERGE subselect

edited Oct 6, 2009 10:15AM in PL/SQL (MOSC) 6 commentsAnswered
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?

Howdy, Stranger!

Log In

To view full details, sign in to My Oracle Support Community.

Register

Don't have a My Oracle Support Community account? Click here to get started.

Category Leaderboard

Top contributors this month

New to My Oracle Support Community? Visit our Welcome Center

MOSC Help Center