Solved

Scheduled task in Oracle 8i

Posted on 2003-11-13
12
1,008 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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 1) Part 2: http://www.e-e.com/A_9074.html So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
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.
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…

911 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

17 Experts available now in Live!

Get 1:1 Help Now