I'm currently working on an assignment where I have to port some Oracle scripts to MS SQL. I ran into a problem at the scheduled jobs. The Oracle script looks like this:
我正在进行一项任务,我必须将一些Oracle脚本移植到MS SQL。我在预定的工作中遇到了问题。 Oracle脚本如下所示:
dbms_job.submit(job =>v_job,
what =>'begin pkg_report.REFRESH_MVIEWS; end;',
next_date =>Trunc(sysdate, 'HH24')+70/1440, interval =>'Trunc(sysdate, ''HH24'')+70/1440');
dbms_job.submit(job =>v_job, what =>'begin pkg_housekeeping.cleanup_daily; end;', next_date =>trunc(sysdate)+1, interval =>'trunc(sysdate)+1+1/24');
The problem is, I don't understand what this truncing is supposed to do. I tried to replicate it in SQL Developer, played around with it a bit, most of the format strings have very obvoius outcome (YEAR, MONTH, ...), but I don't know what HH24 is supposed to do. And what's with the +70/1440, +1, +1+1/24 suffixes at the end?
问题是,我不明白这个truncing应该做什么。我尝试在SQL Developer中复制它,稍微使用它,大多数格式字符串都有非常直观的结果(YEAR,MONTH,...),但我不知道HH24应该做什么。那末尾的+ 70/1440,+ 1,+ 1 + 1/24后缀是什么?
I'd appreciate a little help. Thanks in advance!
我会感激一点帮助。提前致谢!
1 个解决方案
#1
TRUNC
removes the time element of the current date, so the code sets the date to midnight of today (sysdate) and then adds 70/1440 of a day to it.
TRUNC删除当前日期的时间元素,因此代码将日期设置为今天的午夜(sysdate),然后将一天的70/1440添加到它。
70/1440 of a day is 01:10 (ten past one in the morning)
一天的70/1440是01:10(早上十点一点)
+1+1/24 adds one day and 1/24th of a day, so 1am the following day
+ 1 + 1/24增加一天和1/24的一天,所以第二天凌晨1点
#1
TRUNC
removes the time element of the current date, so the code sets the date to midnight of today (sysdate) and then adds 70/1440 of a day to it.
TRUNC删除当前日期的时间元素,因此代码将日期设置为今天的午夜(sysdate),然后将一天的70/1440添加到它。
70/1440 of a day is 01:10 (ten past one in the morning)
一天的70/1440是01:10(早上十点一点)
+1+1/24 adds one day and 1/24th of a day, so 1am the following day
+ 1 + 1/24增加一天和1/24的一天,所以第二天凌晨1点