ERROR - ORA-06502: PL/SQL: numeric or value error: character string buffer too small : I am getting the ORA 06502 Error while calling this query from PL/SQL.
However if i Try from sql prompt its working.      


******An error was encountered  - ERROR - ORA-06502: PL/SQL: numeric or value error: character string buffer too small******


           SELECT *
                      FROM
                  (
                   SELECT
                       COL.BAN,
                       MAX (COL.COL_ACTV_CODE) AS COL_ACTV_CODE,
                       MAX (TO_CHAR(COL.COL_ACTV_DATE,''MM'')) AS COL_ACTV_DATE
                   FROM
                       TABLE1               COL,
                       TABLE2    CAC,
                       ACD_DDR_CH               ADC
                   WHERE
                       COL.BAN              = ADC.BAN
                   AND
                       COL.COL_ACTV_CODE    = CAC.COL_ACTIVITY_CODE
                   AND
                       (CAC.SEVERITY_LEVEL , TO_CHAR(COL.COL_ACTV_DATE,''YYYYMM'')) IN
                        (
                          SELECT
                               MAX(CAC.SEVERITY_LEVEL),
                               MAX(TO_CHAR(COL.COL_ACTV_DATE, ''YYYYMM''))
                          FROM
                               TABLE1               COL,
                               TABLE2    CAC,
                               ACD_DDR_CH               ADC
                          WHERE
                               COL.BAN              = ADC.BAN
                          AND
                               COL.COL_ACTV_CODE    = CAC.COL_ACTIVITY_CODE
                          AND
                               COL.COL_ACTV_DATE <= TO_DATE(''&1'', ''YYYYMMDD'')
                          AND
                               COL.COL_ACTV_DATE >=
                               TRUNC(ADD_MONTHS(TO_DATE(''&1'', ''YYYYMMDD''),-11),''MON'')
                          GROUP BY  TO_CHAR (COL.COL_ACTV_DATE , ''YYYYMM'')
                         )
                    GROUP BY  COL.BAN
                    ORDER BY  TO_CHAR (COL.COL_ACTV_DATE , ''YYYYMM'') DESC
                     )
                     PIVOT
                    (
                       MAX( COL_ACTV_CODE)
                     FOR COL_ACTV_DATE in (''01'' as "JAN",
                      ''02'' as "FEB", ''03'' as "MAR",
                       ''04'' as "APR", ''05'' as "MAY", 
                       ''06'' as "JUN", ''07'' as "JUL", ''08'' as "AUG",
                        ''09'' as "SEP", ''10'' as "OCT", ''11'' as "NOV",
                         ''12'' as "DEC"))';


**The output from sql promt is as below:**

       BAN J F M A M J J A S O N D
---------- - - - - - - - - - - - -
  90314228                 W
  90314009     K
  90314748                     E
  90314568                   E
  90314328                 W

