• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3042
  • Last Modified:

schedule an update query as job in oracle 9i

I have an update (UPDATE SUBSCRIBERS TODATE=FROMDATE WHERE FROMDATE+3 < SYSDATE AND TODATE < FROMDATE) query ank I want to schedule this as a job that running every day..
0
gla
Asked:
gla
1 Solution
 
DLyallCommented:
If you create a strored procedure to run your script you can use DBMS_JOB.SUBMIT to schedule it on the database.
See info below.

SUBMIT Procedure
This procedure submits a new job. It chooses the job from the sequence sys.jobseq.

Syntax
DBMS_JOB.SUBMIT (
   job       OUT BINARY_INTEGER,
   what      IN  VARCHAR2,
   next_date IN  DATE DEFAULT sysdate,
   interval  IN  VARCHAR2 DEFAULT 'null',
   no_parse  IN  BOOLEAN DEFAULT FALSE,
   instance  IN  BINARY_INTEGER DEFAULT any_instance,
   force     IN  BOOLEAN DEFAULT FALSE);

Parameters
Table 41-9 SUBMIT Procedure Parameters
Parameter Description
job
 Number of the job being run.
 
what
 PL/SQL procedure to run.
 
next_date
 Next date when the job will be run.
 
interval
 Date function that calculates the next time to run the job. The default is NULL. This must evaluate to a either a future point in time or NULL.
 
no_parse
 A flag. The default is FALSE. If this is set to FALSE, then Oracle parses the procedure associated with the job. If this is set to TRUE, then Oracle parses the procedure associated with the job the first time that the job is run.

For example, if you want to submit a job before you have created the tables associated with the job, then set this to TRUE.
 
instance
 When a job is submitted, specifies which instance can run the job.
 
force
 If this is TRUE, then any positive integer is acceptable as the job instance. If this is FALSE (the default), then the specified instance must be running; otherwise the routine raises an exception.
 

Usage Notes
You must issue a COMMIT statement immediately after the statement.
The parameters instance and force are added for job queue affinity. Job queue affinity gives users the ability to indicate whether a particular instance or any instance can run a submitted job.
Example
This submits a new job to the job queue. The job calls the procedure DBMS_DDL.ANALYZE_OBJECT to generate optimizer statistics for the table DQUON.ACCOUNTS. The statistics are based on a sample of half the rows of the ACCOUNTS table. The job is run every 24 hours:

VARIABLE jobno number;
BEGIN
   DBMS_JOB.SUBMIT(:jobno,
      'dbms_ddl.analyze_object(''TABLE'',
      ''DQUON'', ''ACCOUNTS'',
      ''ESTIMATE'', NULL, 50);'
      SYSDATE, 'SYSDATE + 1');
   COMMIT;
END;
/
Statement processed.
print jobno
JOBNO
----------
14144

0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now