I want to write a program that will email me if the database is not up and running, as opposed to just having a static page that may be working fine.
Here is a way to do this. This sample assumes the site is NOT https. For that the reader would need to read up on this package in Oracle document B10802-01. It also assumes the machine Oracle is on can make http requests from the Internet.
The anonymous block below looks at the Google site. On that site there is an HTML input item with the name of "q" (where the search text is typed in). The code below checks to see if the item with "name=q" exists on the HTML page. For the reader I would think he/she could do the same, but for a particular item on the page of the 'interactive' page mentioned. If the item does not exist on the page, then the text returned in the request is likely for a static page.
Also note: The http response is returned in a TABLE type. I'm only checking the first array item in the TABLE. If the http response is larger you would need to check more array items.
declare html_pieces utl_http.html_pieces; -- TABLE type each item is VARCHAR2(2000) n_length pls_integer; begin html_pieces := utl_http.request_pieces( 'https://www.google.com/', 10 ); n_length := instr( html_pieces(1), 'name=q' ); if n_length <> 0 then dbms_output.put_line( 'Page is not static.' ); else dbms_output.put_line( 'Page is static.' ); end if; end; /
Dig Deeper on Oracle database design and architecture
Related Q&A from Mike Ault
How to find the definition or structure of a dropped table? I know the table's name but I don't know the columns and datatypes. It no longer exists. Continue Reading
I am trying to remove carriage returns at the end of clob fields in SQL*Plus. This just nulls out the field in the table. What do I need to change to... Continue Reading
I want to find the length of a numeric datatype field in my table. How can I find it? Continue Reading
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.