求oracle存储过程,同时删除两张表中的id相同的数据
2个回答
展开全部
BEGIN
BEGIN
insert into #temp select T1.id from T1,T2 where T1.id=T2.id;
DELETE from T1 WHERE id IN (select id from #temp);
DELETE from T2 WHERE id IN (select id from #temp);
drop table #temp;
EXCEPTION
WHEN NO_DATA_FOUND THEN
DBMS_OUTPUT.PUT_LINE('Employee Number Not Found!');
END
COMMIT;
EXCEPTION
WHEN OTHERS THEN
ROLLBACK;
END;
/
BEGIN
insert into #temp select T1.id from T1,T2 where T1.id=T2.id;
DELETE from T1 WHERE id IN (select id from #temp);
DELETE from T2 WHERE id IN (select id from #temp);
drop table #temp;
EXCEPTION
WHEN NO_DATA_FOUND THEN
DBMS_OUTPUT.PUT_LINE('Employee Number Not Found!');
END
COMMIT;
EXCEPTION
WHEN OTHERS THEN
ROLLBACK;
END;
/
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询