oracle存储过程查找表数据插入另一个表中。。

首先有四个表,A表有xm,mz,jg等几个字段,B表有mz,mzmc字段,C表有jg,jgmc字段,现在要查找出A的mz在B的mz中没有,jg在C的jg中也没有的记录,然后插入到D表中,请问这样子应该怎么做???最好有详细的代码,谢谢~~~

第1个回答  推荐于2016-07-01
不用存储过程,直接INSERT就行
insert into D
(select * from A where
mz not in(select mz from B) and
jg not in(select jg from C));

你要存储过程的话再加个壳
create or replace procedure XXX
IS
begin
insert into D
(select * from A where
mz not in(select mz from B) and
jg not in(select jg from C));
end;
/本回答被提问者采纳