Merge two separate UPDATEs into one I have two separate UPDATEs as follows:
UPDATE mytab
SET colA = 1 
WHERE id IN ( SELECT id FROM mytab
              JOIN othertab ON mytab.otid = othertab.id 
              WHERE othertab.Lock = 'SomeLock' AND mytab.colA IS NULL);
UPDATE mytab
SET colB = 2 
WHERE id IN ( SELECT ID FROM mytab
              JOIN othertab ON mytab.otid = othertab.id 
              WHERE othertab.Lock = 'SomeLock' AND mytab.colB IS NULL);

I wish them as one merged UPDATE query. What I did is:
UPDATE mytab
SET colA = 
CASE WHEN colA IS NULL THEN 1 ELSE colA END,
colB = 
CASE WHEN colB IS NULL THEN 2 ELSE colB END 
WHERE id IN ( SELECT id FROM mytab
                  JOIN othertab ON mytab.otid = othertab.id 
                  WHERE othertab.Lock = 'SomeLock');

In general it does what I want on both SQL Server and Oracle. What is concerning me here is the performance of the merged query. In that shape it will update every row that is returned after filtering by predicate. Any better solutions?
I don't know enough about Oracle to know if the below is valid syntax there or not... or if there are niftier tricks specific to that RDBMS.  However, on SQL Server I would do something like this.
/** If you are updating small numbers of rows then this is probably good enough 
    on SQL Server.  Properly indexed tables, etc.
    **/
UPDATE mytab
SET colA = COALESCE(colA, 1)
    , colB = COALESCE(colB, 2)
WHERE EXISTS (SELECT TOP (1) 1 FROM othertab WHERE othertab.id = mytab.otid AND othertab.Lock = 'SomeLock')
    AND (   colA IS NULL
            OR colB IS NULL
            )
            
/** Larger numbers of rows could do better like this.
    **/
UPDATE M
SET colA = COALESCE(colA, 1)
    , colB = COALESCE(colB, 2)
FROM mytab AS M
    INNER JOIN othertab AS O ON O.id = M.otid AND O.Lock = 'SomeLock'
WHERE M.ColA IS NULL
    OR M.ColB IS NULL