简体   繁体   中英

Using sysdate in IF statement to avoid every top of the hour

I am trying to write an IF statement in my procedure to avoid my procedure running at the top of the hour. The job scheduler that I am using does not have the flexibility to avoid running at the top of the hour for some reason. Anyone have anything out there already they can share? So for example if it is 8:00 I want the IF statement to stop the procedure from executing.......but if its 8:15 then no problem go ahead and run.

You can extract the minutes like that:

SELECT EXTRACT(minute FROM systimestamp) FROM DUAL;

or, more traditionally

SELECT TO_CHAR(sysdate,'MI') FROM DUAL;

Your procedure would then look like:

CREATE OR REPLACE PROCEDURE myproc IS
BEGIN
  IF EXTRACT(minute FROM systimestamp) > 0 THEN
    NULL; 
    -- here goes your code
  END IF;
END myproc;
/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM