How do I use PL/JSON's to_clob method?

2019-08-22 14:31发布

I have a procedure like the following:

procedure receive_json(in_json in json) is
  my_clob clob;
begin
  -- This line keeps returning "wong number or types: to_clob"
  in_json.to_clob(in_json, my_clob);

  -- rest of my procedure
end receive_json;

How do I get the to_clob method to actually put the JSON in my CLOB?

标签: pljson
1条回答
The star\"
2楼-- · 2019-08-22 15:36

PL/JSON does not manage the CLOB for you. You have to do that yourself:

procedure receive_json(in_json in json) is
  my_clob clob;
begin
  dbms_lob.createtemporary(my_clob, true);
  in_json.to_clob(my_clob, false, dbms_lob.lobmaxsize);

  -- do something with my_clob
  -- ...
  -- ...
  dbms_lob.freetemporary(my_clob);
end receive_json;

Note, also, that when calling to_clob on an instance of JSON it is not necessary to supply the instance as the first parameter.

查看更多
登录 后发表回答