天天看點

otl獲得sql出錯位置(oracle)

  項目的一個需要,要獲得sql出錯的位置,進而給出類似sqlplus的錯誤提示(如下)

otl獲得sql出錯位置(oracle)

  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.       

~~積土成山,風雨興焉;積水成淵,蛟龍生焉;~~~