Problem solve Get help with specific problems with your technologies, process and projects.

Verifying date columns, sending e-mail with PL/SQL

I need to verify a date column, and if it matches, send an e-mail to my manager with some text in the mail... Can...

I do it using PL/SQL?

Yes, you can do this. But you'll definitely need PL/SQL and the UTL_SMTP package. Hopefully, the following sample program will give you an idea of what you need to do:

   col_date DATE;
   mailhost VARCHAR2(30):='mailhost.mydomain.com';
   mail_conn  utl_smtp.connection;
   SELECT date_column INTO col_date FROM tableX;
   IF (col_date < TO_DATE('01/01/02','MM/DD/YY')) THEN
      mail_conn := utl_smtp.open_connection(mailhost,
      utl_smtp.helo(mail_conn, mailhost);
      utl_smtp.mail(mail_conn, sender);
      utl_smtp.rcpt(mail_conn, recipient);
      utl_smtp.data(mail_conn, message);
   END IF;
You'll have to supply values sender, recipient and message, which I've ommitted. The Oracle docs on the UTL_SMTP package give you much more detail!

For More Information

  • What do you think about this answer? E-mail the editors at editor@searchDatabase.com with your feedback.
  • The Best Oracle Web Links: tips, tutorials, scripts, and more.
  • Have an Oracle or SQL tip to offer your fellow DBAs and developers? The best tips submitted will receive a cool prize. Submit your tip today!
  • Ask your technical Oracle and SQL questions -- or help out your peers by answering them -- in our live discussion forums.
  • Ask the Experts yourself: Our SQL, database design, Oracle, SQL Server, DB2, metadata, object-oriented and data warehousing gurus are waiting to answer your toughest questions.

This was last published in April 2002

Dig Deeper on Oracle database design and architecture

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.