Oracle UTL_HTTP.Request_Pieces
-- PL/SQL Code to get http request pieces data
-- The output is a PL/SQL table of size 2000 bytes.
-- In the code below just 200 bytes are retreived.
-- Only first 3 pieces of data is displayed.

SET SERVEROUTPUT ON SIZE 1000000;

DECLARE
   v_html   UTL_HTTP.HTML_PIECES; 
   len      PLS_INTEGER := 0; 
BEGIN 
   -- The url is the only required value (others are optional)
   -- v_html := UTL_HTTP.REQUEST_PIECES('http://www.oracle.com/',
   --            200, NULL, NULL, NULL);

   v_html := UTL_HTTP.REQUEST_PIECES('http://www.oracle.com/', 200); 

   IF v_html.count < 1 THEN 
      DBMS_OUTPUT.PUT_LINE('No http Request_Pieces data'); 
   ELSE 
     FOR idx in 1..v_html.count LOOP 
       len := len + length(v_html(idx));
       IF idx < 3 THEN
         DBMS_OUTPUT.PUT_LINE(idx||' --> '||v_html(idx));
       END IF;
     END LOOP; 
    DBMS_OUTPUT.PUT_LINE(v_html.count || ' Pieces were retrieved ');
    DBMS_OUTPUT.PUT_LINE('with a  Content Size (Length) of --> '||len);  
   END IF; 
END; 
/

Figure 1: Oracle UTL_HTTP.Request_Pieces Output
Oracle UTL_HTTP.Request_Pieces Output

Oracle registered trademark of Oracle Corporation.

Last Revised On: August 10, 2014

  1442