Home > Ask the Oracle Database / Applications Experts > Questions & Answers > Verifying date columns, sending e-mail with PL/SQL
Ask The Oracle Expert: Questions & Answers
EMAIL THIS

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

Brian Peasland EXPERT RESPONSE FROM: Brian Peasland

Pose a Question
Other Oracle Categories
Meet all Oracle Experts
Become an Expert for this site
>
QUESTION POSED ON: 26 April 2002
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:

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.


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary



Search and Browse the Expert Answer Center
Search and browse more than 25,000 question and answer pairs from more than 250 TechTarget industry experts.
Browse our Expert Advice



Oracle White Papers: Fusion Middleware
HomeNewsTopicsTipsAsk the ExpertsMultimediaWhite PapersProductsBlogs
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 2003 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts