UTL_HTTP package provides easy to use methods to fetch data from web using http protocol. Today, one of my co-workers complained that “utl_http.request” method returns only a small part of the web page instead of full html. She says she already uses it to fetch from other web pages without any problem. The utl_http.request method returns the requested page as a single string. When I check the documents, I see that it intentionally returns only first 2000 characters, and we should use “utl_http.request_pieces” method if we need to fetch more than 2000 characters. The UTL_HTTP.REQUEST_PIECES returns “utl_http.html_pieces” which is defined as a PLSQL table of 2000 character strings:

So I created a small function to demonstrate how we can fetch a web page using utl_http.request_pieces:

And tested it:

2 Responses to “How to Read Web Pages Using utl_http.request_pieces”

  1. Hi Gohan, Thanks a lot for the tip. I found it very useful.

  2. when I tried to run
    TYPE html_pieces IS TABLE OF VARCHAR2(2000) INDEX BY BINARY_INTEGER;

    I get an  error

    unknown command beginning “TYPE html_…” – rest of line ignored.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">