SELECT COUNT(*) FROM Tab -> No Rows Selected
In the following SQL*Plus output…
SQL> select sum(tran_sum), count(*) 2 from trans; no rows selected
…something is goofed up. You should not have a no rows selected with this SQL.
When you see something like that for the first time, you can generally draw from four conclusions:
- Someone edited the output
- SQL*Plus bug
- Oracle bug
- Combination of the above
Since it was me who saw this, number one was an easy but irrelevant answer.
What about an SQL*Plus bug? OK, run this using some other ad hoc tool. Same result. Time to take a more precise look at the problem. What is trans?
SQL> select object_type from user_objects where object_name='TRANS'; OBJECT_TYPE ------------------- TABLE SQL> desc TRANS; Name Null? Type ------------- -------- ------- TRAN_ID NOT NULL NUMBER TRAN_SUM NOT NULL NUMBER
Table trans has two not null columns (of the number datatype). Couldn’t be simpler. Oracle can’t have a bug in such a simple case, so what’s the deal?
Could it be because what we see is not what we see? (more…)

