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

Time-based stored procedure to check table and update old records

How can I run a time-based stored procedure that is going to check a specific table each X minutes, find any record that is older than the same X minutes and delete it (or run an ASP page from the Web server instead)? I want this table to be updated each X minutes and hold always-fresh records.

Write your stored procedure to perform the actions as desired, then schedule it to run every X minutes using the DBMS_JOB package.

Here's an example (pretty much straight out of the Oracle Supplied Packages Reference):

declare
  v_jobno	number;
begin
  dbms_job.submit(v_jobno, 'my_stored_proc;', sysdate, 'sysdate + (10/(24*60))');
  dbms_output.put_line('Your job was submitted and assigned the job #: ' || v_jobno) ;
end ;
/
This would run your procedure (called my_stored_proc) immediately (sysdate) and then schedule it to run continuously at a 10 minute interval ('sysdate + (10/(24*60)) ').

See the Oracle Supplied Packages Reference for more details on the use of DBMS_JOB.

For More Information


Dig Deeper on Oracle stored procedures

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.

Please create a username to comment.

-ADS BY GOOGLE

SearchDataManagement

SearchBusinessAnalytics

SearchSAP

SearchSQLServer

TheServerSide.com

SearchDataCenter

SearchContentManagement

SearchHRSoftware

Close