How to Read Web Pages Using utl_http.request_pieces

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:

Please share this post Share on Facebook0Share on Google+0Share on LinkedIn0Share on Reddit0Tweet about this on Twitter

Gokhan Atil is a database administrator who has hands-on experience with both RDBMS and noSQL databases (Oracle, PostgreSQL, Microsoft SQL Server, Sybase IQ, MySQL, Cassandra, MongoDB and ElasticSearch), and strong background on software development. He is certified as Oracle Certified Professional (OCP) and is awarded as Oracle ACE (in 2011) and Oracle ACE Director (in 2016) for his continuous contributions to the Oracle users community.

2 Comments

  1. rohan

    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 Comment

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