Ini sebenarnya bug di Oracle 10.5.0.2 dan 11.2.0.1.
Bug dapat direproduksi sebagai berikut:
setel NLS_TIMESTAMP_FORMAT dalam sesi.
Jalankan konversi TO_DATE implisit atau eksplisit dengan data unicode.
TO_TIMESTAMP implisit atau eksplisit berikutnya dengan data unicode akan memicu reset internal format stempel waktu.
Semua TO_TIMESTAMP berturut-turut akan gagal dan TO_CHAR stempel waktu akan menghasilkan keluaran yang tidak valid.
Berikut adalah kode untuk menguji perilaku:
ALTER SESSION SET NLS_TERRITORY = 'AMERICA';
ALTER SESSION SET NLS_DATE_FORMAT = 'YYYY-MM-DD HH24:MI:SS' NLS_TIMESTAMP_FORMAT = 'YYYY-MM-DD HH24:MI:SS.FF';
REM --- WORKS:
SELECT TO_TIMESTAMP('2013-06-24 18:15:10.312') FROM DUAL;
REM --- WORKS:
SELECT TO_DATE('2013-06-24 18:15:10') FROM DUAL;
REM --- WORKS:
SELECT TO_TIMESTAMP('2013-06-24 18:15:10.312') FROM DUAL;
REM --- WORKS:
SELECT TO_TIMESTAMP(x) FROM (SELECT CAST('2013-06-24 18:15:10.312' AS NVARCHAR2(30)) AS X FROM DUAL);
REM --- WORKS:
SELECT TO_DATE(x) FROM (SELECT CAST('2013-06-24 18:15:10' AS NVARCHAR2(30)) AS X FROM DUAL);
REM --- WORKS:
SELECT TO_TIMESTAMP('2013-06-24 18:15:10.312') FROM DUAL;
REM !!! FAILS!
SELECT TO_TIMESTAMP(x) FROM (SELECT CAST('2013-06-24 18:15:10.312' AS NVARCHAR2(30)) AS X FROM DUAL);
REM !!! FAILS!
SELECT TO_TIMESTAMP('2013-06-24 18:15:10.312') FROM DUAL;
REM --- WORKS:
SELECT TO_DATE('2013-06-24 18:15:10') FROM DUAL;