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...
By submitting your personal information, you agree that TechTarget and its partners may contact you regarding relevant content, products and special offers.
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:
DECLARE col_date DATE; mailhost VARCHAR2(30):='mailhost.mydomain.com'; mail_conn utl_smtp.connection; BEGIN 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, 25); utl_smtp.helo(mail_conn, mailhost); utl_smtp.mail(mail_conn, sender); utl_smtp.rcpt(mail_conn, recipient); utl_smtp.data(mail_conn, message); utl_smtp.quit(mail_conn); END IF; END;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.
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.