Connor and Chris will both be at AI World from October 12 to October 17 , the premier Oracle conference of 2025. If you're in Vegas, please come say Hi or pop into our sessions
Thanks for the question, ahmed.
Asked: October 04, 2023 - 6:51 pm UTC
Last updated: January 08, 2025 - 2:29 am UTC
Version: 19.2
Viewed 1000+ times
SQL> create or replace 2 function get_status(p_url varchar2) return number is 3 l_http_request utl_http.req; 4 l_http_response utl_http.resp; 5 l_status int; 6 begin 7 l_http_request := utl_http.begin_request(p_url); 8 l_http_response := utl_http.get_response(l_http_request); 9 10 l_status := l_http_response.status_code; 11 utl_http.end_response(l_http_response); 12 return l_status; 13 exception 14 when others then 15 utl_http.end_response(l_http_response); 16 return -1; 17 end; 18 / Function created. SQL> SQL> select get_status('https://www.oracle.com') from dual; GET_STATUS('HTTPS://WWW.ORACLE.COM') ------------------------------------ 403 SQL> select get_status('https://www.oracle123.com') from dual; GET_STATUS('HTTPS://WWW.ORACLE123.COM') --------------------------------------- -1
Check out more PL/SQL tutorials on our LiveSQL tool.
PL/SQL reference manual from the Oracle documentation library