You may schedule a procedure to run at any time using the DBMS_JOB supplied package. Simply write a procedure to do what you want and then schedule it to run using the DBMS_JOB.SUBMIT procedure. Besides reading up on the DBMS_JOB package in the Oracle Supplied Packages Reference, there's a great article at: http://www.pinnaclepublishing.com/OP/OPmag.nsf/0/C31F87A073306A72852568F00065982B.
If, however, you are wanting to simply run a query (just a SELECT statement) to spool out a report to a file, then you can use your operating system's scheduling mechanisms (for instance, cron) to cause it to start a SQL*Plus session and run a script (.sql) that contains your query. A good cron overview can be found at: http://www.unixgeeks.org/security/newbie/unix/cron-1.html.
For More Information
- Dozens more answers to tough Oracle questions from Karen Morton are available.
- 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 first published in October 2002