Solved

Scheduled task in Oracle 8i

Posted on 2003-11-13
12
1,013 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
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 
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

Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

Question has a verified solution.

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

Note: this article covers simple compression. Oracle introduced in version 11g release 2 a new feature called Advanced Compression which is not covered here. General principle of Oracle compression Oracle compression is a way of reducing the d…
I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
This video shows how to recover a database from a user managed backup

729 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