ORA-40593: name conflicts were found during execution of DBMS_JSON.CREATE_VIEW: name

Viewed 55

When using JSON_DATAGUIDE to create a view:

declare
  dg clob;
BEGIN
  SELECT json_dataguide(json_document, dbms_json.FORMAT_HIERARCHICAL, dbms_json.pretty) into dg
  FROM STATION_INFORMATION;
 
  dbms_json.create_view('STATION_INFORMATION_VIEW', 'STATION_INFORMATION', 'JSON_DOCUMENT', dg);
END;
/

I get the following error:

ORA-40593: name conflicts were found during execution of DBMS_JSON.CREATE_VIEW
1 Answers

This happens when the dataguide uses the same JSON key name in more than one context. You can specify resolveNameConflicts => true to have it automatically make the names unique.

declare
  dg clob;
BEGIN
  SELECT json_dataguide(json_document, dbms_json.FORMAT_HIERARCHICAL, dbms_json.pretty) into dg
  FROM STATION_INFORMATION;
 
  dbms_json.create_view('STATION_INFORMATION_VIEW', 'STATION_INFORMATION', 'JSON_DOCUMENT', dg, resolveNameConflicts => true);
END;
/
Related