merge into Z_TABLE t1
using (
select
S_SYSTEM_ID,
S_PORT_ID,
S_SYSTEM_NAME
where S_SYSTEM_NAME = "广东"
from L_TABLE
) t2
on(
t1.S_PORT_ID=t2.S_PORT_ID and t1.S_SYSTEM_ID=t2.S_SYSTEM_ID and nvl(t1.S_SYSTEM_NAME,'1')=nvl(t2.S_SYSTEM_NAME,'1')
)
WHEN NOT matched THEN
INSERT (
S_SYSTEM_ID,
S_PORT_ID,
S_SYSTEM_NAME
)
VALUES (
t2.S_SYSTEM_ID, t2.S_PORT_ID,t2.S_SYSTEM_NAME
)
merge into Z_TABLE t1
using (
select S_SYSTEM_ID, S_PORT_ID,S_SYSTEM_NAME from Z_TABLE
minus
select S_SYSTEM_ID, S_PORT_ID,S_SYSTEM_NAME from L_TABLE
) t2
on (
t1.S_PORT_ID=t2.S_PORT_ID and t1.S_SYSTEM_ID=t2.S_SYSTEM_ID and nvl(t1.S_SYSTEM_NAME,'1')=nvl(t2.S_SYSTEM_NAME,'1')
)
when matched then
update set t1.additionalInfo = 'del'
delete WHERE t1.additionalInfo = 'del'