我存储过程中有一段代码
loop
fetch C_tracking_info into r_tracking_info;
exit when C_tracking_info%notfound;
begin
update mytable set match_sign='Y' where record_id=r_tracking_info.record_id
exception
when others then
raise_application_error(-20102,'记录匹配时出现错误!'||sqlerrm);
end;
commit;
end loop;
当执行完update和commit之后match_sign仍然是'N',怎么会update不成功呢?
loop
fetch C_tracking_info into r_tracking_info;
exit when C_tracking_info%notfound;
begin
update mytable set match_sign='Y' where record_id=r_tracking_info.record_id
exception
when others then
raise_application_error(-20102,'记录匹配时出现错误!'||sqlerrm);
end;
commit;
end loop;
当执行完update和commit之后match_sign仍然是'N',怎么会update不成功呢?
fetch C_tracking_info into r_tracking_info;
exit when C_tracking_info%notfound;
begin
dbms_output.putline(r_tracking_info.record_id);
update mytable set match_sign='Y' where record_id=r_tracking_info.record_id
exception
when others then
raise_application_error(-20102,'记录匹配时出现错误!'||sqlerrm);
end;
commit;
end loop; 测试一下看有没有值传入.
loop
fetch C_tracking_info into r_tracking_info;
exit when C_tracking_info%notfound;
begin
update mytable set match_sign='Y' where record_id=r_tracking_info.record_id dbms_output.putline(sql%rowcount);
exception
when others then
raise_application_error(-20102,'记录匹配时出现错误!'||sqlerrm);
end;
commit;
end loop;
如果sql%rowcount大于0
那么可能是你在刚才的语句之后又有其他语句给更新回去了
你竟然还没搞清楚再什么地方打印先
set serveroutput on再用dbms_output.put_line();
单步跟踪看一下num3的值