Unless your SELECT
subquery returns a single row, your UPDATE
statement should fail with the error
ORA-01427: single-row subquery returns more than one row
Generally, whey you have a correlated update, you need some condition that relates rows in the outer table T1
to rows in the inner subquery in order to ensure that the subquery returns a single row. That would generally look something like
UPDATE table1 t1 SET (t1.col,t1.Output) = (
SELECT t2.col, t3.Output + t2.col
FROM tabl2 t3
LEFT JOIN table1 t2 ON t3.Join_Key = t2.Join_Key
WHERE t2.col is not NULL
AND t1.some_key = t2.some_key);
Finally, this UPDATE
statement is updating every row in T1
. Is that what you intend? Or do you only want to update the rows where, for example, you find a match in your subquery?