FUNCTION Get_cpwlxhqd_Note(
 dop_id_ in varchar2,
 part_no_  IN  varchar2,
 DOP_ORDER_ID_ IN number
) RETURN number
IS
 AALEVEL_ number;
 temp_ number;
 PARENT_DOP_ORDER_ID_ number;
 tempa_ number;
 Cursor get_attr_ is
 select DOP_STRUCTURE_LEVEL,QTY_PER_ASSEMBLY,PARENT_DOP_ORDER_ID
 from ifsapp.DOP_ORDER_ORD_BY_ID
 WHERE dop_id=dop_id_ and PART_NO=PART_NO_ and DOP_ORDER_ID=DOP_ORDER_ID_;
 Cursor get_att1 is
 select DOP_STRUCTURE_LEVEL,QTY_PER_ASSEMBLY,PARENT_DOP_ORDER_ID
 from ifsapp.DOP_ORDER_ORD_BY_ID
 WHERE dop_id=dop_id_ and PART_NO=PART_NO_;
 begin
    Open get_attr_;
    Fetch get_attr_
    Into AALEVEL_,temp_,PARENT_DOP_ORDER_ID;
    Close get_attr_;    Open get_attr1;
    Fetch get_record IN get_attr1 LOOP
     AALEVEL_:=AALEVEL_-1;
    if (get_record.DOP_ORDER_ID=PARENT_DOP_ORDER_ID_) and (get_record.DOP_STRUCTURE_LEVEL=AALEVEL_) then temp_:=tempa_*temp_;
    end LOOP;
  Return temp_;
End Get_cpwlxhqd_Note;
这是本人在一个包里的一个子包体代码,编译时出现了这些错语
PACKAGE BODY IFSAPP.DJ_FINANCE_API 编译错误
错误:PLS-00103: Encountered the symbol "IN" when expecting one of the following:       
          . into bulk
行:321
文本:Fetch get_record IN get_attr1 LOOP
错误:PLS-00103: Encountered the symbol "LOOP" when expecting one of the following:      
          if
行:324
文本:end LOOP;
错误:PLS-00103: Encountered the symbol "DJ_FINANCE_API" when expecting one of the following:       
          ;
行:328
文本:END Dj_Finance_API;
请教各位,这些错误是什么错误,应如何修改这段代码.

解决方案 »

  1.   

        Fetch get_record IN get_attr1 LOOP 
        AALEVEL_:=AALEVEL_-1; 
        if (get_record.DOP_ORDER_ID=PARENT_DOP_ORDER_ID_) and (get_record.DOP_STRUCTURE_LEVEL=AALEVEL_) then temp_:=tempa_*temp_; 
        end LOOP; ===>    FOR get_record IN get_attr1 LOOP 
         AALEVEL_:=AALEVEL_-1; 
         if (get_record.DOP_ORDER_ID=PARENT_DOP_ORDER_ID_) and (get_record.DOP_STRUCTURE_LEVEL=AALEVEL_) then temp_:=tempa_*temp_; 
        end LOOP; 
      

  2.   

    行321的问题已经解决,感谢codearts,但还有324,328没有解决,它是什么错误
    PACKAGE BODY IFSAPP.DJ_FINANCE_API 编译错误
    错误:PLS-00103: Encountered the symbol "LOOP" when expecting one of the following:       
              if
    行:324
    文本:end LOOP;
    错误:PLS-00103: Encountered the symbol "DJ_FINANCE_API" when expecting one of the following:
              ;
    行:328
    文本:END Dj_Finance_API;
      

  3.   

    少了多个分号,并且fetch into的变量不够。参考修改如下:
    CREATE OR REPLACE FUNCTION GET_CPWLXHQD_NOTE(DOP_ID_       IN VARCHAR2,
                                                 PART_NO_      IN VARCHAR2,
                                                 DOP_ORDER_ID_ IN NUMBER)
      RETURN NUMBER IS
      AALEVEL_             NUMBER;
      TEMP_                NUMBER;
      PARENT_DOP_ORDER_ID_ NUMBER;
      TEMPA_               NUMBER;
      L_1                  NUMBER;
      L_2                  NUMBER;
      CURSOR GET_ATTR_ IS
        SELECT DOP_STRUCTURE_LEVEL, QTY_PER_ASSEMBLY, PARENT_DOP_ORDER_ID
          FROM IFSAPP.DOP_ORDER_ORD_BY_ID
         WHERE DOP_ID = DOP_ID_
           AND PART_NO = PART_NO_
           AND DOP_ORDER_ID = DOP_ORDER_ID_;
      CURSOR GET_ATT1 IS
        SELECT DOP_STRUCTURE_LEVEL, QTY_PER_ASSEMBLY, PARENT_DOP_ORDER_ID
          FROM IFSAPP.DOP_ORDER_ORD_BY_ID
         WHERE DOP_ID = DOP_ID_
           AND PART_NO = PART_NO_;
    BEGIN
      OPEN GET_ATTR_;
      FETCH GET_ATTR_
        INTO AALEVEL_, TEMP_, PARENT_DOP_ORDER_ID;
      CLOSE GET_ATTR_;  OPEN GET_ATTR1;
      LOOP
        FETCH GET_ATTR1
          INTO L_1, TEMPA_, L_3;
        EXIT WHEN GET_ATTR1%NOTFOUND;
        AALEVEL_ := AALEVEL_ - 1;
        IF (L_3 = PARENT_DOP_ORDER_ID_) AND (L_1 = AALEVEL_) THEN
          TEMP_ := TEMPA_ * TEMP_;
        END IF;
      END LOOP;
      CLOSE GET_ATTR1;
      RETURN TEMP_;
    END GET_CPWLXHQD_NOTE;
      

  4.   

    if (get_record.DOP_ORDER_ID=PARENT_DOP_ORDER_ID_) and (get_record.DOP_STRUCTURE_LEVEL=AALEVEL_) then temp_:=tempa_*temp_; 仔细一看,发现少了end if    if (get_record.DOP_ORDER_ID=PARENT_DOP_ORDER_ID_) and 
           (get_record.DOP_STRUCTURE_LEVEL=AALEVEL_) then 
            temp_:=tempa_*temp_;
        end if;  
      

  5.   

    FUNCTION Get_cpwlxhqd_Note(
     dop_id_ in varchar2,
     part_no_  IN  varchar2,
     DOP_ORDER_ID_ IN number
    ) RETURN number
    IS
     AALEVEL_ number;
     temp_ number;
     PARENT_DOP_ORDER_ID_ number;
     tempa_ number;
     Cursor get_attr_ is
     select DOP_STRUCTURE_LEVEL,QTY_PER_ASSEMBLY,PARENT_DOP_ORDER_ID
     from ifsapp.DOP_ORDER_ORD_BY_ID
     WHERE dop_id=dop_id_ and PART_NO=PART_NO_ and DOP_ORDER_ID=DOP_ORDER_ID_;
     Cursor get_att1 is
     select DOP_STRUCTURE_LEVEL,QTY_PER_ASSEMBLY,PARENT_DOP_ORDER_ID
     from ifsapp.DOP_ORDER_ORD_BY_ID
     WHERE dop_id=dop_id_ and PART_NO=PART_NO_;
     begin
        Open get_attr_;
        Fetch get_attr_
        Into AALEVEL_,temp_,PARENT_DOP_ORDER_ID;
        Close get_attr_;    AALEVEL_:=AALEVEL_-1;    Open get_attr1;
        FOR get_record IN get_attr1 LOOP
            IF (get_record.DOP_ORDER_ID=PARENT_DOP_ORDER_ID_) and (get_record.DOP_STRUCTURE_LEVEL=AALEVEL_) then
              begin
                temp_:=tempa_*temp_;
                AALEVEL_:=AALEVEL_-1;
              END IF;
        end LOOP;
        Close get_attr1;
      Return temp_;
    End Get_cpwlxhqd_Note;
    根据各位的意见,我在oracle上改过这段代码之后,还出现以下错误
    PACKAGE BODY IFSAPP.DJ_FINANCE_API 编译错误错误:PLS-00103: Encountered the symbol "IF" when expecting one of the following:       
              ; <an identifier> <a double-quoted delimited-identifier>
    行:328
    文本:END IF;
    不知这个最后的错误是什么意思
      

  6.   

    你这个then 之后又多加了个begin
      

  7.   

    哪个then之后的begin我去掉之后有更多的错误,错误如下:
    PACKAGE BODY IFSAPP.DJ_FINANCE_API 编译错误
    错误:PLS-00201: identifier 'PARENT_DOP_ORDER_ID' must be declared
    行:317
    文本:Into AALEVEL_,temp_,PARENT_DOP_ORDER_ID;
    错误:PL/SQL: SQL Statement ignored
    行:316
    文本:Fetch get_attr_
    错误:PLS-00201: identifier 'GET_ATTR1' must be declared
    行:322
    文本:Open get_attr1;
    错误:PL/SQL: SQL Statement ignored
    行:322
    文本:Open get_attr1;
    错误:PLS-00201: identifier 'GET_ATTR1' must be declared
    行:323
    文本:FOR get_record IN get_attr1 LOOP
    错误:PL/SQL: Statement ignored
    行:323
    文本:FOR get_record IN get_attr1 LOOP
    错误:PLS-00201: identifier 'GET_ATTR1' must be declared
    行:329
    文本:Close get_attr1;
    错误:PL/SQL: SQL Statement ignored
    行:329
    文本:Close get_attr1;
    错误:PLS-00323: subprogram or cursor 'GET_CPWLXHQD_NOTE' is declared in a package specification and must be defined in the package body
    行:76
    文本:-------------------------------Get_Part_Long---------------------------
    应该不是这个错误
      

  8.   

        Fetch get_attr_ 
        Into AALEVEL_,temp_,PARENT_DOP_ORDER_ID; 
        Close get_attr_; 
    ==========>
        Fetch get_attr_ 
        Into AALEVEL_,temp_,PARENT_DOP_ORDER_ID_
        Close get_attr_;