I want to convert and insert a local json clob variable into a table like this:
insert into IMP_JSON
select json_name, json_value
from json_table (
l_clob format json,
'$[*]' error on error columns (
json_name varchar2(32) path '$.name' null on empty,
json_value varchar2(32) path '$.value' null on empty
)
)
With this code, I get an error message
The provided JavaScript Object Notation (JSON) operator generated a result which exceeds the maximum length specified in the RETURN clause. Increase the maximum size of the data type in the RETURNING clause or use a CLOB or BLOB in the RETURNING clause.
I couldn't find how to include a RETURNING
clause in json_table
, but if I skip error on error
and run the procedure, the resulting table seems complete and not truncated.
error on error
, or might it truncate the data for other inputs?RETURNING
clause to json_table?json_value
function you used will return varchar2(4000) by default.
To extend it, you can use returning
clause as the error message already suggests. Using returning, your query should be:
INSERT INTO IMP_JSON
SELECT json_name, json_value
FROM json_table (
l_clob format json,
'$[*]' error on error columns (
json_name varchar2(32000) path '$.name' null on empty,
json_value varchar2(32000) path '$.value' null on empty
)
);
Another note, if you still get the error
SQL Error: ORA-00910: specified length too long for its datatype
It means your DB parameter max_string_size
might be standard
.
You can check it:
SELECT name, value
FROM v$parameter
WHERE name = 'max_string_size';
And you might need to set it to extended
.