IS
v_html clob :=' ';
v_n NUMBER := 0;
BEGIN
--1) let loop to get email html
v_html := '<h4>INDEXES</h4>'
||'<table style="border:1px solid lightgrey">'
||'<tr style="background-color:#85C1E9; font-family:verdana; font-size:80%;">'
||'<th>No</th>'
||'<th>Index Name</th>'
||'<th>Status</th>'
||'</tr>';
FOR i IN (
select index_name,status from user_indexes
where (status <> 'VALID' and status <> 'N/A')
union
select index_name||':'||partition_name,status from user_ind_partitions
where status <> 'USABLE')
LOOP
v_n := v_n +1;
v_html := v_html || '<tr style="font-family:verdana; font-size:80%;">'
||'<TD>'||v_n ||'</TD>'
||'<TD>'|| i.index_name ||'</TD>'
||'<TD>'|| i.status ||'</TD>'
||'</tr>';
END LOOP;
--4) require send?
IF v_n > 0
THEN
v_html := v_html || '</table>';
UTL_MAIL.send(sender => 'oracle@ababank.com',
recipients => '',
subject => '[' || SYS_CONTEXT ('USERENV', 'DB_NAME') || '] Index unusable alert',
message => v_html,
mime_type => 'text/html;charset=us-ascii');
END IF;
dbms_output.put_line('html: ' || v_html);
END;
No comments:
Post a Comment