Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- drop table xmlu;
- CREATE TABLE xmlu (num NUMBER, dat CLOB)
- /
- DECLARE
- request UTL_HTTP.REQ;
- response UTL_HTTP.RESP;
- n NUMBER;
- buff VARCHAR2(4000);
- clob_buff CLOB;
- PROCEDURE getXML(url VARCHAR2) as
- BEGIN
- UTL_HTTP.SET_RESPONSE_ERROR_CHECK(FALSE);
- request := UTL_HTTP.BEGIN_REQUEST(url, 'GET' ,'HTTP/1.1');
- UTL_HTTP.SET_HEADER(request, 'User-Agent', 'Mozilla/4.0');
- response := UTL_HTTP.GET_RESPONSE(request);
- DBMS_OUTPUT.PUT_LINE('Statusul este: ' || response.status_code);
- IF response.status_code = 200 THEN
- BEGIN
- clob_buff := EMPTY_CLOB;
- LOOP
- UTL_HTTP.READ_TEXT(response, buff, LENGTH(buff));
- clob_buff := clob_buff || buff;
- DBMS_OUTPUT.PUT_LINE(clob_buff);
- END LOOP;
- UTL_HTTP.END_RESPONSE(response);
- EXCEPTION
- WHEN UTL_HTTP.END_OF_BODY THEN
- UTL_HTTP.END_RESPONSE(response);
- END;
- ELSE
- DBMS_OUTPUT.PUT_LINE('FAIL');
- UTL_HTTP.END_RESPONSE(response);
- END IF;
- END getXML;
- BEGIN
- getXML('freegeoip.net/xml/82.39.109.147');
- END;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement