暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

Oracle 错误消息中的行号与源行不匹配

askTom 2018-03-06
372

问题描述

通过sqlplus运行PL/SQL脚本时,最终错误消息包含与源行不匹配的行号。例如:

ERROR at line 1:
ORA-06533: Subscript beyond count 
ORA-06512: at line 144 
ORA-06512: at line 2958 


这里,第144行不是包含下标运算符的源行。

我在公共表格和问答网站上看到了许多提到同一问题的报告。

测试。sql

declare

type log_entry is record (stamp timestamp(3),
                          sevlvl varchar2(32),
                          message varchar2(1024));

type sql_log_buffer is varray(100) of log_entry;

log_buffer sql_log_buffer := sql_log_buffer();

procedure test is
begin
    log_buffer(2).message = 'not extended';
end;

begin
    test();
end;
/


专家解答

我们需要看一个具体的例子?

匿名阻止?存储过程?

======================

编译错误行看起来不错

SQL> declare
  2
  3  type log_entry is record (stamp timestamp(3),
  4                            sevlvl varchar2(32),
  5                            message varchar2(1024));
  6
  7  type sql_log_buffer is varray(100) of log_entry;
  8
  9  log_buffer sql_log_buffer := sql_log_buffer();
 10
 11  procedure test is
 12  begin
 13      log_buffer(2).message = 'not extended';
 14  end;
 15
 16  begin
 17      test();
 18  end;
 19  /
    log_buffer(2).message = 'not extended';
                          *
ERROR at line 13:
ORA-06550: line 13, column 27:
PLS-00103: Encountered the symbol "=" when expecting one of the following:
:= . ( @ % ;
The symbol ":= was inserted before "=" to continue.


当我解决这个问题时,运行时错误看起来也很好

SQL> declare
  2
  3  type log_entry is record (stamp timestamp(3),
  4                            sevlvl varchar2(32),
  5                            message varchar2(1024));
  6
  7  type sql_log_buffer is varray(100) of log_entry;
  8
  9  log_buffer sql_log_buffer := sql_log_buffer();
 10
 11  procedure test is
 12  begin
 13      log_buffer(2).message := 'not extended';
 14  end;
 15
 16  begin
 17      test();
 18  end;
 19  /
declare
*
ERROR at line 1:
ORA-06533: Subscript beyond count
ORA-06512: at line 13
ORA-06512: at line 17


即,我们在第13行失败,这来自在第17行调用的例程
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论