Skip to content
Advertisement

Execute two UPDATEs on complementary data at once in Oracle

I have the following table that I need to update:

I execute the following two UPDATE statements separately:

  1. Statement-1

  2. Statement-2

The Subquery that generates a list of values is the same for both of the UPDATE queries.

Is there any way which will help me to execute the query at once, like MERGE?

The following query using MERGE statement is invalid:

Since the WHEN NOT MATCHED THEN clause expects to have an INSERT statement.

Advertisement

Answer

Here is a merge version with example. You have to place logic in source part:

dbfiddle example

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