0% found this document useful (0 votes)
10 views2 pages

Undo Datafile Growth Alert Procedure

The document outlines a PL/SQL procedure named 'UNDO_ALERT' that sends an email alert regarding UNDO datafiles in a database that exceed 30GB in size. It establishes an SMTP connection to a specified email server, constructs an HTML message with details of the oversized datafiles, and sends the email to designated recipients. The procedure includes error handling for connection and email sending processes.

Uploaded by

Nilesh Zodape
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views2 pages

Undo Datafile Growth Alert Procedure

The document outlines a PL/SQL procedure named 'UNDO_ALERT' that sends an email alert regarding UNDO datafiles in a database that exceed 30GB in size. It establishes an SMTP connection to a specified email server, constructs an HTML message with details of the oversized datafiles, and sends the email to designated recipients. The procedure includes error handling for connection and email sending processes.

Uploaded by

Nilesh Zodape
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

CREATE OR REPLACE PROCEDURE "UNDO_ALERT"

IS
v_email_server VARCHAR2(100) := '[Link]';
v_conn UTL_SMTP.CONNECTION;
v_port NUMBER := 25;
v_reply UTL_SMTP.REPLY;
v_msg VARCHAR2(32767);
v_message VARCHAR2(4000);
v_subject VARCHAR2(1000);
b_connected BOOLEAN := FALSE;
v_sender VARCHAR2(100) ;
CRLF VARCHAR2(2):= CHR(13) || CHR(10);
RECPT VARCHAR2(100) ;
CC VARCHAR2(100) ;
CC1 VARCHAR2(100) ;
CC2 VARCHAR2(100) ;
p_stat number;
msg_flg number;
BEGIN
msg_flg := 0;
p_stat := 0;
v_sender := '[Link]@[Link]';
RECPT := 'DBA.CLOVER2@[Link]';
--CC := '[Link]@[Link]';
CC1 := 'DBA.CLOVER2@[Link]';
--CC2 := 'SUNDAR.R@[Link]';
--CC2 := 'cloverconnect@[Link]';
v_message := '<h3>Below UNDO_Datafiles of MMFT_DB has size more than
30GB.<br>Kindly check the same.<br><br></h3><br><br><table border="1"><tr><td>FILE
NAME</td><td>TABLESPACE NAME</td></tr>';
For rec in (select file_name,tablespace_name from dba_data_files where
BYTES/1024/1024/1024 > 30 and tablespace_name like '%UNDO%')
Loop
v_message := v_message || '<tr><td>' || rec.file_name || '</td><td>' ||
rec.tablespace_name || '</td></tr>' ;
msg_flg := 1;
End Loop;
v_message := v_message || '</table><br><br>This is an automated mailer and do not
reply to it.<br><br>Yours Sincerely,<br><br>Datafile Growth Alert';
v_subject := 'Undo Datafile Growth - Alert';
v_conn:= UTL_SMTP.OPEN_CONNECTION(v_email_server, v_port );
v_reply :=UTL_SMTP.HELO( v_conn, v_email_server);
b_connected := TRUE;
IF b_connected = FALSE THEN
p_stat := 99;
RETURN;
END IF;
v_reply := UTL_SMTP.MAIL(v_conn, v_sender);
IF 250 != v_reply.code THEN
p_stat := 99;
RETURN;
END IF;
v_reply := UTL_SMTP.RCPT(v_conn, RECPT);
IF 250 != v_reply.code THEN
raise_application_error(-50001,'ERROR IN EMAIL ID -> '||' EMPLOYEE ID ->');
p_stat := 99;
RETURN;
END IF;
if cc is not null then
v_reply := UTL_SMTP.RCPT(v_conn, cc);
IF 250 != v_reply.code THEN
p_stat := 99;
RETURN;
END IF;
end if;
if cc1 is not null then
v_reply := UTL_SMTP.RCPT(v_conn, cc1);
IF 250 != v_reply.code THEN
p_stat := 99;
RETURN;
END IF;
end if;

if msg_flg = 1 then

UTL_SMTP.OPEN_DATA ( v_conn);
v_msg := 'Date: '|| TO_CHAR( SYSDATE, 'Mon DD yy hh24:mi:ss' ) || CRLF
|| 'From: '|| v_sender || CRLF
|| 'Subject: '|| v_subject || CRLF
|| 'To: ' || RECPT || CRLF
|| 'Mime-Version: 1.0' || CRLF ||'Content-Type:
multipart/mixed;boundary="[Link].605592468"' || CRLF
||'' || CRLF ||'Body: '||v_message||CRLF ||'' || CRLF ||'--
[Link].605592468'
|| CRLF ||'Content-Type: text/html;name="v_message.TXT"; charset=US-
ASCII' || CRLF
||'Content-Disposition: inline; filename="v_message.TXT"' ||CRLF
||'Content-Transfer-Encoding: 7bit' || CRLF || '' || CRLF ||
v_message|| CRLF || CRLF || CRLF;
UTL_SMTP.WRITE_DATA(v_conn,v_msg);

UTL_SMTP.CLOSE_DATA( v_conn );
UTL_SMTP.QUIT( v_conn );

end if;

END;
/

You might also like