你好,我正在检查一个表中的数据是否存在于另一个表中,这是我的代码
我尝试了2种方法,但都不起作用idk为什么方法1
create or replace procedure proc1
As
Begin
if not exists(select * from T2 where c=(select * from (select * from T1 order by c) where rownum=1)) then
insert into T2
select * from (select * from T1 order by c) where rownum=1
end if;
End;
字符串
方法2
create or replace procedure proc1
As
Begin
declare var integer;
select count(*) into var from (select * from T1
intersect
select * from T2)
group by c
if var<2 then
insert into T2
select * from (select * from T1 order by c) where rownum=1
end if;
end;
型
1条答案
按热度按时间1cosmwyk1#
您不需要PL/SQL,可以使用单个SQL
merge
语句:字符串
或者
INSERT
与NOT EXISTS
和相关子查询:型
fiddle