Link to home
Start Free TrialLog in
Avatar of basirana
basirana

asked on

change time dbms_job

Hi friend

Below is the job script that is used to run a procedure at 10:01 AM daily. I want to change the time to 10:45AM Howcan I do that. what I have to use

DECLARE
  X NUMBER;
BEGIN
  SYS.DBMS_JOB.SUBMIT
    ( job       => X
     ,what      => 'procedure_name;'
     ,next_date => to_date('26/01/2007 10:01:05','dd/mm/yyyy hh24:mi:ss')
     ,interval  => 'sysdate + 1'
     ,no_parse  => TRUE
    );
  SYS.DBMS_OUTPUT.PUT_LINE('Job Number is: ' || to_char(x));
END;
/

commit;
ASKER CERTIFIED SOLUTION
Avatar of slightwv (䄆 Netminder)
slightwv (䄆 Netminder)

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of slightwv (䄆 Netminder)
slightwv (䄆 Netminder)

or

Just remove the current job and recreate it with the script you have (after changing the time).

dbms_job.remove(<job_number>)
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of basirana

ASKER

SQL> begin
  2  dbms_job.change(673, next_date => to_date('26/01/2007 10:45:00','dd/mm/yyyy hh24:mi:ss'));
  3  end;
  4  /
dbms_job.change(673, next_date => to_date('26/01/2007 10:45:00','dd/mm/yyyy hh24:mi:ss'));
*
ERROR at line 2:
ORA-06550: line 2, column 1:
PLS-00306: wrong number or types of arguments in call to 'CHANGE'
ORA-06550: line 2, column 1:
PL/SQL: Statement ignored
Eliminate the TO_DATE part:

next_date => (TRUNC(SYSDATE) + 645/1440)
Sorry friend but I want to schedule it at 10:45 not 645/1400 which will give hours
How to remove existing job and create new job to run procedure but different time...
Can you help me with example
Sorry, I got confused and I'm still confused. Do you just want to change the next_date? If it's the case you can do this:

EXEC DBMS_JOB.NEXT_DATE(<job as integer>,to_date('26/01/2007 10:45:00','dd/mm/yyyy hh24:mi:ss'));
exec DBMS_JOB.CHANGE(<job number>,null,TRUNC(SYSDATE+10/24)+45/1440,'TRUNC(SYSDATE+10/24)+45/1440');
commit;

how to create new job that will execute at 10:45 AM.. to execute a procedure
Do you want to run it today?

The one below will run tomorrow at 10:45 and every following day at 10:45 AM:

DECLARE
  X NUMBER;
BEGIN
  SYS.DBMS_JOB.SUBMIT
    ( job       => X
     ,what      => 'procedure_name;'
     ,next_date => trunc(sysdate + 1) + 645/1440
     ,interval  => 'trunc(sysdate + 1) + 645/1440'
     ,no_parse  => TRUE
    );
  SYS.DBMS_OUTPUT.PUT_LINE('Job Number is: ' || to_char(x));
END;
/
exec DBMS_JOB.ISUBMIT(12, 'begin smd.smd_update(trunc(sysdate-1));end;',TRUNC(SYSDATE+10/24)+45/1440,'TRUNC(SYSDATE+10/24)+45/1440');
commit;


With isubmit you provide the joib number, here in the example I used a 12.

From the begin until the the end is my proc, please, copy/paste your proc.

friend I tried to execute but the time is not correct

exec DBMS_JOB.CHANGE(<job number>,null,TRUNC(SYSDATE+10/24)+45/1440,'TRUNC(SYSDATE+10/24)+45/1440');


OUTPUT

DECLARE
  X NUMBER;
BEGIN
  SYS.DBMS_JOB.SUBMIT
    ( job       => X
     ,what      => 'dbms_refresh.refresh("....");'
     ,next_date => to_date('26/01/2007 00:45:00','dd/mm/yyyy hh24:mi:ss')
     ,interval  => 'TRUNC((SYSDATE+1)+10/24)+45/1440'
     ,no_parse  => TRUE
    );
  SYS.DBMS_OUTPUT.PUT_LINE('Job Number is: ' || to_char(x));
END;
/
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi.
I think it is about time you distribute the points as we have separated precious time of our own to help you.
Now it is time you help us giving the points we deserve.
Forced accept.

Computer101
EE Admin