The following code will query some data from the Oracle Database and will export them on a CSV file.
The webserver where this script is executed should have the OCI8 library installed.
The execution of this script can be also scheduled to have a periodic backup of a certain table.
The script below will extract from the system [...]

Sometimes it’s needed to send an email using PL/SQL. This can be done with few lines of code pasted below. The variables $server.address, $domain, $sender_email, $recipient_email should be replaced with the relevant information.

DECLARE
l_retVal INTEGER;
v_connection UTL_SMTP.connection;
BEGIN
v_connection := UTL_SMTP.open_connection(’$server.address’);
UTL_SMTP.helo(v_connection, ‘$domain’);
UTL_SMTP.mail(v_connection, ‘$sender_email’);
UTL_SMTP.rcpt(v_connection, ‘$recipient_email’);
UTL_SMTP.open_data(v_connection);
UTL_SMTP.write_data(v_connection, ‘From: $sender_email’ || UTL_TCP.crlf);
UTL_SMTP.write_data(v_connection, ‘To: $recipient_email’ || UTL_TCP.crlf);
UTL_SMTP.write_data(v_connection, ‘The Subject!’ || [...]