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;