I have 2 tables source and target
Target table has schema like this:
Source table has schema:
Now I'm trying to use merge into target table as
merge into target_table as tgt
using
(
select
src.id as mergekey,
src.*
from source_table src
union all
select
null as mergekey,
src.*
from source_table src
join target_table tgt
on tgt.id = src.id
and tgt.is_current = 1
where not( tgt.name = src.name )
) us
on tgt.id = us.mergekey
when matched
and tgt.is_current = 1
and
not ( tgt.name = src.name )
then update set
is_current = 0,
end_date = '2020-01-08'
when not matched then
insert *, 1 as is_current , '2020-01-09' as start_date, null as end_date
The problem occurs on the last line. I'm getting error on last line:
Error in SQL statement: ParseException:
mismatched input ',' expecting {<EOF>, ';'}(line 30, pos 8)
It works fine if I try to use it in select *, 1 as is_current , '2020-01-09' as start_date, null as end_date from source_table but in merge I think the syntax is different but I can't seem to find the solution