Trigger based on sysdate

孤街醉人 提交于 2019-12-20 04:57:36

问题


I have a table

Table Schema:

CREATE TABLE CHARGES 
(
    total NUMBER(30),
    admitdate TIMESTAMP(6),
    dischargedate TIMESTAMP(30)
)

Trigger Algorithm:

if 
{
   dischargedate="null" 
   then total=admitdate-sysdate=difference in days * Total
   Do this every day at 12:00(24 Hr. Format)
}
else
{
    Do Nothing;
}

My question is what to do if the system is offline at 12:00 am. This problem will not allow the trigger to run.


回答1:


To run a piece of code on a specific time, you can use jobs. Triggers are there only to respond to table changes. If the server is down (which it should hardly ever be), the job can be run at a later time.




回答2:


It would be easier to maintain and reason about if you can change approach and store only static values.And do calculations using sysdate only when needed, like in sql output when asked for it.



来源:https://stackoverflow.com/questions/14110433/trigger-based-on-sysdate

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!