情况一:
select (case when trim(' ') is not null then 'not null' else 'is null' end) as age from dual;
输出结果:age: 'is null'
情况二:删除trim()
select (case when ' ' is not null then 'is null' else 'not null' end) as age from dual;
输出结果:age: 'not null'
由以上测试可以得出今后的判断条件为:
if (trim(nvl(var_name_str,''))='') then
begin
your operation;
end;
end if;
nvl用法:nvl(arg,value)代表如果前面的arg的值为null那么返回的值为后面的value
select (case when trim(' ') is not null then 'not null' else 'is null' end) as age from dual;
输出结果:age: 'is null'
情况二:删除trim()
select (case when ' ' is not null then 'is null' else 'not null' end) as age from dual;
输出结果:age: 'not null'
由以上测试可以得出今后的判断条件为:
if (trim(nvl(var_name_str,''))='') then
begin
your operation;
end;
end if;
nvl用法:nvl(arg,value)代表如果前面的arg的值为null那么返回的值为后面的value
本文通过两个具体示例对比了使用trim函数与不使用trim函数时SQL语句的输出结果差异,并给出了针对变量为空字符串时的有效处理方法。
2万+

被折叠的 条评论
为什么被折叠?



