Solved

Scheduled task in Oracle 8i

Posted on 2003-11-13
12
1,015 Views
Last Modified: 2013-12-11
Dear All,

I have Oracle 8.1.7 installed on Win NT server. Now I have written a procedure in my database called PROC_DEMO. I want to run this procedure on specified date and time.

How can I do this ?

Please explain in detail.

Regards,
Manish.
0
Comment
Question by:manish_saraswat
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
  • 2
  • +2
12 Comments
 
LVL 8

Assisted Solution

by:baonguyen1
baonguyen1 earned 50 total points
ID: 9746203
You can use DBMS_JOB package:

To submit a job:
DBMS_JOB.SUBMIT(ID OUT BINARY_INTEGER,                
                             what IN VARCHAR2,                
                             next_date IN DATE,                
                             interval IN VARCHAR2,                
                             no_parse IN BOOLEAN)

ID                              Unique job number
What                         The PL/SQL code or stored procedure
Next_date                   The date when the job will execute.  Default
                                 is SYSDATE.
Interval                       A function that calculates the next time the
                                 job is to execute.  Default is NULL.
No_parse                    If TRUE, Oracle parses the code the first
                                 time the job is executed.  If FALSE,
                                 the job is parsed when submitted.  Default is
                                 FALSE.

Ex: DBMS_JOB.SUBMIT(1234,<procedure_name>, sysdate,'sysdate+1')

To remeove a job:

DBMS_JOB.REMOVE(ID  IN  BINARY_INTEGER);

To change a job:

DBMS_JOB.CHANGE(ID IN BINARY_INTEGER,                
                                 what IN VARCHAR2,                
                                next_date IN DATE,                
                                interval IN VARCHAR2);

To run a job immediate:

DBMS_JOB.RUN(ID IN BINARY_INTEGER);

You also have DBMS_JOB.WHAT/NEXT_DATE/INTERVAL/BROKEN ...
0
 

Author Comment

by:manish_saraswat
ID: 9752690
I tried the following command and got errors :

SQL> BEGIN
  2  DBMS_JOB.SUBMIT(1, PROC_TEST, SYSDATE, SYSDATE+1);
  3  END;
  4  /
DBMS_JOB.SUBMIT(1, PROC_TEST, SYSDATE, SYSDATE+1);
                   *
ERROR at line 2:
ORA-06550: line 2, column 20:
PLS-00222: no function with name 'PROC_TEST' exists in this scope
ORA-06550: line 2, column 1:
PL/SQL: Statement ignored

Here PROC_TEST is a vaild procedure.

Why did this error occur ?
0
 

Author Comment

by:manish_saraswat
ID: 9752788
I tried the following and got a new error :

SQL>declare
  2      x number(3);
  3    begin
  4      dbms_job.submit(x,  'proc_test', sysdate, 'sysdate+1');
  5*   end;
declare
*
ERROR at line 1:
ORA-06550: line 1, column 108:
PLS-00103: Encountered the symbol "END" when expecting one of the following:
:= . ( @ % ;
The symbol ";" was substituted for "END" to continue.
ORA-06512: at "SYS.DBMS_JOB", line 79
ORA-06512: at "SYS.DBMS_JOB", line 131
ORA-06512: at line 4

What may be the problem in this ?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 8

Expert Comment

by:baonguyen1
ID: 9752893
This should work:

SQL>declare
2   x number(3);
3   BEGIN
4   dbms_job.submit(x, 'PROC_TEST', sysdate, 'sysdate+1', TRUE);
5   commit;
6   end;

Thanks,
0
 
LVL 6

Accepted Solution

by:
morphman earned 50 total points
ID: 9754050
you need a ; after your procedure name i beleive.

dbms_job.submit(x, 'PROC_TEST;', sysdate, 'sysdate+1', TRUE);
0
 
LVL 8

Expert Comment

by:baonguyen1
ID: 9754634
Thanks morphman,  you are right. You need a semicolon after the procedure name. I forgot
0
 

Expert Comment

by:kvsrikant
ID: 10540896
How do i get the job id after i submit the job ?
0
 
LVL 8

Expert Comment

by:baonguyen1
ID: 10547691
dba_jobs view
0
 

Expert Comment

by:sjensen26
ID: 10955198
How do I setup a scheduled task on Oracle 8i for 9:30AM, 11:30AM, and 2:30PM to run everyday?
0
 

Expert Comment

by:sjensen26
ID: 10955219
And dba_jobs view does not work.
0
 

Expert Comment

by:sjensen26
ID: 10955512
I answered my own question. But I still can't get dba_jobs view to work. How do you do it at a specfic time? You create multiple jobs.

declare
x number(10);
g number(11);
h number(12);

BEGIN

dbms_job.submit( x, 'PROCEDURE_NAME;', TRUNC(SYSDATE)+8/24, 'TRUNC(SYSDATE)+1+8/24', TRUE );
dbms_job.submit( g, 'PROCEDURE_NAME;', TRUNC(SYSDATE)+11/24, 'TRUNC(SYSDATE)+1+11/24', TRUE );
dbms_job.submit( h, 'PROCEDURE_NAME;', TRUNC(SYSDATE)+14/24, 'TRUNC(SYSDATE)+1+14/24', TRUE );

commit;
end;
/
0
 

Expert Comment

by:sjensen26
ID: 10955680
This is how you view a job.

SELECT JOB, NEXT_DATE, NEXT_SEC, FAILURES, BROKEN FROM DBA_JOBS;
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Suggested Courses

622 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question