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

◇◆丶佛笑我妖孽 提交于 2019-12-12 03:15:21

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/27348064/how-do-i-use-pl-jsons-to-clob-method

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!