select * from dual where null like '%*%'
no record found.
在做一个数据处理的应用的时候,因为忽略了这个,导致数据被多多处理了。
一下是出问题的SQL:
update CR_VIP_BKG_VIEW_LOAD d
set d.total_cntr_qntt = null,
d.total_cntr_qntt_20 = null,
d.total_cntr_qntt_40 = null,
d.total_cntr_qntt_40_hq = null,
d.total_cntr_qntt_45_hq = null,
d.total_cntr_qntt_other = null
where rowid not in
(SELECT MAX(ROWID)
from CR_VIP_BKG_VIEW_LOAD d
WHERE (d.cntr_check_digit not like '%*%' or
d.cntr_check_digit is null)
GROUP BY d.bkg_num, d.svc_prod_comp_id);
红色的谓词是改正之后的。因为缺失了对NULL的处理以及 NOT IN的条件,导致update语句更新了多于预期的数据条数,导致了bug.
写在这里是为了供日后更好的参考
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/8520577/viewspace-760773/
,如需转载,请注明出处,否则将追究法律责任。