Thursday, June 05, 2025

JSON_OBJECT_T.GET_CLOB(key) returns the string 'null' if the value is null

Discovery of the day on Oracle 19 version EE 19.21.0.0.0:

JSON_OBJECT_T.GET_CLOB(key) member function returns a CLOB string containing 'null' (lowercase), not a NULL value.

As you can see below the 'null' string is matched by the function NULLIF which replaces it with a real NULL value:

set serveroutput on
declare
  l_procedure clob;
  j_job_desc       json_object_t;
begin
  j_job_desc := json_object_t.parse('{"procedure":null}');
  l_procedure := nullif(j_job_desc.get_clob('procedure'),'null');
  if l_procedure is null then
    dbms_output.put_line('nothing');
  else
    dbms_output.put_line(l_procedure);
  end if;
end;
/

nothing


PL/SQL procedure successfully completed.
The documentation doesn't explain this behavior at all, it just says that the member function will create a CLOB implicitly and that's all,

No comments:

yes you can!

Two great ways to help us out with a minimal effort. Click on the Google Plus +1 button above or...
We appreciate your support!

latest articles