declare
v_cnt number;
begin
select count(*) into v_cnt from dual
where exists (select * from tstp_schemedetail where auto_scheme_id = '123');
if v_cnt = 0 then
insert into tstp_schemedetail( auto_scheme_id,stock_code, market_no)
values ( '28', '3423', '234') ;
else
update tstp_schemedetail set stock_code='new_value' where auto_scheme_id = '123';
end if;
end;
参考文章:https://www.cnblogs.com/neru/archive/2012/06/23/2559551.html