编写 Oracle 函数以获取某个事件的时间(如果该事件不在另一个事件中)
让我解释一下我想要什么:有些组件可能会由于某些原因而失败,并且它们有优先级。现在,我想要的是,如果一个事件发生并且其优先级较低,我会将其开始时间和结束时间传递给函数,看看是否还有其他那段时间存在的高优先级组成部分。如果有,则有四种情况:
如果低优先级事件在高优先级事件的计时,则时间为 0。
如果事件的结束时间处于高优先级,但开始时间在高优先级之外,则为事件外部的时间。
如果事件的开始时间处于高优先级,但结束时间在高优先级之外,则为事件外部的时间。
start 和 end 都出局意味着高优先级出现在低优先级事件之间。
示例:假设每个事件都具有高优先级。我正在发送开始时间和结束时间,例如 12:41:01
和 12:49:01
component start time end time
1 12:40:01 12:50:01 result will be 0 because it's between the start & end
2 12:40:01 12:48:01 result will be 1 minute
3 12:43:01 12:50:01 result will be 2 minutes
4 12:43:01 12:44:01 result will be 7 minutes
我希望该函数以秒为单位向我发送时间。我必须一直将它与每个组件进行比较,并且我不知道如何在仅函数而不是过程中执行此操作。
Let me be explain what I want: There are some components which can fail due to some reasons and they have priorities. Now, what I want is that if an event occurs and its priority is low, I will pass its start time and end time to the function and see if there is some other high priority component that was there in that period of time. If there was, then there are four cases:
If the low priority event is in the timing of high priority event then time is 0.
If the end time of the event is in the high priority but start time is out side the high priority then the time outside the event.
If the start time of the event is in the high priority but end time is out side the high priority then the time outside the event.
both start and end are out means high priority comes in between the low priority event.
Example: Assume that every event has high priority. I am sending the start time and end time, e.g. 12:41:01
and 12:49:01
component start time end time
1 12:40:01 12:50:01 result will be 0 because it's between the start & end
2 12:40:01 12:48:01 result will be 1 minute
3 12:43:01 12:50:01 result will be 2 minutes
4 12:43:01 12:44:01 result will be 7 minutes
I want the function to send me back the time in seconds. I have to compare it with every component all the time, and I don't know how to do it in a function only function not procedure.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
鉴于下表定义
和以下数据,
以下过程将不会给出您要求的结果,但考虑到您的解释有点缺乏细节,我认为这是您所能期望的最好结果。它应该为您提供一些起点来获得您认为想要的东西:
分享和享受。
Given the following table definition
with the following data
the following procedure will NOT give the results you asked for, but given that your explanation was a bit lacking in detail I think this is the best you can hope for. It should give you something to start from to get what you think you want:
Share and enjoy.
该描述似乎没有意义,但我认为这就是您可能正在寻找的内容(假设 start_time_in 和 end_time_in 是输入变量的名称)。
The description doesn't seem to make sense, but I think this is what you might be looking for (assuming start_time_in and end_time_in are the names of your input variables).