用oracle的select语句就可以实现 方法是 select rest_id from table(你存这两个数据的表) which res_deal_sts = 'p';(p是啥意思 present?) 这个是查询语句 也就是限制条件 如果是插入可以用merge实现
构建另一张表,存入准备插入的数据 然后用merge into
用个insert all搞定...给你个例子insert all when sal > 2000 then into insert_all_test1 values(no,name) when sal < 2500 then into insert_all_test2 values(no,sal) select empno no,ename name,sal from scott.emp;
if not exists(select 1 from tb where rest_id is null and rest_deal_sts = 'P' and 关键字 = ... and 日期 = ...) insert into tb(...) values(...)
方法是
select rest_id
from table(你存这两个数据的表)
which res_deal_sts = 'p';(p是啥意思 present?)
这个是查询语句 也就是限制条件 如果是插入可以用merge实现
然后用merge into
when sal > 2000 then
into insert_all_test1 values(no,name)
when sal < 2500 then
into insert_all_test2 values(no,sal)
select empno no,ename name,sal from scott.emp;
insert into tb(...) values(...)