otl获得sql出错位置(oracle)

  项目的一个需要,要获得sql出错的位置,从而给出类似sqlplus的错误提示(如下)

 

  sql出错原因易获得,记录在otl_exception::msg,但出错位置就不是那么容易了。

  默认情况下otl异常类是没有出错位置的信息的,如果需要获得出错位置,需要在引入otl头文件之前定义宏:OTL_EXCEPTION_ENABLE_ERROR_OFFSET

这样做之后,我们就可以在otl_exception::error_offset 中获得出错位置信息。

 

  关于这个宏,作者是这样说的:

You need to use #define OTL_EXCEPTION_ENABLE_ERROR_OFFSET before including otlv4.h:

http://otl.sourceforge.net/otl3_compile.htm#OTL_EXCEPTION_ENABLE_ERROR_OFFSET

The feature is not enabled by default, because it's Oracle only, and it's a little heavy for people who don't need it. 
posted @ 2015-08-07 09:41  皇家救星  阅读(234)  评论(0编辑  收藏  举报