Solved

Scheduled Database Task between certain times

  • 17 January 2020
  • 18 replies
  • 750 views

Userlevel 6
Badge +13
  • Hero (Customer)
  • 351 replies

Does anyone know if it’s possible to schedule a Task between particular times?  I’m looking to scheduled a task daily to run every two minutes but only between 6am and 8pm each day.  

 

 

Any PL/SQL assistance would be appreciated.  

Many thanks.

icon

Best answer by anmise 20 January 2020, 11:12

View original

18 replies

Userlevel 6
Badge +15

Try this:

decode(sign(sysdate - (trunc(sysdate) + 20/24)), 1, (trunc(sysdate) + 6/24), (sysdate + 2/1440))

 

Userlevel 6
Badge +13

Well it didn’t growl at me for wrong syntax.  I’ll let you know after 8pm today if it works!  

 

Many thanks, @CallumW - appreciate the swift response

 

Linda

Userlevel 6
Badge +15

Check after 08:02pm instead - as depending on when the penultimate task was executed in the queue, it could execute the last task slightly after 8pm! 

Userlevel 7

I find the DMBS Scheduler syntax is easier to read e.g. 

FREQ=MINUTELY; BYHOUR=6,7,8,9,10,11,12,13,14,15,16,17,18,19,20;INTERVAL=2;
Userlevel 6
Badge +13

I find the DMBS Scheduler syntax is easier to read e.g. 

 FREQ=MINUTELY; BYHOUR=6,7,8,9,10,11,12,13,14,15,16,17,18,19,20;INTERVAL=2;

Not sure what you mean by this, @anmise ...

Userlevel 6
Badge +13

Check after 08:02pm instead - as depending on when the penultimate task was executed in the queue, it could execute the last task slightly after 8pm! 

Sadly, this didn’t work, @CallumW 

Userlevel 7

I find the DMBS Scheduler syntax is easier to read e.g. 

 FREQ=MINUTELY; BYHOUR=6,7,8,9,10,11,12,13,14,15,16,17,18,19,20;INTERVAL=2;

Not sure what you mean by this, @anmise ...

It’s a different format you can put into the ‘Custom Expression’ field. It will run every 2 minutes between 6am and 8pm (20). 

FREQ: How often? 

INTERVAL: Related to FREQ, minutely = 2 e.g. every 2 minutes

BYHOUR: which hours of the day? 

Userlevel 6
Badge +15

Just to fix my code…

decode(sign(sysdate - (trunc(sysdate) + 6/24)), 1, decode(sign(sysdate - (trunc(sysdate) + 20/24)), -1, (sysdate + 2/1440), (trunc(sysdate+1) + 6/24)), (trunc(sysdate) + 6/24))

--If the time is greater than 06:00 then
--If the time is less than 20:00 then
--2 minute interval
--else set start time to 06:00 the following day
--else set start time to 06:00

 

But I prefer the answer from @anmise as it is A LOT easier to read

I find the DMBS Scheduler syntax is easier to read e.g. 

 FREQ=MINUTELY; BYHOUR=6,7,8,9,10,11,12,13,14,15,16,17,18,19,20;INTERVAL=2;

 

Userlevel 6
Badge +13

I’m happy to report, @CallumW and @anmise, both solutions worked. 

I now have the moral quandary of which of your responses to mark as Best Answer.  As I think we agree @anmise‘s is the easier to read I’ll plump for that one, @CallumW.

 

Many thanks both, appreciate your input

Linda

Userlevel 7

I’m happy to report, @CallumW and @anmise, both solutions worked. 

I now have the moral quandary of which of your responses to mark as Best Answer.  As I think we agree @anmise‘s is the easier to read I’ll plump for that one, @CallumW.

 

Many thanks both, appreciate your input

Linda

No worries, the most important thing is that you found a solution!

Userlevel 4
Badge +10

I find the DMBS Scheduler syntax is easier to read e.g. 

 FREQ=MINUTELY; BYHOUR=6,7,8,9,10,11,12,13,14,15,16,17,18,19,20;INTERVAL=2;

Not sure what you mean by this, @anmise ...

It’s a different format you can put into the ‘Custom Expression’ field. It will run every 2 minutes between 6am and 8pm (20). 

FREQ: How often? 

INTERVAL: Related to FREQ, minutely = 2 e.g. every 2 minutes

BYHOUR: which hours of the day? 

 

IFS8: I tried this syntax AS IS and i am getting syntax error… what could have gone wrong here… 

Once this error will resolve i will fix it hourly for only weekdays hopefully easily.

 

Userlevel 4
Badge +10

@anmise , @CallumW , @PRODQ  can you assist what is going wrong in my case.

Userlevel 6
Badge +15

@KHALIDU

Try:

FREQ=HOURLY;BYDAY=MON,TUE,WED,THU,FRI;BYMINUTE=0;BYSECOND=0;INTERVAL=1;

Every hour - on the hour Monday to Friday

Userlevel 4
Badge +10

@CallumW thanks, still not working in IFS8, however working in IFS10 (we are in process of upgrade). not sure why our PROD env doesn’t like it. 

Userlevel 6
Badge +15

What version of Oracle are you using for apps 8?

Userlevel 4
Badge +10

Aaah
 @CallumW  Oracle 12c in IFS8 vs Oracle 19c in IFS10.

Userlevel 1
Badge +4

I wanted similar thing for generating event based pm work orders for irregular intervals in Apps 10

Scenario:

  1. Work Order required on every 2nd tuesday of month. No idea whether 2nd tuesday of every month was a  luckly day :rofl: but below is the solution i am using in Apps 10

 

 

As per IFS Documentation, below is advised -

 

Hello google :heart_eyes: -

 

Link - https://docs.oracle.com/cd/E11882_01/server.112/e25494/scheduse.htm#ADMIN034

Here you can find lot expressions of use. 

 

Cheers

Regards,

Srinivas

Userlevel 7
Badge +21

Thanks everyone for including their thoughts over here. It helped me out trying to get a scheduled task to run every last Saturday of a month at 10:30 am. This is the setting I've used:

FREQ=MONTHLY; BYDAY=SAT; BYSETPOS=-1; BYHOUR=10; BYMINUTE=30;

 

Reply