当前位置: 代码迷 >> Oracle开发 >> PLsql报错找不到游标~该如何解决
  详细解决方案

PLsql报错找不到游标~该如何解决

热度:113   发布时间:2016-04-24 06:35:20.0
PLsql报错找不到游标~
我是一个PLsql初学者,遇到了问题,下面是我写的代码,编译报错在15,8     说cursorT_SALARY 找不到,说些列存在之一 :=
. ( @ %;  求各位大神指点一下,我实在找不出什么错误了 =  =

CREATE OR REPLACE PACKAGE BODY AWS.PKG_SALARY_CURSOR AS

FUNCTION  SALARY_CURSOR
(        
    iUSER_ID           IN      VARCHAR2,                       
    oTABNAME           OUT     VARCHAR2,                       --/ エラー発生時のテーブル名称
    oERRORCODE         OUT     NUMBER,                         --/ エラー発生時のエラーコード
    oERRORDESC         OUT     VARCHAR2                        --/ エラー発生時のエラー名称 
)RETURN NUMBER

IS 
    vlTOTALAMOUNT              NUMBER:=0;                     
    vlTABNAME                  VARCHAR2(100);
BEGIN
CURSOR cursorT_SALARY IS 
    SELECT
        AMOUNT,
        PERFORMANCE
    FROM
        SALARY
    WHERE
        USER_ID=iUSER_ID;
    ORDER BY
        SALARY.AMOUNT;

    cur_rec_T_SALARY  cursorT_SALARY%ROWTYPE;

BEGIN
    vlTABNAME := 'PKG_SALARY_CURSOR.SALARY_CURSOR';

BEGIN
    
    OPEN cursorT_SALARY;
         LOOP
            FETCH
                cursorT_SALARY
            INTO
               cur_rec_T_SALARY;
            EXIT WHEN cursorT_SALARY%NOTFOUND;
             vlTOTALAMOUNT:= cur_rec_T_SALARY; 
         END LOOP;
         IF cursorT_BINTICKET%ISOPEN THEN
            CLOSE cursorT_BINTICKET;
         END IF;
            EXCEPTION
              WHEN OTHERS THEN
                 IF cursorT_BINTICKET%ISOPEN THEN
                 CLOSE cursorT_BINTICKET;
                 END IF;
                 oTABNAME     := 'ANNUAL_PENSION' ;
                 oERRORCODE   := SQLCODE;
                 oERRORDESC   := SUBSTR(SQLERRM,1,256);
                 Return(PKG_SYSTEM_DEF.ORACLEERROR);
END;
 --/ 正常終了
    RETURN(vlTOTALAMOUNT);

EXCEPTION
    WHEN OTHERS THEN
        oPRGNAME   := vlPRG_NAME;
        oERRORCODE := SQLCODE;
        oERRORDESC := SUBSTR(SQLERRM,1,256);
        RETURN(PKG_SYSTEM_DEF.ORACLEERROR);
END;
END PKG_SALARY_CURSOR;
/

------解决思路----------------------
WHERE
        USER_ID=iUSER_ID;
    ORDER BY
        SALARY.AMOUNT;
  相关解决方案