首页 > 数据库技术 > 详细

Oracle UTL_HTTP

时间:2020-01-04 16:35:42      阅读:104      评论:0      收藏:0      [点我收藏+]

Oracle 中可以通过包 UTL_HTTP 来获取访问 HTTP 的能力.

declare
  req  UTL_HTTP.REQ;
  resp UTL_HTTP.RESP;
  val  varchar2(32767);
begin
  req := UTL_HTTP.BEGIN_REQUEST('http://www.oracle.com');
  utl_http.set_header(req, 'Content-Type', 'text/html; charset=utf-8');
  resp := UTL_HTTP.GET_RESPONSE(req);
  utl_http.read_line(resp, val, true);
  utl_http.end_response(resp);
  dbms_output.put_line(val);
EXCEPTION
  WHEN utl_http.end_of_body THEN
    utl_http.end_response(resp);
end;

还可以直接在 select 中使用请求函数

select utl_http.request('http://www.sohu.com') from dual;

参考

Oracle UTL_HTTP

原文:https://www.cnblogs.com/taadis/p/12149408.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!