Skip to content

G-2330: Never use zero-length strings to substitute NULL.

Blocker

Portability, Reliability

Reason

Today zero-length strings and null are currently handled identical by the Oracle Database. There is no guarantee that this will still be the case in future releases, therefore if you mean null use null.

Example (bad)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
create or replace package body constants_up is
   co_null_string constant types_up.text := '';

   function null_string return varchar2
      deterministic
   is
   begin
      return co_null_string;
   end null_string;
end constants_up;
/

Example (good)

1
2
3
4
5
6
7
8
9
create or replace package body constants_up is
   function empty_string return varchar2
      deterministic
   is
   begin
      return null;
   end empty_string;
end constants_up;
/