ORA-06550消息中的实际源行

时间:2012-06-06 12:57:41

标签: oracle plsql ora-06550

在Toad中开发Oracle PL / SQL过程时,遇到类似

的错误
  • ORA-06550:第97行,第25栏:PLS-00330:无效使用类型名称或子类型名称
  • ORA-06550:第97行,第9列:PL / SQL:语句被忽略

这些给定的行号和列号似乎与源代码行号很少或没有关系。我在哪里可以找到有助于我识别导致错误的实际源代码行或实际代码的提示或技巧?这在上述情况(这是700多行源的结果)中尤其重要,其中错误消息不提供有关实际问题细节的线索。 (顺便说一句,该源中的第101行是一系列注释行中的第三行,后面跟一个空行。)

(请注意,这在存储过程中尚未存在;此时它正在从源代码开发和执行。不确定这是否有所不同,因为目前没有数据库,我们的开发人员有权使用创建程序。)

示例代码:

SET SERVEROUTPUT ON;

DECLARE
TYPE bendemo_hdr IS RECORD
(
    recid      CHAR(1)
  , client     CHAR(30)
  , filedesc   CHAR(30)
  , seqnum     CHAR(2)
  , crtdate    CHAR(20)
  , srtdate    CHAR(8)
  , stpdate    CHAR(8)
);

TYPE bendemo_record IS RECORD
(
    recid        CHAR(1)
  , ssn          CHAR(9)
  , empnum       CHAR(15)
  , eeflag       CHAR(1)
  , titlecode    CHAR(6)
  , fname        CHAR(30)
  , mname        CHAR(30)
  , lname        CHAR(30)
  , namesuffix   CHAR(6)
  , prefname     CHAR(30)
  , dob          CHAR(8)
  , dod          CHAR(8)
  , dverdte      CHAR(8)
  , dauddte      CHAR(8)
  , ddtesrc      CHAR(6)
  , gender       CHAR(1)
  , martstat     CHAR(6)
  , mstateffdt   CHAR(8)
  , lang         CHAR(1)
  , citzcde      CHAR(6)
  , vipflag      CHAR(1)
  , kyeeflag     CHAR(1)
  , orghrdte     CHAR(8)
  , lathrdte     CHAR(8)
  , adjhrdte     CHAR(8)
  , jobtitle     CHAR(30)
  , precntmthd   CHAR(6)
  , mailpref     CHAR(6)
  , phnepref     CHAR(6)
  , emalpref     CHAR(6)
  , hmaddrefdt   CHAR(8)
  , hmaddr1      CHAR(60)
  , hmaddr2      CHAR(60)
  , hmaddr3      CHAR(60)
  , hmaddr4      CHAR(60)
  , hmaddcity    CHAR(60)
  , hmaddstate   CHAR(60)
  , hmaddzip     CHAR(10)
  , hmaddcnty    CHAR(3)
  , hmphcnty     CHAR(6)
  , hmphnbr      CHAR(16)
  , hmphext      CHAR(4)
  , mbphcnty     CHAR(6)
  , mbphnbr      CHAR(16)
  , faxcnty      CHAR(6)
  , faxnbr       CHAR(16)
  , hmemail      CHAR(100)
  , wkaddrefdt   CHAR(8)
  , wkaddr1      CHAR(60)
  , wkaddr2      CHAR(60)
  , wkaddr3      CHAR(60)
  , wkaddr4      CHAR(60)
  , wkaddcity    CHAR(60)
  , wkaddstate   CHAR(60)
  , wkaddzip     CHAR(10)
  , wkaddcnty    CHAR(3)
  , wkphcnty     CHAR(6)
  , wkphnbr      CHAR(16)
  , wkphext      CHAR(4)
  , wkemail      CHAR(100)
  , hiresrc      CHAR(30)
  , bgnunit      CHAR(30)
  , qdroflag     CHAR(1)
  , hiresrcdt    CHAR(8)
);

TYPE bendemo_trlr IS RECORD
(
    recid      CHAR(1)
  , client     CHAR(30)
  , filedesc   CHAR(30)
  , reccount   CHAR(9)
  , field1     CHAR(15)
);

demo_hdr    bendemo_hdr;
demo_rec    bendemo_record;
demo_trlr   bendemo_trlr;
i           NUMBER;

PROCEDURE dump_hdr_rec IS
BEGIN
    DBMS_OUTPUT.put(bendemo_hdr.recid);
    DBMS_OUTPUT.put(bendemo_hdr.client);
    DBMS_OUTPUT.put(bendemo_hdr.filedesc);
    DBMS_OUTPUT.put(bendemo_hdr.seqnum);
    DBMS_OUTPUT.put(bendemo_hdr.crtdate);
    DBMS_OUTPUT.put(bendemo_hdr.srtdate);
    DBMS_OUTPUT.put(bendemo_hdr.stpdate);
    DBMS_OUTPUT.put_line('<');
END dump_hdr_rec;



PROCEDURE dump_demo_rec IS
BEGIN
    --      IF l_output IS NULL THEN
    DBMS_OUTPUT.put(bendemo_record.recid);
    DBMS_OUTPUT.put(bendemo_record.ssn);
    DBMS_OUTPUT.put(bendemo_record.empnum);
    DBMS_OUTPUT.put(bendemo_record.eeflag);
    DBMS_OUTPUT.put(bendemo_record.titlecode);
    DBMS_OUTPUT.put(bendemo_record.fname);
    DBMS_OUTPUT.put(bendemo_record.mname);
    DBMS_OUTPUT.put(bendemo_record.lname);
    DBMS_OUTPUT.put(bendemo_record.namesuffix);
    DBMS_OUTPUT.put(bendemo_record.prefname);
    DBMS_OUTPUT.put(bendemo_record.dob);
    DBMS_OUTPUT.put(bendemo_record.dod);
    DBMS_OUTPUT.put(bendemo_record.dverdte);
    DBMS_OUTPUT.put(bendemo_record.dauddte);
    DBMS_OUTPUT.put(bendemo_record.ddtesrc);
    DBMS_OUTPUT.put(bendemo_record.gender);
    DBMS_OUTPUT.put(bendemo_record.martstat);
    DBMS_OUTPUT.put(bendemo_record.mstateffdt);
    DBMS_OUTPUT.put(bendemo_record.lang);
    DBMS_OUTPUT.put(bendemo_record.citzcde);
    DBMS_OUTPUT.put(bendemo_record.vipflag);
    DBMS_OUTPUT.put(bendemo_record.kyeeflag);
    DBMS_OUTPUT.put(bendemo_record.orghrdte);
    DBMS_OUTPUT.put(bendemo_record.lathrdte);
    DBMS_OUTPUT.put(bendemo_record.adjhrdte);
    DBMS_OUTPUT.put(bendemo_record.jobtitle);
    DBMS_OUTPUT.put(bendemo_record.precntmthd);
    DBMS_OUTPUT.put(bendemo_record.mailpref);
    DBMS_OUTPUT.put(bendemo_record.phnepref);
    DBMS_OUTPUT.put(bendemo_record.emalpref);
    DBMS_OUTPUT.put(bendemo_record.hmaddrefdt);
    DBMS_OUTPUT.put(bendemo_record.hmaddr1);
    DBMS_OUTPUT.put(bendemo_record.hmaddr2);
    DBMS_OUTPUT.put(bendemo_record.hmaddr3);
    DBMS_OUTPUT.put(bendemo_record.hmaddr4);
    DBMS_OUTPUT.put(bendemo_record.hmaddcity);
    DBMS_OUTPUT.put(bendemo_record.hmaddstate);
    DBMS_OUTPUT.put(bendemo_record.hmaddzip);
    DBMS_OUTPUT.put(bendemo_record.hmaddcnty);
    DBMS_OUTPUT.put(bendemo_record.hmphcnty);
    DBMS_OUTPUT.put(bendemo_record.hmphnbr);
    DBMS_OUTPUT.put(bendemo_record.hmphext);
    DBMS_OUTPUT.put(bendemo_record.mbphcnty);
    DBMS_OUTPUT.put(bendemo_record.mbphnbr);
    DBMS_OUTPUT.put(bendemo_record.faxcnty);
    DBMS_OUTPUT.put(bendemo_record.faxnbr);
    DBMS_OUTPUT.put(bendemo_record.hmemail);
    DBMS_OUTPUT.put(bendemo_record.wkaddrefdt);
    DBMS_OUTPUT.put(bendemo_record.wkaddr1);
    DBMS_OUTPUT.put(bendemo_record.wkaddr2);
    DBMS_OUTPUT.put(bendemo_record.wkaddr3);
    DBMS_OUTPUT.put(bendemo_record.wkaddr4);
    DBMS_OUTPUT.put(bendemo_record.wkaddcity);
    DBMS_OUTPUT.put(bendemo_record.wkaddstate);
    DBMS_OUTPUT.put(bendemo_record.wkaddzip);
    DBMS_OUTPUT.put(bendemo_record.wkaddcnty);
    DBMS_OUTPUT.put(bendemo_record.wkphcnty);
    DBMS_OUTPUT.put(bendemo_record.wkphnbr);
    DBMS_OUTPUT.put(bendemo_record.wkphext);
    DBMS_OUTPUT.put(bendemo_record.wkemail);
    DBMS_OUTPUT.put(bendemo_record.hiresrc);
    DBMS_OUTPUT.put(bendemo_record.bgnunit);
    DBMS_OUTPUT.put(bendemo_record.qdroflag);
    DBMS_OUTPUT.put(bendemo_record.hiresrcdt);
    DBMS_OUTPUT.put_line('<');
END dump_demo_rec;



PROCEDURE dump_hdr_trlr IS
BEGIN
    DBMS_OUTPUT.put(bendemo_trlr.recid);
    DBMS_OUTPUT.put(bendemo_trlr.client);
    DBMS_OUTPUT.put(bendemo_trlr.filedesc);
    DBMS_OUTPUT.put(bendemo_trlr.reccount);
    DBMS_OUTPUT.put(bendemo_trlr.field1);
    DBMS_OUTPUT.put_line('<');
END dump_hdr_trlr;
BEGIN
demo_bendemo_hdr.recid := 'x';
demo_bendemo_hdr.client := 'Client';
demo_bendemo_hdr.filedesc := 'Descr';
demo_bendemo_hdr.seqnum := 'a';
demo_bendemo_hdr.crtdate := 'Created';
demo_bendemo_hdr.srtdate := 'Sorted';
demo_bendemo_hdr.stpdate := 'stop';
dump_demo_hdr(l_output, demo_hdr);
END;

1 个答案:

答案 0 :(得分:4)

如果没有看到您正在运行的代码类型的示例,则很难确定此答案是否相关,但消息中指定的行号与正在编译的PL / SQL的整个块有关,并忽略任何该行前的空白行或注释。例如,如果您的脚本显示(仅为了清晰起见添加了行号):

1
2 -- test script
3
4
5 begin
6
7     rubbish;
8
9 end;

然后当您尝试运行它时,您将收到错误:

ORA-06550: line 3, column 3: 
PLS-00201: identifier 'RUBBISH' must be declared ...

它说第3行不是第7行因为“垃圾”;是正在编译的PL / SQL的第3行。上面的空行和注释不计算在内。然而,块中的空白行和注释确实计算在内。

修改

因此,将我的规则应用于您发布的代码示例,我们可以忽略DECLARE上面的2行,因此“第97行”是第99行:

DBMS_OUTPUT.put(bendemo_hdr.recid);

但是bendemo_hdr是TYPE而不是变量,所以在这个语句中没有意义,因此错误。它与写作类似:

DBMS_OUTPUT.put(CHAR(1)); --!!!

你可能意味着:

DBMS_OUTPUT.put(demo_hdr.recid);