gpt4 book ai didi

sql - 在utl_http.req中发送长度为32000的CLOB数据会抛出ORA :06052 POST method

转载 作者:行者123 更新时间:2023-12-03 09:25:43 25 4
gpt4 key购买 nike

我正在尝试从 PL/SQL 发送 XML 作为 URL 参数。但是当我尝试发送它时,出现错误“ORA:06052”。下面是PL/SQL代码

      CREATE OR REPLACE FUNCTION EMASDB.ESIGN(TY IN VARCHAR2,DATA1 IN CLOB,DATA2 IN CLOB) RETURN clob
IS
XML CLOB;
v_data_post CLOB;
resp utl_http.resp;
req utl_http.req;
v_txt CLOB;
BEGIN
IF TY='REGISTER' THEN
XML:='<register><uniqueid>'||DATA2||'</uniqueid><DATA1>'||DATA1||'</DATA1><userEnable>true</userEnable><originalContent>'||DATA2||'</originalContent></register>';
ELSIF TY='AUTHENTICATE' THEN
XML :='<AuthenticateDet><uniqueId>'||DATA2||'</uniqueId><DATA1>'||DATA1||'</DATA1><originalContent>'||DATA2||'</originalContent><referenceNo></referenceNo></AuthenticateDet>';
ELSE
XML :='<verifyDet><dataType>pkcs7</dataType><DATA1>'||DATA1||'</DATA1><originalContent>'||DATA2||'</originalContent><responseFormat>plain</responseFormat></verifyDet>';
DBMS_OUTPUT.PUT_LINE('A');
END IF;
req := UTL_HTTP.begin_request ('url','POST','HTTP/1.1');
utl_http.set_header(req, 'Content-Type', 'application/x-www-form-urlencoded');
utl_http.set_header(req, 'Content-Length', length(XML));
v_data_post :='xml='||XML;
/*utl_http.write_text(req, v_data_post);
resp := UTL_HTTP.get_response(req);
utl_http.read_text(resp,v_txt);
utl_http.end_response(resp);
RETURN v_txt;*/
RETURN 'done';
END;
/

最佳答案

当您需要在 utl_http 中写入(和读取)超过 32k 时,它的做法会有所不同。

例如:

l_data := 'fill with some sample piece of text';
http_req := utl_http.begin_request(url => 'http://example.com', method => 'POST');
utl_http.set_header (http_req, 'Content-Length', length(l_data));
utl_http.set_header (http_req, 'Content-Type', 'text/xml;charset=UTF-8');
utl_http.set_header (http_req, 'Transfer-Encoding', 'chunked');

loop
l_chunkData := null;
l_chunkData := substr(l_data, l_chunkStart, l_chunkLength);
utl_http.write_text(http_req, l_chunkData);
if (length(l_chunkData) < l_chunkLength) then exit; end if;
l_chunkStart := l_chunkStart + l_chunkLength;
end loop;

参见:http://www.kurzhals.info/2012/03/using-chunked-transfer-with-plsql-utl_http-write_text.html

有关 clob 示例,请参阅:http://blog.optiosys.com/?p=246

关于sql - 在utl_http.req中发送长度为32000的CLOB数据会抛出ORA :06052 POST method,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21643294/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com