Skip to content
Advertisement

Merge sql throws Unique constraint violation error

I have below two table for which when i query table TEST_RUA:

it returns:

When i query table TEST_RUA_MER:

it returns:

You can see both the values are same for table where ID_UU= 'GV9999B12M0'. The table TEST_RUA_MER has unique index on columns ID_LL, ID_UU, TKR.

Now i have below merge query which throws error as ORA-00001: unique constraint violated and i dont understand how can i avoid this error as both the table values are same then in this case this merge query should try to update and not to insert in table TEST_RUA_MER .

Advertisement

Answer

Looks like NULL causes problems; it isn’t “equal” to anything, so this:

fails.

Try with

(depending on what ID_LL column’s datatype is; I presumed it is a number).

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement