oops, clicked submit too soon. I mean maybe one column has blank data and onther is null and maybe it's a different contraint that is failing?
Main Topics
Browse All TopicsUsing Oracle 11g and TOAD 9.7.2.5, I'm executing:
select *
from TestTable
where TestDate is null
but it's not giving me any results even though TestDate field has thousands of null entries.
I discovered the problem when TOAD failed to run "Copy data to another schema" because of a null column violation.
This problem appeared following my adding a date column with a not null constraint which Oracle 11 allowed me to do even though there were thousands of null (TestDate) entries.
I have worked around the copy problem by disabling the not null constraint in the destination table but why is my statement not returning any rows in the source schema?
After the copy, I ran the same statement (see above) in the destination schema and it brought back the results correctly however, as expected, it is not allowing me to enable the not null constraint.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
No rows were returned from the source.
Thousands of rows were returned, correctly, from the destination.
I'm perplexed as I can see no data in that column and the below statement also produces the above results:
select *
from TestTable
where trunc(TestDate) is null
How else can you see no data in a DATE type column and it not be null?
you'll need to file a ticket on metalink with oracle support.
clearly your source system is screwed up.
one last thought, do you have any rewrite options turned on? either query rewrite via materialized
views or advanced rewrite that may be running something instead of the SQL you expect?
assuming you don't then I suggest you submit the results of all of the above queries and the following ones to exhaustively show the source sytem's NULL's don't show up.
I wouldn't include anything from the destination system, since it's behaving properly it's not really part of the problem.
select *
from TestTable
minus
select *
from TestTable
where TestDate is not NULL
select count(*) from TestTable;
select count(*) from TestTable where TestDate is not NULL;
select count(*) from TestTable where TestDate is NULL;
select *
from TestTable
minus
select *
from TestTable
where TestDate is not NULL------------------- 0 rows
select count(*) from TestTable;----------------
select count(*) from TestTable where TestDate is not NULL;------------------- 24077
select count(*) from TestTable where TestDate is NULL;------------------- 0
According to TOAD 9.6.1.1's schema browser, the constraint is Enabled and Validated.
you'll have to contact Oracle support for that.
you can put a contraint on it, but it shouldn't have validated.
Can you post all of the DDL for the table and the constraints?
Are you sure the constraint is validated?
Are you sure the data has NULL's?
All of the results you've posted above indicate a system with a constraint that has no bad data.
If that's not the case, you MUST contact Oracle with a "Wrong Results" bug
Interestingly I ran the following SQL:
select to_char(TestDate , 'dd Mon yyyy')
from TestTable
where id = 20000
and it came back with '00 000 0000'
I then ran:
select count(*)
from TestTable
where to_char(TestDate , 'dd Mon yyyy') = '00 000 0000'
and it comes back with a count of all of the rows.
What is date '00 000 0000'? How did I produce it? How would I reproduce it?
Will the following SQL fix it without breaking anything:
update TestTable
set TestDate = null
where to_char(TestDate , 'dd Mon yyyy') = '00 000 0000'
I tried to run:
update TestTable
set TestDate = null
where to_char(TestDate , 'dd Mon yyyy') = '00 000 0000'
and it, quite rightly, will not let me violate the null constraint but why does "Copy data to another schema" try to copy null and not the date: '00 000 0000'?
Is this an Oracle or TOAD problem?
assuming your testtable has just one column (testdate)
the above should create 19 rows of invalid dates and then show them to you like...
TO_CHAR(TESTDATE,'YYYY
----------------------
0000-00-00 00:00:00 00
0000-00-00 00:00:00 00
0000-00-00 00:00:00 00
0000-00-00 00:00:00 00
0000-00-00 00:00:00 00
0000-00-00 00:00:00 00
0000-00-00 00:00:00 00
0000-00-00 00:00:00 00
0000-00-00 00:00:00 00
0000-00-00 00:00:00 00
0000-00-00 00:00:00 00
0000-00-00 00:00:00 00
0000-00-00 00:00:00 00
0000-00-00 00:00:00 00
0000-00-00 00:00:00 00
0000-00-00 00:00:00 00
0000-00-00 00:00:00 00
0000-00-00 00:00:00 00
0000-00-00 00:00:00 00
19 rows selected.
Here's a cute trick...
this shows Oracle actuall maintains the entirety of year 0 (which doesn't really exist)
and, is apparently a leap-year as far as Oracle is concerned since there are 366 days (8784 hours) of invalid dates
but, even though their is a "secret" year, you can't really use it because every point in time within it is 0000-00-00 00:00:00
SELECT n,
TO_CHAR(NEW_TIME( TO_DATE('1/1/1 00:00:00', 'yyyy/mm/dd hh24:mi:ss')
+ n / 24,
'GMT',
'EST'
),
'yyyy-mm-dd hh24:mi:ss BC'
)
FROM (SELECT level - 8800 n
FROM dual
connect by level < 8820 )
small clarification to my earlier post where I said year 0 didn't exist
actually year 0 does exist on astronomical calendars.
Oracle has a confused (arguably broken) calendar, because it does calculations as if it were an astronomical calendar (where there is a year 0) but it only supports dates in a AD/BC form (where there is not a year 0)
Business Accounts
Answer for Membership
by: sdstuberPosted on 2009-01-08 at 10:08:50ID: 23327878
are you sure the data has null and not simply "blank" data in it?