select count(*) into 会出现 no_data_found吗?
很久以前就遇到这个问题了,今天又碰到了,记录下。
在遇到这个问题之前,我会非常肯定说:不可能。
看个测试:
SQL> desc t
Name Null? Type
----------------------------------------- -------- ----------------------------
ID NUMBER
SQL>
SQL>
SQL>
SQL> select * from t;
ID
----------
1
2
3
4
5
6
7
8
9
10
10 rows selected.
SQL> select count(*) from t;
COUNT(*)
----------
10
SQL> select count(*) from t where id =0;
COUNT(*)
----------
0
SQL> select count(*) from t where id = 0 group by id;
no rows selected
SQL> select count(*) from t where id=1 group by id;
COUNT(*)
----------
1
事实就是这样,没有什么不可能。
补充一句,这里要区分“空值”和“空记录”。
发表于 白鳝 在 2008年12月30日, 09:38 上午 CST #
发表于 Kuru 在 2008年12月31日, 03:23 下午 CST #