C:\Users\123>sqlplus scott/system
SQL*Plus: Release 11.2.0.1.0 Production on Tue Jan 22 16:53:44 2013
Copyright (c) 1982, 2010, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> create table t_substr(a varchar2(10));
Table created.
SQL> insert into t_substr values(null);
1 row created.
SQL> insert into t_substr values('zxy');
1 row created.
SQL> commit;
Commit complete.
SQL> select * from t_substr;
A
--------------------
--------------------
zxy
SQL> select substr(a,1,2) from t_substr;
SUBSTR(A,1,2)
----------------
----------------
zx
SQL> select substr(null,1,2) from dual;
S
-
SQL> select substr(null,1,2) from t_substr;
S
-
S
-
SQL> select substr(null,1,2) from t_substr;
S
-
小结:
1,如变量值为null,substr运行不会报错,可以正常处理
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/9240380/viewspace-753051/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/9240380/viewspace-753051/