insert&update
begin
insert into a(id,name,address)
select b1.id,b1.name,b1.address from
(select #{id} as id,#{name} as name,#{address} as address from dual) b1
where not exist(select 1 from a a1 where a1.id =#(id));
update a set(id,name,address)=select b1.id,b1.name,b1.address from
(select #{id} as id,#{name} as name,#{address} as address from dual) b1
where not exist(select 1 from a a1 where a1.id =#(id));
end;
注意,begin end如果不加的话,可能会报无效索引,插入,更新失败。

浙公网安备 33010602011771号