我必须构建一个following child json payload来补充main payload。我的问题是如何将这些数组放到一个clob中作为PSLQL参数传递。
代码:
Declare
l_children json_array_t;
p_clob CLOB
cursor getrec is select * from sometable;
begin
for i in getrec loop
select TO_CHAR(SYSTIMESTAMP,'mmddyyyyhhmiss') into l_doc_id from dual;
l_children.append(json_object_t('
{
"AttachedDocumentId": "'||l_doc_id||'",
"DatatypeCode": "TEXT",
"CategoryName": "INSTANCE_NUMBER",
"UploadedText": "'||i.instance_number||'",
"UploadedFileContentType": "text",
"ContentRepositoryFileShared": "false",
"Title": "'||i.instance_number||'",
"Description": "'||i.instance_number||'"
}'));
select TO_CHAR(SYSTIMESTAMP,'mmddyyyyhhmiss') into l_doc_id from dual;
l_children.append(json_object_t('
{
"AttachedDocumentId": "'||l_doc_id||'",
"DatatypeCode": "TEXT",
"CategoryName": "SERIAL_NUMBER",
"UploadedText": "'||i.attachment_serial_number||'",
"UploadedFileContentType": "text",
"ContentRepositoryFileShared": "false",
"Title": "'||i.attachment_serial_number||'",
"Description": "'||i.attachment_serial_number||'"
}'));
end loop;
p_Clob := l_children.to_clob; /* this won't work */
感谢Darsh
1条答案
按热度按时间4uqofj5v1#
不需要游标或循环;使用Oracle JSON函数:
其中,对于样本数据:
输出:
fiddle