fork download
  1. FUNCTION SEND_QUERY(a_url varchar2,
  2. a_proc_name varchar2,
  3. a_xml clob,
  4. a_log_id number default null) RETURN clob AS
  5.  
  6. l_blob blob := convert_to_blob(a_xml, 'AL32UTF8');
  7.  
  8. l_http_request UTL_HTTP.req;
  9. l_http_response UTL_HTTP.resp;
  10.  
  11. l_varchar2_response varchar2(32767);
  12. l_buff raw(32767);
  13.  
  14. -- l_return xmltype;
  15. l_dpd_xml_log_id number;
  16.  
  17. l_cnt number;
  18. l_offset number;
  19.  
  20. BEGIN
  21. if a_log_id is null then
  22. l_dpd_xml_log_id := spsr_xml_log_seq.nextval;
  23. else
  24. l_dpd_xml_log_id := a_log_id;
  25. end if;
  26.  
  27. xml_loger(l_dpd_xml_log_id, a_proc_name, xmltype(a_xml));
  28.  
  29. --формируем HTTP запрос
  30. l_http_request := UTL_HTTP.begin_request(a_url, 'POST', 'HTTP/1.1');
  31. --проставим заголовки
  32. UTL_HTTP.set_header(l_http_request, 'Content-Type', 'text/xml');
  33. UTL_HTTP.set_header(l_http_request,
  34. 'Content-Length',
  35. dbms_lob.getlength(l_blob));
  36. --тут циклом читаем clob который надо передать и кусками передаем через HTTP соединение
  37. l_cnt := 32767;
  38. l_offset := 1;
  39. loop
  40. dbms_lob.read(l_blob, l_cnt, l_offset, l_buff);
  41. UTL_HTTP.write_raw(l_http_request, l_buff);
  42. l_offset := l_offset + l_cnt;
  43. exit when l_cnt < 32767;
  44. end loop;
  45. --получаем HTTP ответ
  46. l_http_response := UTL_HTTP.get_response(l_http_request);
  47.  
  48. UTL_HTTP.read_text(l_http_response, l_varchar2_response);
  49.  
  50. -- dbms_output.put_line(l_varchar2_response);
  51.  
  52. UTL_HTTP.end_response(l_http_response);
  53.  
  54. xml_loger(l_dpd_xml_log_id,
  55. a_proc_name,
  56. XMLTYPE.createxml(l_varchar2_response));
  57.  
  58. RETURN l_varchar2_response;
  59. END;
Success #stdin #stdout #stderr 0s 3448KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Error: near line 1: near "FUNCTION": syntax error
Error: near line 8: near "l_http_request": syntax error
Error: near line 9: near "l_http_response": syntax error
Error: near line 11: near "l_varchar2_response": syntax error
Error: near line 12: near "l_buff": syntax error
Error: near line 15: near "l_dpd_xml_log_id": syntax error
Error: near line 17: near "l_cnt": syntax error
Error: near line 18: near "l_offset": syntax error
Error: near line 20: near "if": syntax error
Error: near line 23: near "else": syntax error
Error: near line 25: near "if": syntax error
Error: near line 27: near "xml_loger": syntax error
Error: near line 30: near "l_http_request": syntax error
Error: near line 32: near "UTL_HTTP": syntax error
Error: near line 33: near "UTL_HTTP": syntax error
Error: near line 37: near "l_cnt": syntax error
Error: near line 38: near "l_offset": syntax error
Error: near line 39: near "loop": syntax error
Error: near line 41: near "UTL_HTTP": syntax error
Error: near line 42: near "l_offset": syntax error
Error: near line 43: near "exit": syntax error
Error: near line 44: near "loop": syntax error
Error: near line 46: near "l_http_response": syntax error
Error: near line 48: near "UTL_HTTP": syntax error
Error: near line 52: near "UTL_HTTP": syntax error
Error: near line 54: near "xml_loger": syntax error
Error: near line 58: near "RETURN": syntax error
Error: near line 59: cannot commit - no transaction is active