Advertisement
Guest User

Untitled

a guest
May 21st, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. drop table xmlu;
  2. CREATE TABLE xmlu (num NUMBER, dat CLOB)
  3. /
  4.  
  5. DECLARE
  6. request UTL_HTTP.REQ;
  7. response UTL_HTTP.RESP;
  8. n NUMBER;
  9. buff VARCHAR2(4000);
  10. clob_buff CLOB;
  11.  
  12. PROCEDURE getXML(url VARCHAR2) as
  13. BEGIN
  14. UTL_HTTP.SET_RESPONSE_ERROR_CHECK(FALSE);
  15. request := UTL_HTTP.BEGIN_REQUEST(url, 'GET' ,'HTTP/1.1');
  16. UTL_HTTP.SET_HEADER(request, 'User-Agent', 'Mozilla/4.0');
  17. response := UTL_HTTP.GET_RESPONSE(request);
  18. DBMS_OUTPUT.PUT_LINE('Statusul este: ' || response.status_code);
  19.  
  20. IF response.status_code = 200 THEN
  21. BEGIN
  22. clob_buff := EMPTY_CLOB;
  23. LOOP
  24. UTL_HTTP.READ_TEXT(response, buff, LENGTH(buff));
  25. clob_buff := clob_buff || buff;
  26. DBMS_OUTPUT.PUT_LINE(clob_buff);
  27. END LOOP;
  28.  
  29. UTL_HTTP.END_RESPONSE(response);
  30. EXCEPTION
  31. WHEN UTL_HTTP.END_OF_BODY THEN
  32. UTL_HTTP.END_RESPONSE(response);
  33. END;
  34.  
  35. ELSE
  36. DBMS_OUTPUT.PUT_LINE('FAIL');
  37. UTL_HTTP.END_RESPONSE(response);
  38. END IF;
  39. END getXML;
  40. BEGIN
  41. getXML('freegeoip.net/xml/82.39.109.147');
  42. END;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement