I’m trying to make the following update in oracle in order to update the DT_expiration field based on the results of the subquery for the same CD_PER_ALT_IDENTIFIER, but i keep getting the same error that i have ‘ON keyword missing’; I can’t figure it out what i’m missing here;
merge into per_alt_identifier a
using
(
select
a.CD_PER_ALT_IDENTIFIER,
case
when b.UNLIMITED_EXPIRATION = 1 then to_date(‘99991231′,’yyyymmdd’)
else to_date(substr(b.DATE_OF_ISSUE_EXPIRY,1,8),’yyyymmdd’)
end as dt_expiration_new
–a.*
from per_alt_identifier a
INNER JOIN PER_ALT_IDENT_TYPE t
on a.ID_PER_ALT_IDENT_TYPE = t.ID_PER_ALT_IDENT_TYPE
inner join ORA_PER_RESID b
on a.CD_PER_ALT_IDENTIFIER = b.PERMIT_NUMBER
)b
on a.CD_PER_ALT_IDENTIFIER = b.CD_PER_ALT_IDENTIFIER
when matched then update set a.dt_expiration = b.dt_expiration_new;
Thank you!