Solved

Scheduled task in Oracle 8i

Posted on 2003-11-13
12
1,012 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
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 
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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Working with Network Access Control Lists in Oracle 11g (part 2) Part 1: http://www.e-e.com/A_8429.html Previously, I introduced the basics of network ACL's including how to create, delete and modify entries to allow and deny access.  For many…
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
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 configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

738 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