简体   繁体   English

在IF语句中使用sysdate避免每时每刻

[英]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. 我试图在我的过程中编写IF语句,以避免我的过程在高峰时间运行。 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. 因此,例如,如果是8:00,我希望IF语句停止该过程的执行.......但是,如果它是8:15,则可以继续运行。

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;
/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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