Plsql 如何使用JSON返回ORD中的大文本(超过32k)
我正在Oracle ORDS中创建一个Rest API,需要返回大于32k的base64文本。源类型是PL/SQL 原始数据位于CLOB变量中,但ORDS不支持这种返回。我尝试使用LONG,但当字符串大于32k时,我无法将其移动到LONGPlsql 如何使用JSON返回ORD中的大文本(超过32k),plsql,oracle-ords,Plsql,Oracle Ords,我正在Oracle ORDS中创建一个Rest API,需要返回大于32k的base64文本。源类型是PL/SQL 原始数据位于CLOB变量中,但ORDS不支持这种返回。我尝试使用LONG,但当字符串大于32k时,我无法将其移动到LONG 我试图将内容从CLOB移到LONG,但没有成功 我尝试用我需要的文本创建两个长变量,并将其连接到长变量以输出它,但也没有成功 我能够在ResultSet中返回内容,但这会使Json结构与我需要的不同 --:boleto是ORDS中的OUT参数(OUT、RE
- 我试图将内容从CLOB移到LONG,但没有成功
- 我尝试用我需要的文本创建两个长变量,并将其连接到长变量以输出它,但也没有成功
- 我能够在ResultSet中返回内容,但这会使Json结构与我需要的不同
OPEN :boleto FOR
SELECT out_hexa as dados from dual;
In this case the output is:
{
"boleto": [
{
"dados": "JVBERi0xLjQKMSAwIG9iago8PAovVGl0bGUgKP7..."
}
]
}
What I need is a Json in this format:
{
"boleto": "JVBERi0xLjQKMSAwIG9iago8PAovVGl0bGUgKP7..."
}
找不到一种自动执行的方法,所以我自己编写Json。 我正在分块阅读CLOB并使用HTP.prn编写它:
OWA_UTIL.mime_header('application/json', FALSE);
OWA_UTIL.http_header_close;
htp.prn('{');
htp.prn('"return_code" : "' ||out_status || '",');
htp.prn('"return_message" : "' ||out_msg_retorno || '",');
htp.prn('"boleto" : "');
IF(out_status = '001') THEN
:http_status := 200;
WHILE counter < length(out_hexa)+chunk_size LOOP
htp.prn(substr(out_hexa, counter, chunk_size));
counter := counter+chunk_size;
END LOOP;
ELSE
:http_status := 404;
END IF;
htp.prn('"}');
OWA_UTIL.mime_头('application/json',FALSE);
OWA_UTIL.http_头\u关闭;
htp.prn('{');
htp.prn(“'return|u code”:“'| out|u status | |',”);
htp.prn(“'return|u message:“'out|u msg|u returno |',”);
htp.prn(“‘boleto’:”);
如果(输出状态='001'),则
:http_状态:=200;
而计数器
ords确实支持返回的LOB,将源类型设置为media resource,将mime类型设置为application/base64-类似这样的Hi,好的,但在这种情况下,我需要返回“application/json”mime类型,一个字段的内容将是base64字符串。。。。有什么想法吗?谢谢自己生成json是的,就是这样。。。我正在自己编写Json及其工作原理。谢谢
--This wont work:
:boleto := substr(out_hexa, 1, 32765) || substr(out_hexa, 32765, LENGTH(out_hexa));
OPEN :boleto FOR
SELECT out_hexa as dados from dual;
In this case the output is:
{
"boleto": [
{
"dados": "JVBERi0xLjQKMSAwIG9iago8PAovVGl0bGUgKP7..."
}
]
}
What I need is a Json in this format:
{
"boleto": "JVBERi0xLjQKMSAwIG9iago8PAovVGl0bGUgKP7..."
}
OWA_UTIL.mime_header('application/json', FALSE);
OWA_UTIL.http_header_close;
htp.prn('{');
htp.prn('"return_code" : "' ||out_status || '",');
htp.prn('"return_message" : "' ||out_msg_retorno || '",');
htp.prn('"boleto" : "');
IF(out_status = '001') THEN
:http_status := 200;
WHILE counter < length(out_hexa)+chunk_size LOOP
htp.prn(substr(out_hexa, counter, chunk_size));
counter := counter+chunk_size;
END LOOP;
ELSE
:http_status := 404;
END IF;
htp.prn('"}');