有没有一种方法可以获取引发异常的行号? [英] Is there a way to get the line number where an exception was thrown?
本文介绍了有没有一种方法可以获取引发异常的行号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在处理一个pl-sql脚本,其中大约有10个TO_CHAR转换.
Im working on a pl-sql script, in which I have about 10 TO_CHAR conversions.
其中一个正在投掷
ORA-06502: PL/SQL: numeric or value error: character string buffer too small
例外.
当前,使用这段代码记录消息
Currently, im logging the message with this piece of code
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.put_line('Exception message is '||SQLERRM(sqlcode));
ROLLBACK;
我想添加(主要出于调试目的)引发异常的行,以便接收形式为
I'd like to add (mostly for debugging purposes) the line where the exception is thrown, in order to receive a message in the form of
ORA-06502: PL/SQL: numeric or value error: character string buffer too small (at line x)
有一种简单的方法吗?
推荐答案
您需要10克才能使用
DBMS_OUTPUT.put_line('Error in '|| $$plsql_unit || ' at ' || $$plsql_line);
也考虑使用
DBMS_UTILITY.format_error_backtrace
Steven Feuerstein于2005年4月在《 Oracle杂志》上发表了一篇文章:
there is an article in Oracle Magazine from april '05 by Steven Feuerstein:
http://www.oracle. com/technetwork/issue-archive/2005/05-mar/o25plsql-093886.html
欢呼,尼尔斯
这篇关于有没有一种方法可以获取引发异常的行号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文