DB2 Exception handling

大兔子大兔子 提交于 2019-12-23 03:58:10

问题


The problem that I am facing is primarily on Exception Handling! When an exception occurs I want to put that data in another log table with the error message. However, in DB2 I am not able to figure out a way to retrieve the corresponding error message for the raised SQLSTATE.

PS: I have a stored procedure for this migration and I am not using any other language to call it.

We could do this through SQLERRM in oracle; probably it should be a small thing, still for some strange reasons I have not been able to find it yet!

Hopefully you would have an idea on this, ;-). I just need a pointer on this.

Thanks,

Harveer Uppal


回答1:


DB2 has an SQLERRM function too. All you need to to is capture all of the tokens from the error and feed them into the function for the equivalent message you'd get from the CLP.

http://publib.boulder.ibm.com/infocenter/db2luw/v9r5/topic/com.ibm.db2.luw.sql.rtn.doc/doc/r0022027.html




回答2:


You should be able to get in the front-end code using DB2Exception.Message property.



来源:https://stackoverflow.com/questions/1096340/db2-exception-handling

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!