Monday, June 16, 2014

ORA-30926: unable to get a stable set of rows in the source tables

ORA-30926: unable to get a stable set of rows in the source tables

Cause :- This error occurred in MERGE statement when your ON Clause find duplicate record. This trying to update the same row of the target table multiple times

MERGE INTO D D
USING (SELECT DEPARTMENT_ID, DEPARTMENT_NAME, MANAGER_ID, LOCATION_ID FROM DEPT) DP
ON (D.DEPARTMENT_ID=DP.DEPARTMENT_ID)
WHEN MATCHED
THEN
   UPDATE SET D.DEPARTMENT_NAME=DP.DEPARTMENT_NAME, D.MANAGER_ID=DP.MANAGER_ID, D.LOCATION_ID=DP.LOCATION_ID
WHEN NOT MATCHED THEN
INSERT (DEPARTMENT_ID, DEPARTMENT_NAME, MANAGER_ID, LOCATION_ID)
VALUES (DP.DEPARTMENT_ID, DP.DEPARTMENT_NAME, DP.MANAGER_ID, DP.LOCATION_ID);

No comments:

Post a Comment