提取Netezza SP中的错误代码并插入表中?

问题描述

我创建了一个Netezza存储过程,尝试提取sp失败时出现的错误代码

BEGIN 
 insert into test values (10,10);
 
 insert into not_exist values ('dsad'); -- should fail here because table dosent exist
 EXCEPTION 
 WHEN OTHERS THEN ROLLBACK;
 insert into t2 (prc_name,error_code,error_msg,time_stamp )
 VALUES('NK_TEST1','??',SQLERRM,current_timestamp);
 commit;
 RAISE EXCEPTION 'Procedure failed: %',SQLERRM;
 
 END; 
END_PROC;

exec NK_TEST1(); 

执行以上操作后,将得到以下错误消息

ERROR [42S02] ERROR:  Procedure failed: relation does not exist RAMW2.ADMIN.not_exist 

需要提取错误代码 [42S02] 并将其插入t2表。

请帮忙

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...