You should be able to use MERGE statement to do it in a single shot. However, the statement is going to be rather large:

MERGE INTO employee e
USING (
   SELECT 1 as d_id, 'cd234' as staff_no FROM Dual
       UNION ALL
   SELECT 2 as d_id, 'ef345' as staff_no FROM Dual
       UNION ALL
   SELECT 3 as d_id, 'fg456' as staff_no FROM Dual
       UNION ALL
   ... -- More selects go here
   SELECT 200 as d_id, 'za978' as staff_no FROM Dual
) s
ON (e.depno = S.d_id)
WHEN MATCHED THEN UPDATE SET e.staff_no= s.staff_no
Answer from Sergey Kalinichenko on Stack Overflow
Top answer
1 of 2
8

If you just want the discharge_dt to be overwritten with the admit_dt from the same row, it sounds like you just need

UPDATE patient
   SET discharge_dt = admit_dt
 WHERE facility_id = 'X'
   AND pat_seq IN (<<query that returns the 60,000 keys>>)
2 of 2
4

Cloyd, the description is indeed confusing.

I'll state some assumptions and work on them. Please, shall you consider this worth, comment out and I'll keep editing the answer until we get 'there'. Deal?

Let's go:

  • the update statement has as condition facility_id='X'

  • the sub-query at the assignment has no condition at all (except pat_seq)

  • therefore, I'm assuming and 'forecasting' that:

    • pat_seq is key for identification of a patient

    • both admit_dt and discharge_dt are of type date/time, not just date

    • the facility_id column at patient table keeps track of the several facilities within which the patient has been sent during it's (sad?) stay

    • for any patient, for each facility where it's been sent to, there has to be a row keeping track of date/time of admission and discharging, like:

      • pat_seq: 0015, facility_id: AABB, admit_dt: 15:35, discharge_dt:16:45
      • pat_seq: 0015, facility_id: CCA1, admit_dt:16:45, discharge_dt:17:10
      • pat_seq: 0015, facility_id: AAHD, admit_dt:17:10, discharge_dt: NULL
    • just the admitances are registered, hence for any new admitance registered there has to be an update action upon the imediate previous entry for which the discharge time will be assumed as the admitance time within the next facility

    • bullseye?

Well, for this scenario, you shall do, assuming a batch, scheduled task:

UPDATE patient 
SET discharge_dt = (
            /*
                For every entry past this, retrieve the least admit_dt, which shall identify the moment the pat_seq moved into the next facility
            */
            SELECT MIN(admit_dt)
            FROM patient pat_next_admit
            WHERE pat_next_admit.pat_seq  = patient.pat_seq
              AND pat_next_admit.admit_dt > patient.admit_dt
        ) 
WHERE discharge_dt IS NULL /* No need to process rows already processed! */
Discussions

SQL command for UPDATE of multiple rows - Oracle Forums
Hi, how to write SQL command to updating multiple rows in one statement? I tried as follows from TOAD which worked: UPDATE TableA SET a = 'x' WHERE b = 'a'; UPDATE TableA SET a = 'x' WHERE b = 'b; UP... More on forums.oracle.com
๐ŸŒ forums.oracle.com
December 21, 2009
sql - Update multiple rows using CASE WHEN - ORACLE - Stack Overflow
I have the table ACCOUNT of structure as follow: ACCOUNT_ID | ACCOUNT_STATUS| 004460721 | 2 | 042056291 | 5 | 601272065 | 3 | I need to update the ... More on stackoverflow.com
๐ŸŒ stackoverflow.com
Update multiple rows using select statement in Oracle - Database Administrators Stack Exchange
Im using this script for updating "gndt_customer_identification" table, value of V_iden_no coming from select statement. How i can update multiple row when select return more then one val... More on dba.stackexchange.com
๐ŸŒ dba.stackexchange.com
sql - Update multiple rows using select statements - Stack Overflow
Let's say I have these tables and values: Table1 ------------------------ ID | Value ------------------------ 2 | asdf 4 | fdsa 5 | aaaa Table2 ------------------------ ID | Value ------------... More on stackoverflow.com
๐ŸŒ stackoverflow.com
May 24, 2017
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ pl/sql โ€บ how-to-update-multiple-rows-at-once-using-plsql
How to Update Multiple Rows at Once Using PL/SQL? - GeeksforGeeks
July 23, 2025 - UPDATE table_name SET column1 = value1, column2 = value2, ... WHERE condition; ... UPDATE: Specifies the table to modify. SET: Identifies the columns to update and assigns new values.
๐ŸŒ
Oracle Tutorial
oracletutorial.com โ€บ home โ€บ oracle basics โ€บ oracle update
Oracle UPDATE Statement
May 11, 2025 - If you update more than two columns, you separate each expression column = value by a comma. The value1, value2, or value3 can be literals or a subquery that returns a single value.
๐ŸŒ
Oracle
forums.oracle.com โ€บ ords โ€บ apexds โ€บ post โ€บ sql-command-for-update-of-multiple-rows-5350
SQL command for UPDATE of multiple rows - Oracle Forums
December 21, 2009 - Hi, how to write SQL command to updating multiple rows in one statement? I tried as follows from TOAD which worked: UPDATE TableA SET a = 'x' WHERE b = 'a'; UPDATE TableA SET a = 'x' WHERE b = 'b; UP...
๐ŸŒ
Sayantanblogonoracle
sayantanblogonoracle.in โ€บ home โ€บ sql โ€บ update multiple rows in oracle using join
Update multiple rows in Oracle using Join - Sayantan's Blog On Oracle
July 24, 2022 - In this scenario, we will use a value which is the result of a join condition to update multiple rows of a column. UPDATE EMP_JOIN_TEST A SET DEPARTMENT_NAME = (SELECT DEPARTMENT_NAME FROM DEPARTMENTS WHERE DEPARTMENT_ID = A.DEPARTMENT_ID ) WHERE DEPARTMENT_ID IS NOT NULL; ... In the above example we have used the join condition to update the DEPARTMENT_NAME column of EMP_JOIN_TEST by the same column of DEPARTMENTS table.
Find elsewhere
๐ŸŒ
Quora
quora.com โ€บ How-do-I-update-multiple-rows-in-Oracle-SQL-with-different-values
How to update multiple rows in Oracle SQL with different values - Quora
Answer (1 of 3): a2a: You can do a case statement in SQL. update test set text = case when (flag='Y') then ('its now yes') when (flag='N') then ('its no now') else ('unknown') end; So youโ€™d hard code the values in the where clauses and this lets you update multiple rows with different values...
๐ŸŒ
Medium
medium.com โ€บ geekculture โ€บ update-multiple-rows-in-sql-with-different-values-at-once-7d2eddb0b85f
Update multiple rows in SQL with different values at once | by Tadej Golobic | Geek Culture | Medium
June 12, 2021 - let sql = 'UPDATE users u JOIN ('; for(let i = 0; i < res.length; i+=BATCH_SIZE) { let nestedSql = ''; for(let j = 0; i < BATCH_SIZE; j++) { const userData = res[i+j]; if (!userData) { break; } if (j != 0) { nestedSql += 'UNION ALL '; } nestedSql += `SELECT \"${data.id}\" as id, \"${data.firstName}\" as firstName `; } sql += `${nestedSql}) a on u.id = a.id SET u.firstName = a.firstName;`; await trx.raw(sql); } Now we can run this and it will do a bulk update of 3000 rows.
๐ŸŒ
TechOnTheNet
techonthenet.com โ€บ sql โ€บ update.php
SQL: UPDATE Statement
This UPDATE example would update the supplier_id to 150, the supplier_name to 'Apple' and city to 'Cupertino' where the supplier_name is 'Google'.
๐ŸŒ
Oracle FAQ
orafaq.com โ€บ forum โ€บ t โ€บ 208043 โ€บ 0
OraFAQ Forum: SQL & PL/SQL ยป How to update multiple rows with different values from another table in the same query?
merge into Library lib using BookSupplier bs on ( lib.BookId = bs.BookNo and lib.BookShelfNo in ('4545','4546','4550')) when matched then update set lib.BOOKSUPPLERNO = bs.SupplierNo It gave me error ORA-30926: unable to get a stable set of rows in the source tables.
๐ŸŒ
Oracle
forums.oracle.com โ€บ ords โ€บ apexds โ€บ post โ€บ update-multiple-rows-with-different-values-6805
Update Multiple Rows with Different values. - Oracle Forums
April 25, 2020 - Hi I have to update descrip column in customer table around 1000 values manually, i.e I have to manually get the 1000 values of descrip values from BA's and update in descrip column, we do not have an...
๐ŸŒ
TechOnTheNet
techonthenet.com โ€บ oracle โ€บ update.php
Oracle / PLSQL: UPDATE Statement
Let's look at an Oracle UPDATE ... = 32 WHERE customer_id > 100; When you wish to update multiple columns, you can do this by separating the column/value pairs with commas....
๐ŸŒ
W3Schools
w3schools.com โ€บ sql โ€บ sql_update.asp
SQL UPDATE Statement
ADD ADD CONSTRAINT ALL ALTER ALTER COLUMN ALTER TABLE ALTER VIEW AND ANY AS ASC BACKUP DATABASE BETWEEN CASE CHECK COLUMN CONSTRAINT CREATE CREATE DATABASE CREATE INDEX CREATE OR REPLACE VIEW CREATE TABLE CREATE PROCEDURE CREATE UNIQUE INDEX CREATE VIEW DATABASE DEFAULT DELETE DESC DISTINCT DROP DROP COLUMN DROP CONSTRAINT DROP DATABASE DROP DEFAULT DROP INDEX DROP TABLE DROP VIEW EXEC EXISTS FOREIGN KEY FROM FULL OUTER JOIN GROUP BY HAVING IN INDEX INNER JOIN INSERT INTO INSERT INTO SELECT IS NULL IS NOT NULL JOIN LEFT JOIN LIKE LIMIT NOT NOT NULL OR ORDER BY OUTER JOIN PRIMARY KEY PROCEDURE RIGHT JOIN ROWNUM SELECT SELECT DISTINCT SELECT INTO SELECT TOP SET TABLE TOP TRUNCATE TABLE UNION UNION ALL UNIQUE UPDATE VALUES VIEW WHERE MySQL Functions
๐ŸŒ
Ask TOM
asktom.oracle.com โ€บ ords โ€บ f
Update table with multiple columns from another table ? - Ask TOM
Update table with multiple columns from another table ? Hi Tom,Due to migration to new system we have to change all our account numbers. ( Client number is consist of branch, Number, Sub Number Currency Code ) We have one big transaction table around 1 million records, having many columns, ...