存储过程里if判断问题
代码如下createorreplaceprocedurezhuancunisbegindeletefromtest2;deletefromtest4;insertinto...
代码如下
create or replace procedure zhuancun
is
begin
delete from test2;
delete from test4;
insert into test2 select * from test1;
insert into test4 select * from test3;
commit;
end;
现在想做一个判断,如果test1和test3不为空,在删除test2和test4的数据,否则不操作,如何写? 展开
create or replace procedure zhuancun
is
begin
delete from test2;
delete from test4;
insert into test2 select * from test1;
insert into test4 select * from test3;
commit;
end;
现在想做一个判断,如果test1和test3不为空,在删除test2和test4的数据,否则不操作,如何写? 展开
展开全部
create or replace procedure zhuancunis is
p_cnt number;
begin
select count(1) into p_cnt from test2;
if p_cnt > 0 then
delete from test2;
end if;
select count(1) into p_cnt from test4;
if p_cnt > 0 then
delete from test4;
end if;
insert into test2
select * from test1;
insert into test4
select * from test3;
commit;
end;
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询