oracle中如何获得sql语句的错误信息
create or replace procedure pro_DataCopyAndCheck is
ls_COD varchar2(50);
ls_STA VARCHAR2(1);
ls_LNG VARCHAR2(3);
ld_EMS DATE;
ls_OPR_EMS VARCHAR2(20);
ls_REV VARCHAR2(3);
ld_REV DATE;
ls_OPR_REV VARCHAR2(20);
ls_SIG_PRD VARCHAR2(1);
ls_FIL_LAME VARCHAR2(1);
ls_COD_LAME VARCHAR2(5);
cursor get70TableData is
select I94_COD_QCP,I94_STA_QCP,I94_LNG_QCP,D94_EMS_QCP,T94_OPR_EMS_QCP,
I94_REV_QCP,D94_REV_QCP,T94_OPR_REV_QCP,I27_SIG_PRD,
F94_FIL_LAME,I94_COD_LAME from TGED070_QCP_STANGING;
begin
open get70TableData;
fetch get70TableData into
ls_COD,ls_STA,ls_LNG,ld_EMS,ls_OPR_EMS,ls_REV,ld_REV,
ls_OPR_REV,ls_SIG_PRD,ls_FIL_LAME,ls_COD_LAME;
while get70TableData%found loop
begin
insert into TGED070_QCP values
(ls_COD,ls_STA,ls_LNG,ld_EMS,ls_OPR_EMS,ls_REV,ld_REV,
ls_OPR_REV,ls_SIG_PRD,ls_FIL_LAME,ls_COD_LAME);
EXCEPTION
when others then
update TGED070_QCP_STANGING set C_flag = "B ",Err_info = insert语句产生的错误信息
where I94_COD_QCP = ls_cod;
fetch get70TableData into
ls_COD,ls_STA,ls_LNG,ld_EMS,ls_OPR_EMS,ls_REV,ld_REV,
ls_OPR_REV,ls_SIG_PRD,ls_FIL_LAME,ls_COD_LAME;
end;
end loop;
Close get70TableData;
end pro_DataCopyAndCheck;
如何得到insert语句所产生的错误消息
[解决办法]
有一种办法,可以对表进行审计。
init文件的参数必须:
audit_trail=DB
比如:
用user用户登陆.打算对表user.test的插入操作做审计.
操作如下:
audit insert on user.test;
执行你的语句:
insert into test values (....);
查询sql执行情况:
select * from sys.aud$;
[解决办法]
dup_val_on_index
违反主见,唯一建,唯一索引