Solved

Scheduled task in Oracle 8i

Posted on 2003-11-13
12
1,006 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
  • 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
 
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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Have you ever had to make fundamental changes to a table in Oracle, but haven't been able to get any downtime?  I'm talking things like: * Dropping columns * Shrinking allocated space * Removing chained blocks and restoring the PCTFREE * Re-or…
Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

708 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now