Oracle CLOB/BLOB empty和null是不一样的


select length(lob_col_name) from table where xxx;

如果是empty, 返回0, 是null的话, 返回null.

怎么在sqlplus中 insert empty lob?

insert empty_clob() into table(lob_col_name) 

insert empty_blob() into table(lob_col_name) 

怎么在JDBC中insert empty lob?

statement.setClob(index, oracle.sql.CLOB.getEmptyCLOB())

statement.setBlob(index, oracle.sql.CLOB.getEmptyBLOB())

怎么在JDBC中判断是 null Clob 还是 empty Clob?

无论是Oracle的CLOB.isEmptyLob还是JDBC的Clob.isEmptyLob都不靠谱, 需要用 Clob.length==0来判断, 需要注意: 是 length() 函数, 而不是 getLength() 函数  

if(value.isEmptyLob() || value.length()==0){


判断是否是 null, 直接用 JDBC的 Resulset.wasNull函数就可以了

我的环境是: Oracle 10G, ojdbc6.jar

smithfox | Wednesday 27 April 2011 at 4:04 pm | | Java       

two comments

prada iphone 6 plus cases

You might have a picture of your puppy on the screen the majority of the time, but put the boarding pass for your flight in the queue as well to make things easy when you get to the gate.

prada iphone 6 plus cases, (URL) - 23-04-’15 14:35
Fake Chanel Handbags

Ellwood writes that vertical integration means Vuitton not only owns its own factories, but the company also leases the space it uses for the LV mini boutiques you see on the selling floor of various department stores.

Fake Chanel Handbags, (URL) - 06-07-’15 18:08
(optional field)
(optional field)
为阻止垃圾广告, 请在提交评论前, 回答一个简单问题(Please answer an simple question)
Remember personal info?
Small print: All html tags except <b> and <i> will be removed from your comment. You can make links by just typing the url or mail-address.