Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Unable to log the Timeout Exception

Arun ThomasAug 19 2015 — edited Aug 19 2015

Hi Friends,

please help me in finding the issue with this code, am setting the timeout for 2 secs. but the code is running for a minute and it's going to "When others" instead of "When UTL_HTTP.transer_timeout" PFB the code.

DECLARE

   request     UTL_HTTP.REQ;

   response    UTL_HTTP.RESP;

   n           NUMBER;

   buff        VARCHAR2 (4000);

   clob_buff   CLOB;

BEGIN

   UTL_HTTP.SET_RESPONSE_ERROR_CHECK (FALSE);

  UTL_HTTP.set_transfer_timeout (2);

   request := UTL_HTTP.BEGIN_REQUEST ('www.google.com:81', 'GET');

   UTL_HTTP.SET_HEADER (request, 'User-Agent', 'Mozilla/4.0');

   response := UTL_HTTP.GET_RESPONSE (request);

   DBMS_OUTPUT.PUT_LINE (

      'HTTP response status code: ' || 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;

         END LOOP;

         UTL_HTTP.END_RESPONSE (response);

      EXCEPTION

         WHEN UTL_HTTP.END_OF_BODY

         THEN

            UTL_HTTP.END_RESPONSE (response);

         WHEN OTHERS

         THEN

            DBMS_OUTPUT.PUT_LINE (SQLERRM);

            DBMS_OUTPUT.PUT_LINE (DBMS_UTILITY.FORMAT_ERROR_BACKTRACE);

            UTL_HTTP.END_RESPONSE (response);

      END;

      SELECT COUNT (*) + 1 INTO n FROM WWW_DATA;

      INSERT INTO WWW_DATA

           VALUES (n, clob_buff);

      COMMIT;

   ELSE

      DBMS_OUTPUT.PUT_LINE ('ERROR');

      UTL_HTTP.END_RESPONSE (response);

   END IF;

EXCEPTION

   WHEN UTL_HTTP.transfer_timeout

   THEN

      DBMS_OUTPUT.put_line ('Timeout');

   WHEN OTHERS

   THEN

      DBMS_OUTPUT.put_line ('Exception in others  :' || SQLERRM);

END;

Comments

Processing
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Sep 16 2015
Added on Aug 19 2015
11 comments
1,741 views