开发者

Best way to dynamically monitor SQL column value in view?

开发者 https://www.devze.com 2022-12-15 05:49 出处:网络
I have a database that has been partitioned into various yyyymmdd aggregated views.There\'s a column in each of those partitioned views call开发者_C百科ed speed.Is there a way to actively monitor the

I have a database that has been partitioned into various yyyymmdd aggregated views. There's a column in each of those partitioned views call开发者_C百科ed speed. Is there a way to actively monitor the speed value in the partition view, compared with the previous day's max value and insert into another table if today's speed value is greater than yesterday?


If you are looking for a general solution across all database platforms which use SQL, then the answer is no, at least not in the database.

However, most databases have a trigger mechanism. Whether or not they support views depends on the database that you are using. SQL Server, for example, does allow triggers on views.

If you are willing to use a database-specific solution, then this is the direction I would recommend looking down first.

For a general solution across all databases, you would have to rely on application code, polling the value on a regular basis and then comparing it against your condition before you take your action.

0

精彩评论

暂无评论...
验证码 换一张
取 消