Just for clarification: I had this similar issue with Oracle date values, found after converting from a legacy Oracle 8 database to Oracle 10. Here's the post in which I try to find the origins of this data. I also 'hacked' a fix into Oracle_Enhanced for this, it is in the mailinglist. Here's my last post from that thread:
OCI8::VERSION gives '1.0.6'.
When a date field is NULL in Oracle, it *is* retrieved as 'nil' by ruby-oci8. So that is working perfectly, also in the Oracle Enhanced code.
The problem occurs, when the date field value is not 'nil' nor filled with a valid date value: it is empty. An 'empty' date is returned as a datetime with only '0' values by OCI8. And this is where the problem occured.
I created the following SQL to get a better look at the data of a record that does work, and a record that causes the error:
select fllid, creation_datetime , nvl(creation_datetime, Sysdate), length(creation_datetime), to_char(creation_datetime) from filelist where fllid=959 or fllid=198
It outputs:
FLLID creation_datetime nvl() length() to_char()
----- ----------------- ------------------ -------- ---------
198 24-9-2009 13:49:38
959 9 00-000-00
The date with fllid '198' works perfectly and is treated as a 'nil' value by OCI and hence by the Oracle Adapter.
The date with fllid '959' is the one that will cause problems: As you can see, it IS 9 characters long (???) but it is not 'null' (indicated by the empty nvl(..) column) and it is displayed as an 'empty' date just like the date above! Only when converting it to 'char', the '0' values are shown...
I tried to create an insert statement that can reproduce a date like this, but have not succeeded so far. I already tried insert statements like this:
insert into datatest (id) values (1) -- just inserts as 'NULL'
insert into datatest (id, dt) values (2, '') -- just inserts as 'NULL'
insert into datatest (id, dt) values (5, to_date('00/00/0000','MM/DD/YYYY')) -- is not valid
insert into datatest (id, dt) values (5, to_date('01/01/4712 bc','DD/MM/YYYY bc')) -- inserts as normal date
insert into datatest (id, dt) VALUES (6, to_date( '00/00/0000 00:00:00 00', 'MM/DD/YYYY HH:MI:SS AM')) -- is not valid
So I'm really a bit at a loss here, how this data was inserted at all into the database, as you can imagine. I do know this Oracle 10 database was created by importing (with Oracle's imp.exe) an export (using Oracle's exp.exe) from a Oracle 8i database...