Home » SQL & PL/SQL » SQL & PL/SQL » DBMS_JOB TO run every saturday starting next saturday (oracle 11g Release2)
DBMS_JOB TO run every saturday starting next saturday [message #634999] Wed, 18 March 2015 15:09 Go to next message
azeem87
Messages: 116
Registered: September 2005
Location: dallas
Senior Member
hi,

I have to deploy the code this week, but the job should start from
saturday 03/28/2015 12.30 AM and from there on every saturday at 12.30 am should run every week
i have this code, please advice what should be on interval value/next date

DECLARE
  X NUMBER;
BEGIN
  SYS.DBMS_JOB.SUBMIT
  ( job       => X 
   ,what      => 'TEST_PROC(33);'
   ,next_date => next_day(sysdate,'sat')
   ,interval  => xxxxxxx
   ,no_parse  => FALSE
  );
 COMMIT;
END;
/


Thanks
Re: DBMS_JOB TO run every saturday starting next saturday [message #635000 is a reply to message #634999] Wed, 18 March 2015 15:35 Go to previous messageGo to next message
joy_division
Messages: 4963
Registered: February 2005
Location: East Coast USA
Senior Member
I use DBMS_SCHEDULER. It is more intuitive to me. The options I use are something like:
start_date => '03/28/2015 12.30 AM'
repeat_interval => 'FREQ=WEEKLY'


Does DBMS_JOB have those?
Re: DBMS_JOB TO run every saturday starting next saturday [message #635001 is a reply to message #634999] Wed, 18 March 2015 15:38 Go to previous messageGo to next message
Michel Cadot
Messages: 68645
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

Same thing for both: trunc(next_day(sysdate,'sat'))+1/2+1/48

Re: DBMS_JOB TO run every saturday starting next saturday [message #635002 is a reply to message #635001] Wed, 18 March 2015 15:41 Go to previous messageGo to next message
Michel Cadot
Messages: 68645
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

Sorry, next saturday is not 03/28, so
next_date=>to_date('03/28/2015 12.30 AM','MM/DD/YYYY HH:MI AM')
interval=>'trunc(next_day(sysdate,'sat'))+1/2+1/48'

Re: DBMS_JOB TO run every saturday starting next saturday [message #635003 is a reply to message #635002] Wed, 18 March 2015 17:39 Go to previous messageGo to next message
azeem87
Messages: 116
Registered: September 2005
Location: dallas
Senior Member
Thanks all for your time,
DECLARE
  X NUMBER;
BEGIN
  SYS.DBMS_JOB.SUBMIT
  ( job       => X, 
  what      => TEST_PROC(63);',
  next_date=>to_date('03/28/2015 12.30 AM','MM/DD/YYYY HH:MI AM'),
  interval  => 'trunc(next_day(sysdate,'SAT'))+1/2+1/48',
  no_parse  => FALSE
  );
 COMMIT;
END;
/



I am getting this error, am i missing anything there.

Error at line 1
ORA-06550: line 8, column 41:
PLS-00103: Encountered the symbol "SAT" when expecting one of the following:

) , * & = - + < / > at in is mod remainder not rem
<an exponent (**)> <> or != or ~= >= <= <> and or like like2
like4 likec between || multiset member submultiset
The symbol ", was inserted before "SAT" to continue.
Re: DBMS_JOB TO run every saturday starting next saturday [message #635011 is a reply to message #635003] Thu, 19 March 2015 01:17 Go to previous messageGo to next message
Michel Cadot
Messages: 68645
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

The error is obvious, think a little bit and fix it.
Hint: how a ' inside a string should be handled?

Re: DBMS_JOB TO run every saturday starting next saturday [message #635161 is a reply to message #635011] Mon, 23 March 2015 09:35 Go to previous message
azeem87
Messages: 116
Registered: September 2005
Location: dallas
Senior Member
thanks i had it corrected and deployed and the code is below,
it ran sucessfully First run was good on time and it ran at 12.30 am.

but Next date shows the next schedule job is at 12.30 PM
Next Date 3/28/2015 12:30:00 PM

DECLARE
  X NUMBER;
BEGIN
  SYS.DBMS_JOB.SUBMIT
  ( job       => X, 
  what      => 'TEST_PROC(63);',
  next_date=>to_date('03/21/2015 12.30 AM','MM/DD/YYYY HH:MI AM'),
  interval  =>'trunc(next_day(sysdate,''SAT''))+1/2+1/48',
  no_parse  => FALSE
  );
 COMMIT;
END;
/



is my format wrong in next date column for job creation code.

Thanks Again for your help.
Previous Topic: synonyms
Next Topic: merging two queries to create a table
Goto Forum:
  


Current Time: Wed Apr 24 17:59:27 CDT 2024