Atish Kumar Dipongkor
Atish Kumar Dipongkor

Reputation: 10422

Update and select in a single query in oracle 11g

At first, I want to update a table, then want to select updated rows. How can I do this in a single query. let say, I have updated a table following way

    UPDATE suppliers
SET city = (SELECT customers.city
            FROM customers
            WHERE customers.customer_name = suppliers.supplier_name)
WHERE EXISTS (SELECT customers.city
              FROM customers
              WHERE customers.customer_name = suppliers.supplier_name)

Now, How can I select this updated rows

Upvotes: 0

Views: 4858

Answers (1)

Anvesh
Anvesh

Reputation: 7693

try this for oracle using Returning:

UPDATE <table> SET (c1) = (v1) WHERE <condition> RETURNING <expression> INTO <variables>

Upvotes: 1

Related Questions