Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Insert select with order by to avoid deadlock

Alexander ChervinskyAug 19 2017 — edited Aug 23 2017

We have a procedure that inserts data into a table using insert select. The table has a primary key. We see deadlocks on this insert, on this primary key. Unfortunately, I cannot change the input data.

How can I ensure that the data is inserted in a particular order to avoid deadlock? Order by in select doesn't help. Will it work if I add rownum, and therefore, force oracle to materialize the dataset?

Or is my only option to select into a collection, and insert with forall insert?

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 20 2017
Added on Aug 19 2017
41 comments
4,862 views