今天要查询clob类型字段为空的记录。颇费一番周折才找到一个方法,记录以供参考。
select s.testcaseid from b_t_testcasestepinfo s where pjid = '2013WARD120006'
and actorphase = 1
and not (s.stepid = 1 and s.stepaction6 not like '%') and s.stepresult6 not like '%';
注:
1、stepaction6为clob类型。
2、该脚本在PLSQL developer工具上执行报错,在Oracle SQL Developer上可以执行。
3、直接s.stepresult6 like ''不能查询到想要的结果
看到一些关于此类查询的文章, 推荐建立oracle全文索引,再使用contains函数,效率是更高的。
参考文章如下:
http://www.iteye.com/problems/64807
http://blog.csdn.net/pathuang68/article/details/4093665