当我试图执行此过程时,它给我一个错误,无效的对象

时间:2017-02-14 07:52:44

标签: plsql

当我尝试执行此过程时,它会给我一个错误,无效对象ora-06550错误。

我该怎么办?

此过程将值插入某些表并进行一些计算。

以下是程序:

CREATE OR REPLACE PROCEDURE SPR_FIS_SCHOLARSHIP_INSERT(P_ENTRY_DATE DATE) AS
      L_COUNT          NUMBER(10) := 0;
      l_party_count    number(10) := 0;
      L_NET_AMOUNT     NUMBER(10);
      L_COUNT1         NUMBER(10) := 0;
      L_GEN_VOUCHER_NO VARCHAR(20);
      L_PAYMENT_ID     NUMBER(10);
      L_PARTY_ID       NUMBER(10) := 0;
      L_CO6_NO         VARCHAR2(10) := 0;
      l_max_party_code NUMBER(10);
      L_NAME           VARCHAR2(100);
      CURSOR C1 IS
        SELECT NAME, AMOUNT
          FROM TMP_SCHOLARSHIP_DATA
         WHERE ENTRY_DATE LIKE P_ENTRY_DATE;
      CURSOR C_NAME IS
        SELECT NAME
          FROM TMP_SCHOLARSHIP_DATA
         WHERE NAME NOT IN (SELECT PARTY_NAME
                              FROM M_FIS_PARTY
                             WHERE SCHOLARSHIP_FLAG = 'S'
                               AND DELETE_FLAG = 'N')
           AND ENTRY_DATE = P_ENTRY_DATE;
    BEGIN
      SELECT COUNT(*)
        INTO L_COUNT
        FROM TMP_SCHOLARSHIP_DATA
       WHERE ENTRY_DATE LIKE P_ENTRY_DATE;




     -- L_CO6_NO := P_CO6_NO;
      DBMS_OUTPUT.PUT_LINE('STARTING CO6 NO=======' || L_CO6_NO);
      select max(TO_NUMBER(party_code)) + 1
        into l_max_party_code
        from m_fis_party;
      FOR I IN C_NAME LOOP
        L_PARTY_ID := SFN_ADM_GENERATE_SEQNO('M_FIS_PARTY', 'FIS');
        INSERT INTO M_FIS_PARTY
          (PARTY_ID,
           PARTY_CODE,
           PARTY_NAME,
           DELETE_FLAG,
           CREATED_BY,
           CREATION_DATE,
           SCHOLARSHIP_FLAG,
           PARTY_TYPE_OTH_CODE,
           PARTY_ACCOUNT_NUMBER,
           BANK_NAME,
           IFSC_CODE)
        VALUES
          (L_PARTY_ID,
           TO_CHAR(l_max_party_code),
           I.NAME,
           'N',
           'FISDEV',
           TO_DATE(SYSDATE),
           'S',
           'SCHOLARSHIP',
           I.BANK_ACCOUNT_NUMBER,
           I.BANK_NAME,
           I.IFSC_CODE);
        L_MAX_PARTY_CODE := L_MAX_PARTY_CODE + 1;
        l_party_count    := l_party_count + 1;
      END LOOP;
      FOR REC_C1 IN C1 LOOP
        L_PAYMENT_ID     := SFN_ADM_GENERATE_SEQNO('T_FIS_PAYMENT_HDR', 'FIS');
        l_gen_voucher_no := SFN_FIS_Generate_VoucherNumber('PAYORDER',
                                                           'A',
                                                           'D',
                                                           SYSDATE);
        SELECT PARTY_ID
          INTO L_PARTY_ID
          FROM M_FIS_PARTY
         WHERE PARTY_NAME = REC_C1.NAME
           AND SCHOLARSHIP_FLAG = 'S';

           SELECT MAX(TO_NUMBER(CLASSIF_ORD_NO))+1 INTO L_CO6_NO
           FROM T_FIS_PAYMENT_HDR;




          -- AND ROWNUM < 2;
        L_NET_AMOUNT := 0;
        IF (REC_C1.AMOUNT IS NOT NULL) THEN
          L_NET_AMOUNT := REC_C1.AMOUNT;
        END IF;
        INSERT INTO T_FIS_PAYMENT_HDR
          (PAYMENT_ID,
           PAYMENT_NO,
           PAY_ORD_DATE,
           PAYMENT_TYPE_ID,
           PAYEE_TYPE_ID,
           PAYEE_ID,
           PAID_TO_NAME,
           NET_AMOUNT,
           PAYMENT_STATUS,
           APPROVAL_FLAG,
           POST_FLAG,
           DELETE_FLAG,
           CREATED_BY,
           CREATION_DATE,
           PAY_ORD_NO,
           SCHOLARSHIP_FLAG,
           REMARKS,
           PRINT_FLAG,
           DOCUMENT_NO,
           FIS_SECTION,
           CLASSIF_ORD_NO,
           DEPT_PAYORDER_NO,
           CLASSIF_ORD_DATE,
           SUB_SECTION_CODE,
           DEPT_PAYORDER_DATE)
        VALUES
          (L_PAYMENT_ID,
           L_GEN_VOUCHER_NO,
           TO_DATE(SYSDATE),
           3,
           3,
           L_PARTY_ID,
           REC_C1.NAME,
           L_NET_AMOUNT,
           'U',
           'N',
           'N',
           'N',
           'FISDEV',
           TO_DATE(SYSDATE),
           L_GEN_VOUCHER_NO,
           'S',
           'SCHOLARSHIP 2016-2017',
           'N',
           '878-',
           'A',
           L_CO6_NO,
           'CC0080842',
           TO_DATE(SYSDATE),
           'HQXP',
           '05-MAR-15');
        INSERT INTO T_FIS_PAYMENT_DTL
          (PAYMENT_ID,
           LINE_NO,
           COMBINATION_ID,
           AMOUNT,
           DEBIT_CREDIT_FLAG,
           DELETE_FLAG,
           CREATED_BY,
           CREATION_DATE,
           REMARKS)
        VALUES
          (L_PAYMENT_ID,
           1,
           '16287',
           L_NET_AMOUNT,
           'D',
           'N',
           'FISDEV',
           TO_DATE(SYSDATE),
           'SCHOLARSHIP 2016-2017');
        L_COUNT1   := L_COUNT1 + 1;
        L_PARTY_ID := L_PARTY_ID + 1;
        L_CO6_NO   := L_CO6_NO + 1;
      END LOOP;
      DBMS_OUTPUT.PUT_LINE('TOTAL PARTY INSERTED======' || l_party_count);
      DBMS_OUTPUT.PUT_LINE('TOTAL SELECTED======' || L_COUNT);
      DBMS_OUTPUT.PUT_LINE('TOTAL INSERTED======' || L_COUNT1);
      DBMS_OUTPUT.PUT_LINE('LAST PAYMENT_NO===' || L_GEN_VOUCHER_NO);
      DBMS_OUTPUT.PUT_LINE('LAST PAYMENT_ID===' || L_PAYMENT_ID);
      DBMS_OUTPUT.PUT_LINE('LAST PARTY_ID===' || L_PARTY_ID);
      DBMS_OUTPUT.PUT_LINE('LAST CO6 NO===' || L_CO6_NO);
    END;

    **Here the error what shows when i tried to execute this procedure.**

    SQL> exec SPR_FIS_SCHOLARSHIP_INSERT('14-feb-2017');
    begin SPR_FIS_SCHOLARSHIP_INSERT('14-feb-2017'); end;
    ORA-06550: line 1, column 7:
    PLS-00905: object FIS.SPR_FIS_SCHOLARSHIP_INSERT is invalid
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored

3 个答案:

答案 0 :(得分:0)

ora-06550 error。当您尝试执行无效的PLSQL代码块(如存储过程或函数)但发生编译错误时,会出现此错误。

所以你的代码没有正确编译。您可以show error检查SQLPLUS中的错误。

当您使用ToadPLSQL developer等客户端并尝试编辑存储过程时,它会提供message PLSQL block compiled with error,这并不意味着它已正确编译。

答案 1 :(得分:0)

坚持......

 L_CO6_NO         VARCHAR2(10) := 0;

如果不是在编译时,可能会在运行时发出错误。可能就是这样。

答案 2 :(得分:0)

该过程确实存在编译错误,如原始错误堆栈中所述:

SQL> exec SPR_FIS_SCHOLARSHIP_INSERT('14-feb-2017');
begin SPR_FIS_SCHOLARSHIP_INSERT('14-feb-2017'); end;
ORA-06550: line 1, column 7:
PLS-00905: object FIS.SPR_FIS_SCHOLARSHIP_INSERT is invalid

在SQL * Plus中使用以下命令或等效命令来显示错误:

show errors procedure spr_fis_scholarship_insert

游标c1c_name从tmp_scholarship_data中选择名称,但在您的一条评论中,似乎该表似乎只有student_name列,而不是name

循环开始for i in c_name loop指的是i.namei.bank_account_numberi.bank_namei.ifsc_code,但游标c_name只有student_name

您将字符串'05-MAR-15'插入dept_payorder_date,并将'14-feb-2017'作为p_entry_date传递,但可能它们应该是date '2015-03-05'date '2017-02-14'之类的日期。此外,代码在几个地方使用to_date(sysdate),我猜测它是trunc(sysdate)。但是这些是运行时问题而不是编译错误。

可能还有其他问题,但我没有M_FIS_PARTY,T_FIS_PAYMENT_HDR和T_FIS_PAYMENT_DTL的定义。 (我可以为sfn_adm_generate_seqno和sfn_fis_generate_vouchernumber创建虚函数。顺便说一下,为什么不包含所有这些?)