oracle 空串 比较

declare
  len_x integer;
  len_y integer;

begin

  select nvl(length(trim('')), 0) into len_x from dual;

  select nvl(length(trim(null)), 0) into len_y from dual;
 
  dbms_output.put_line('len_x=' || len_x);
  dbms_output.put_line('len_y=' || len_x);

  if len_x = len_y then
    dbms_output.put_line('1111');
  else
    dbms_output.put_line('2222');
  end if;
end;

例如:
if nvl(length(trim(p_posi_code)), 0) > 0 then
      v_query_sql := v_query_sql || ' and posi.code like ''%' ||
                     trim(p_posi_code) || '%''';
end if;

猜你喜欢

转载自vernonchen163.iteye.com/blog/1902626