能不能试试用隐式游标判断表1是否插入成功,如果不成功就抛出异常。因为我机子上没装过oracle,以下代码未经调试,你试一下
DECLARE
bad_credit EXCEPTION;
begin
insert into scott.a2(ab1,ab2,ab3) --1
if sql%rowcount=0 then
RAISE bad_credit;
end if
select aa1,aa2,'1' from scott.a1; --1
insert into scott.a2(ab1,ab2) --2
select aa1,aa2 from scott.a1; --2
exception
when bad_credit then
dbms_output.put_line('插入错误');
rollback;
when others then
dbms_output.put_line('插入错误');
rollback;
end;
DECLARE
bad_credit EXCEPTION;
begin
insert into scott.a2(ab1,ab2,ab3) --1
if sql%rowcount=0 then
RAISE bad_credit;
end if
select aa1,aa2,'1' from scott.a1; --1
insert into scott.a2(ab1,ab2) --2
select aa1,aa2 from scott.a1; --2
exception
when bad_credit then
dbms_output.put_line('插入错误');
rollback;
when others then
dbms_output.put_line('插入错误');
rollback;
end;
解决方案 »
- 求教:安装oracle之前创建裸设备出错,急急急
- 请高手指点这种分区方式属于哪一种(oracle分区问题)
- 用c写一个update oracle 的函数,该如何设置它的参数?
- 如何从一个select语句中得到第二条记录?
- 请问这样的表如何创建?
- 关于锁表的问题?(for update nowait)
- 如何得到一个表的主键??????????????????????
- SQLLDR的一个错误,紧急求助 [在线等待]
- 锁的问题,能不能有什么根本方法解决它(不用kill)!在线等待!!
- Oracle10g在32位win7电脑安装失败
- 关于日期函数的用法,请大家帮忙!
- 【请问】如何配置访问公网上的Oracle数据库 100fen!
建议楼主对2个结果分别判断异常
可以用2楼的方法,看看sql%rowcount来判断