0
PROCEDURE PR_TRIAL_BAL_BULKWITHOUTCUR IS


VAR_OF_TYP_TBL TYP_TBL;

BEGIN
SELECT * BULK COLLECT INTO VAR_OF_TYP_TBL 
  FROM (SELECT NAME, SUM(CREDIT) AS CREDIT, SUM(DEBIT) AS DEBIT
          FROM (SELECT (SELECT GL_NAME
                          FROM QM_GL
                         WHERE QM_GL.GL_ID = QT_ACCOUNTING.GL_ID) AS NAME,
                       DECODE(QT_ACCOUNTING.TRANS_TYPE,
                              'CR',
                              (QT_ACCOUNTING.TRANS_AMOUNT),
                              0.00) AS CREDIT,
                       DECODE(QT_ACCOUNTING.TRANS_TYPE,
                              'DR',
                              (QT_ACCOUNTING.TRANS_AMOUNT),
                              0.00) AS DEBIT

                  FROM QT_ACCOUNTING, QM_ACCOUNTING_PERIOD

                 WHERE QT_ACCOUNTING.VALUE_DATE BETWEEN
                       QM_ACCOUNTING_PERIOD.PERIODFROM AND
                       QM_ACCOUNTING_PERIOD.PERIODTO
                   AND QM_ACCOUNTING_PERIOD.STATUS = 'O')
         GROUP BY NAME)
         );

FOR I IN 1 .. VAR_OF_TYP_TBL.COUNT LOOP

  IF (VAR_OF_TYP_TBL(I).CREDIT - VAR_OF_TYP_TBL(I).DEBIT) > 0 THEN
    INSERT INTO TBL_TRIAL_BALANCE_REPORT
    VALUES
      (VAR_OF_TYP_TBL(I).NAME,
       (VAR_OF_TYP_TBL(I).CREDIT - VAR_OF_TYP_TBL(I).DEBIT),
       0);
  END IF;
  IF (VAR_OF_TYP_TBL(I).DEBIT - VAR_OF_TYP_TBL(I).CREDIT) > 0 THEN
    INSERT INTO TBL_TRIAL_BALANCE_REPORT
    VALUES
      (VAR_OF_TYP_TBL(I).NAME,
       0,
       (VAR_OF_TYP_TBL(I).DEBIT - VAR_OF_TYP_TBL(I).CREDIT));
  END IF;

END LOOP;
VAR_OF_TYP_TBL.DELETE;

EXCEPTION
  WHEN OTHERS THEN
  DBMS_OUTPUT.PUT_LINE(SQLERRM);
  BEGIN
    VAR_OF_TYP_TBL.DELETE;
  EXCEPTION
    WHEN OTHERS THEN
      NULL;
  END;
END;

上記のコードの次のエラーはどこにあり、どのように削除できますか?

  • ORA-00933: SQLコマンドが正しく終了していません
  • エラー: PL/SQL: SQL文は無視されました

(エラーは選択クエリのみ)

4

1 に答える 1

1
    SELECT   *
      BULK   COLLECT
      INTO   VAR_OF_TYP_TBL
      FROM   (  SELECT   NAME, SUM (CREDIT) AS CREDIT, SUM (DEBIT) AS DEBIT
                  FROM   (SELECT   (SELECT   GL_NAME
                                      FROM   QM_GL
                                     WHERE   QM_GL.GL_ID = QT_ACCOUNTING.GL_ID)
                                      AS NAME,
                                   DECODE (QT_ACCOUNTING.TRANS_TYPE,
                                           'CR', (QT_ACCOUNTING.TRANS_AMOUNT),
                                           0.00)
                                      AS CREDIT,
                                   DECODE (QT_ACCOUNTING.TRANS_TYPE,
                                           'DR', (QT_ACCOUNTING.TRANS_AMOUNT),
                                           0.00)
                                      AS DEBIT
                            FROM   QT_ACCOUNTING, QM_ACCOUNTING_PERIOD
                           WHERE   QT_ACCOUNTING.VALUE_DATE BETWEEN QM_ACCOUNTING_PERIOD.PERIODFROM
                                                                AND  QM_ACCOUNTING_PERIOD.PERIODTO
                                   AND QM_ACCOUNTING_PERIOD.STATUS = 'O')
              GROUP BY   NAME);
          -- );       remove this from your code
于 2012-10-09T09:38:26.343 に答える