ORACLE的http访问

ORACLE利用UTL_HTTP包提供了访问HTTP的工具。

下面这段代码是网上找的,可以直接在plsql中运行。

declare

req UTL_HTTP.REQ;
resp UTL_HTTP.RESP;
val varchar2(32767);
begin

req := UTL_HTTP.BEGIN_REQUEST('http://www.sohu.com');
utl_http.set_header(req, 'Content-Type', 'text/html; charset=utf-8');--add this
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;

 

如果只是想调用某个url,可以用下面的语句

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

以上内容没有深究,有空再研究,先记录下来

 

posted @ 2016-08-09 20:09  blaast  阅读(3680)  评论(0编辑  收藏  举报