Skip to Main Content
  • Questions
  • Schedule a procedure to run every hour on the hour between 7AM and 7PM EST.

Breadcrumb

Question and Answer

Tom Kyte

Thanks for the question, soffian.

Asked: November 24, 2009 - 10:31 pm UTC

Last updated: November 30, 2009 - 2:45 pm UTC

Version: 10.1.0

Viewed 10K+ times! This question is

You Asked

Server: CAPRD02
Schema: EFORMS_OWN
Script: MESSAGE_PROCESSING.PROCESS_PENDING_MESSAGES
Run: Every hour on the hour between 7AM and 7PM EST.

Script was executed :
DECLARE
X NUMBER;
BEGIN
EFORMS_OWN.DBMS_SCHEDULER.CREATE_JOB (
job_name => 'MESSAGE'
,job_type => 'PLSQL_BLOCK'
,job_action => 'MESSAGE_PROCESSING.PROCESS_PENDING_MESSAGES'
,start_date => 'trunc(sysdate+1/7/24'
,repeat_interval => 'FREQ=DAILY'
,enabled => FALSE
,comments => 'Every hour'
);
COMMIT;

got an error :
ORA-06550: line 13, column 8:
PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following:

and Tom said...

couple of problems.

eforms_own? sys owns dbms_scheduler

start_date => 'trunc(sysdate+1/7/24'?? missing closing parenthesis and I think you meant 7am, which would be trunc(sysdate)+7/24

ops$tkyte%ORA10GR2> select trunc(sysdate)+1/7/24, trunc(sysdate)+7/24 from dual;

TRUNC(SYSDATE)+1/7/2 TRUNC(SYSDATE)+7/24
-------------------- --------------------
30-nov-2009 00:08:34 30-nov-2009 07:00:00


you are missing the end; statement for the block... and also, start_date is of type timestamp, NOT varchar2, you do not pass a string - unless that string is a timestamp to be converted with your default NLS settings..

you never got to the repeat interval bit... however:

ops$tkyte%ORA10GR2> BEGIN
  2    DBMS_SCHEDULER.CREATE_JOB
  3    ( job_name => 'MESSAGE',
  4      job_type => 'PLSQL_BLOCK',
  5      job_action => 'P',
  6      start_date => trunc(sysdate)+7/24,
  7      repeat_interval => 'FREQ=DAILY; BYDAY=MON,TUE,WED,THU,FRI,SAT,SUN; BYHOUR=7,8,9,10,11,12,13,14,15,16,17,18,19;',
  8      enabled => FALSE,
  9      comments => 'Every hour'
 10    );
 11  end;
 12  /

PL/SQL procedure successfully completed.

Rating

  (3 ratings)

Is this answer out of date? If it is, please let us know via a Comment

Comments

Oleksandr Alesinskyy, November 30, 2009 - 4:07 am UTC

Would not start_date => 'trunc(sysdate)' be sufficient? As BYHOUR is specified anyway.
Tom Kyte
November 30, 2009 - 2:45 pm UTC

I guess just sysdate would be sufficient "start right now"... indeed.

dbms job

soffian, December 01, 2009 - 11:22 pm UTC

thanks..
it's working now

Oleksandr Alesinskyy, December 02, 2009 - 11:16 am UTC

BTW one more issue may arise - it the schedule should follow summer/winter time then the start date expression shall contain an appropriate time zone (and sysdate does not),
see http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_sched.htm#BABEJGCH (look for General Rules).

More to Explore

PL/SQL demos

Check out more PL/SQL tutorials on our LiveSQL tool.

PL/SQL docs

PL/SQL reference manual from the Oracle documentation library