最近,写oracle存储过程,和sql的不一样啊,sql 中select 就可以返回结果集,而oracle呢,得用指针(游标),写惯了sql语句,有点不适应.昨天,写好测试一存储过程,存储过程在开始时会对某个参数的长度进行判断

 


test varchar2(20) :='';
begin
if length(test)=0 then
  语句一
else
  语句二
end if;
end;

当test赋值''时,在sql中LEN(@test)=0,而在oracle中这个条件总是走到语句二,难道oracle中,length(test)不为0?只好测试看看了

 


test varchar2(20) :='';
begin
dbms_output.put_line(
's'||length(test)||'s');
dbms_output.put_line(
's'||nvl(test,0)||'s');
end;

/*
运行结果:
ss
s0s
*/

 

结论:

根据测试,在oracle中,将参数赋值'' 与 null 全部视为 null,因为对oracle是刚接触,可能有的地方得出的结论不正确,请大家指点啊.

 

相关文章:

  • 2021-07-01
  • 2022-12-23
  • 2021-10-24
  • 2021-10-25
  • 2022-12-23
  • 2021-06-22
  • 2022-01-30
  • 2022-12-23
猜你喜欢
  • 2021-11-01
  • 2021-11-20
  • 2022-02-27
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案