Oracle/SQL - 选择特定系统日期时间的记录
我有一个每天运行多次的查询,但问题是我们希望查询仅在特定时间运行时返回结果。因此,对于此示例,我只希望在上午 8 点运行查询时返回记录。我认为这可能会起作用
case
when to_char(sysdate,'HH24') = '08' then
select
*
from
tablename
end
,事实上,它在早上 8 点时间内确实有效,但除此之外它会出错,而不是不返回任何记录。
有什么想法吗?
好吧,我真是太蠢了。我想太多了。我被困在必须使用 if then 之类的条件上。是时候喝更多咖啡了。
I have a query that runs multiple times a day, the issue though is we want the query to only return result when it's run at certain times. So for this example I only want records to be returned when the query is run during the 8am hour. I thought this might work
case
when to_char(sysdate,'HH24') = '08' then
select
*
from
tablename
end
And indeed it does during the 8am hour, but outside of that it errors rather than returning no records.
Any ideas?
Okay well that was dumb of me. I was WAY over thinking it. I was stuck on having to use a if then sort of condition. Time for more coffee.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
也许:
Perhaps:
听起来像你想要的
It sounds like you want