Update statements with join are bit tricky to implement in Oracle. Use MERGE
instead
Also as mentioned in comments, datediff
is not valid in Oracle. So subtracts dates directly. But b.Int_start - a.Int_start
will give you difference in days
. Multiply it by 24
or 24*60
or 24*60*60
to get difference in hours
, minutes
and seconds
respectively.
merge into rpt_dev a
using rpt_dev_temp b
on (a.Interaction_UDL = b.Interaction_UDL)
when matched then update
set a.Till_Next = (b.Int_start - a.Int_start)
where a.Till_Next <= 0 and
a.Int_start not in (select max(Int_start) from rpt_dev_temp);
Note: Take backup of your original data before running. Test it on your test data and do no commit until you are sure you are updating correct rows.
In short, run update/delete statements with extra caution.