Here is one method (but you better track down the program that is causing the issue in the first place or the bad dates will just keep coming back!)
ops$ora734@ORA734.WORLD> select x, y, dumpx, to_char(x,'dd-mon-yyyy hh24:mi:ss' ) dt,
2 substr( dumpx, first_comma+1, second_comma-first_comma-1 ) hour,
3 substr( dumpx, second_comma+1, third_comma-second_comma-1 ) minute,
4 substr( dumpx, third_comma+1 ) second
5 from (select x, y, dump(x) dumpx,
6 instr(dump(x),',',1,4) first_comma,
7 instr(dump(x),',',1,5) second_comma,
8 instr(dump(x),',',1,6) third_comma
9 from test_date_tbl )
10 /
ERROR:
ORA-01801: date format is too long for internal buffer
no rows selected
ops$ora734@ORA734.WORLD> select x, y, dumpx,
2 substr( dumpx, first_comma+1, second_comma-first_comma-1 ) hour,
3 substr( dumpx, second_comma+1, third_comma-second_comma-1 ) minute,
4 substr( dumpx, third_comma+1 ) second
5 from (select x, y, dump(x) dumpx,
6 instr(dump(x),',',1,4) first_comma,
7 instr(dump(x),',',1,5) second_comma,
8 instr(dump(x),',',1,6) third_comma
9 from test_date_tbl )
10 /
X Y DUMPX HOUR MINU SECO
--------- ---------- -------------------- ---- ---- ----
03-APR-00 1 Typ=12 Len=7: 120,10 100 123 123
0,4,3,100,123,123
29-NOV-01 2 Typ=12 Len=7: 120,10 10 6 5
1,11,29,10,6,5
<b>we have one good date, one bad date (y=1 is bad)</b>
ops$ora734@ORA734.WORLD> update
2 (select x, y, dump(x) dumpx,
3 instr(dump(x),',',1,4) first_comma,
4 instr(dump(x),',',1,5) second_comma,
5 instr(dump(x),',',1,6) third_comma
6 from test_date_tbl )
7 set x = trunc(x) + 8/24
8 where NOT substr( dumpx, first_comma+1, second_comma-first_comma-1 ) between 1 and 24 OR
9 NOT substr( dumpx, second_comma+1, third_comma-second_comma-1 ) between 1 and 60 OR
10 NOT substr( dumpx, third_comma+1 ) between 1 and 60
11 /
1 row updated.
ops$ora734@ORA734.WORLD> select x, y, dumpx, to_char(x,'dd-mon-yyyy hh24:mi:ss' ) dt,
2 substr( dumpx, first_comma+1, second_comma-first_comma-1 ) hour,
3 substr( dumpx, second_comma+1, third_comma-second_comma-1 ) minute,
4 substr( dumpx, third_comma+1 ) second
5 from (select x, y, dump(x) dumpx,
6 instr(dump(x),',',1,4) first_comma,
7 instr(dump(x),',',1,5) second_comma,
8 instr(dump(x),',',1,6) third_comma
9 from test_date_tbl )
10 /
X Y DUMPX DT HOUR MINU SECO
--------- ---------- -------------------- -------------------- ---- ---- ----
03-APR-00 1 Typ=12 Len=7: 120,10 03-apr-2000 08:00:00 9 1 1
0,4,3,9,1,1
29-NOV-01 2 Typ=12 Len=7: 120,10 29-nov-2001 09:05:04 10 6 5
1,11,29,10,6,5
ops$ora734@ORA734.WORLD> rollback;
Rollback complete.
<b>Now they are all "good"</b>