那么有可能获得当前的代码行吗?
1,2,3,4 v_variable :=(get_line or something???) and in variable are value 4?
5,6,7,8,9 v_variable :=(get_line or something???) and in variable are value 9?
Run Code Online (Sandbox Code Playgroud)
我只是想找到最简单的方法来捕获错误谢谢.
1,2,3,4, code lines...
Run Code Online (Sandbox Code Playgroud)
那么有可能获得当前的代码行吗?
是的,这是可能的.从Oracle 10g开始,$$PLSQL_LINE查询指令可用于返回$$PLSQL_LINE出现的代码中的行号:
SQL> declare
2 l_cur_cl pls_integer;
3 begin
4 l_cur_cl := $$PLSQL_LINE;
5 dbms_output.put_line('Line #: '|| to_char(l_cur_cl) || chr(13)
6 || 'Current line #: '|| to_char($$PLSQL_LINE));
7 end;
8 /
Run Code Online (Sandbox Code Playgroud)
输出:
Line #: 4
Current line #: 6
PL/SQL procedure successfully completed
Run Code Online (Sandbox Code Playgroud)