Argument out of range error I have this query:

WITH
  I1 AS
  (
    SELECT
      *
    FROM
      XYZ A
    WHERE
      UPPER(A.DES) LIKE '%%' ESCAPE '\'  --'
      AND NVL(A.END_DATE, TO_DATE('9999-12-31', 'YYYY-MM-DD')) &gt;= TO_DATE('2016-06-01', 'YYYY-MM-DD')
      AND NVL(A.END_DATE, TO_DATE('9999-12-31', 'YYYY-MM-DD')) &gt;= TO_DATE('2016-06-08', 'YYYY-MM-DD')
      AND A.ID_OU IS NOT NULL
    ORDER BY
      IDFR
  ),
  I2 AS
  (
    SELECT
      I1.IDFR, I1.DES, I1.ID_OU,D1.VAL, T1.CODE
    FROM
      ABC D1, I1, DEF T1
    WHERE
      D1.IDFR = T1.IDFR
      AND D1.IDFR = I1.IDFR
  ),
  I3 AS
  (
    SELECT I2.* FROM I2
  ),
  I4 AS
  (
    SELECT
      *
    FROM
      I3
      PIVOT
      (
        MAX(VAL) AS VAL FOR CODE IN ('AB' AS ABC , 'XY' AS XY)
      )
    ORDER BY
      DES
  ),
  I5 AS
  (
    SELECT COUNT(*) TOTAL_NO_ROWS FROM I4
  ),
  I6 AS
  (
    SELECT I4.*, rownum row_number FROM I4
  )
SELECT
  I6.*,  I5.TOTAL_NO_ROWS
FROM
  I5, I6
WHERE
  row_number &gt; 0 AND row_number &lt; 3;


Sometimes it runs fine, but other times it throws this error:


  ORA-01428: argument '000000000000000000000000' is out of range


I implemented the same structure and data in another database (similar database configuration) and didn't face such error.

How to resolve this issue?
One possible reason:

Bug 18162779 : ORA-01428: ARGUMENT '000000000000000000' IS OUT OF RANGE

Try running the query after setting the below:

alter session set  "_disable_function_based_index" = TRUE;