oracle中错误块数的含义是什么?

时间:2018-03-12 13:01:53

标签: oracle plsql

在PLSQL语句块中,oracle中的错误块数是什么意思 -

    /* The \ check should technically be needed for win32 systems only where
     * it is a valid path separator. However, IE in all it's wisdom always sends
     * the full path of the file on the user's filesystem, which means that unless
     * the user does basename() they get a bogus file name. Until IE's user base drops
     * to nill or problem is fixed this code must remain enabled for all systems. */

    s = _basename(internal_encoding, filename TSRMLS_CC);
    if (!s) {
        s = filename;
    }

2 个答案:

答案 0 :(得分:3)

如果没有更多代码,很难肯定。但是在调试中经常使用这种方法来确定代码中发生错误的位置。在EXCEPTION块中,它可能会在某处打印n_err_block。这样,如果它打印" n_err_block = 200",则开发人员知道错误发生在n_err_block := 200;n_err_block := 300;之间。例如:

declare
  n_err_block number;
begin
  n_err_block := 100;
  -- try something
  insert into table values (1, 2, 3);
  n_err_block := 200;
  -- try something else
  insert into table2 values (4, 5, 6);
  n_err_block := 300;
  update table3 set value2 = 7;
exception when others then
  dbms_output.print_line(DBMS_UTILITY.FORMAT_ERROR_BACKTRACE);
  dbms_output.print_line('n_err_block = ' || n_err_block);
end;
/

答案 1 :(得分:3)

很好的答案,kfinity,我认为值得强调你在那里添加的内容:DBMS_UTILITY.FORMAT_ERROR_BACKTRACE。此函数(和12.1及更高版本中的utl_call_stack的类似功能)追溯到引发错误的行号。

因此,如果您看到代码似乎跟踪了在引发错误之前您的程序有多远,请废弃所有这些并确保在记录错误时调用DBMS_UTILITY.FORMAT_ERROR_BACKTRACE