2012-10-09 81 views
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命令未正確結束

  • ORA-00933:SQL命令不能正確地結束
  • 錯誤:PL/SQL:忽略

SQL語句(誤差在選擇查詢,只)

+1

DON」關注美國。 [你從前面的問題中學到了嗎?](http://stackoverflow.com/q/12793389/1369235) – hims056

回答

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 
+0

@priyanka:如果你已經知道,你需要小心你的大括號,你與查詢帖子只有查詢有一些問題。 –

+0

感謝gaurav。這是我正在做的唯一愚蠢的錯誤。 –

相關問題