The justification for my solution is that all your subqueries were the same, except for the last 2 lines which acted as a kind of yes/no switch for selecting CE records or not; I moved the yes/no part into the CASE expressions and combined all the identical subqueries into one. I don't know what you mean about it "may not produce the correct result", since I believe the query does the same as yours.
If Oracle is objecting to the CASE statement you are probably on a pre-9i version. In that case, you could use DECODE instead:
Code:
BEGIN
UPDATE UPDATE_TABLE TPC
SET (TPC.federal, TPC.state, ...) =
(SELECT
DECODE (TPC.exempt_federal, 1, TPC.federal, NVL(MAX(CE.federal),TPC.federal)),
DECODE (TPC.state, 1, TPC.state, NVL(MAX(CE.state),TPC.state)),
...
FROM SOURCE CE
WHERE ((CE.pkg_inst_id = TPC.pkg_inst_id AND CE.type_code = 0)
OR (CE.pkg_inst_id = 0 AND CE.type_code = TPC.type_code)
OR (CE.pkg_inst_id = 0 AND CE.type_code = 0))
AND CE.account_no = TPC.account_no
);
END;