What I want is flag all the records as dups except the max date. Is there a better way to write this update. Its currently produces error ORA-01652 ..unable to extend temp segment. The table is over a million records..

merge into TABLE_INPUT a
using (select rowid row_id,
row_number() over(partition by doc_id order by eff_dt desc) rn
from table_input) b
on (b.row_id=a.rowid and b.rn > 1)
when matched then update set DUPLICATE_FLAG=1
/