创建 FoxPro 触发器
我想在foxpro中创建一个触发器,它将在我的数据库表中的每次更新后执行,例如JobActivity。每次更新后,触发器应在表JobActivity中插入更新时间。
I want to create a trigger in foxpro that will execute after every update in my db table, for example JobActivity.After every update, the trigger should insert the update time in the table JobActivity.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以在处理插入/更新之前应用记录规则验证(如 @Stuart Dunkeld 提到的),而不是在更新之后。
转到数据库容器并创建一个类似的存储过程
,然后,对于记录验证规则,放入 SP_LastUpdated()。
Instead of AFTER the update, you could apply a Record RULE validation (as @Stuart Dunkeld mentions) that is applied against the entire record before the insert/update is processed.
Go to your database container and create a stored procedure something like
Then, for the record validation rule, put in SP_LastUpdated().
您可能需要使用创建触发器命令那么,除了你有一个问题:VFP触发器无法更新触发它的表(否则它会以无限循环结束)
我在很多年前做的一个项目中对此有一个解决方案,我认为它使用了记录验证规则进行更新,我回家后会查找并发布。
You would want to use the Create Trigger command then, except you have one problem: a VFP trigger cannot update the table which fires it (as otherwise it would end out in an endless loop)
I had a solution for this in a project I did many years ago, I think it used the Record Validation rule to do the update, I will look it up when I get home and post it.
我的第一个假设是数据表更新是在 VFP 应用程序中完成的。
如果是这样,那就太好了。您只需查看更新的位置并添加必要的代码即可使用日期/时间更新您的 jobActivity 表。
如果正在更新的表本身就是 jobActivity 表,那么用于更新其他数据的 UPDATE 或 REPLACE 命令只需要修改为也写入此更新跟踪字段 - 简单。
事实上,如果您想这样做,您还可以轻松添加执行更新的个人的姓名首字母等。
如果您在使用不同语言的应用程序中执行此操作,您仍然可以添加代码以向 jobActivity 表发出 SQL UPDATE。
祝你好运
My first assumption is that this data table updating is done in a VFP application.
If so, then great. You only need to look where this updating is being done and add the necessary code to also update your jobActivity table with the date/time.
And if the table being updated is itself, the jobActivity table, then the UPDATE or REPLACE command used to update the other data only needs to be modified to also write this Update Tracking field - simple.
In fact if you wanted to do so, you could easily also add the Initials, etc. of the individual doing the update.
If you are doing this in an application using a different language you can still add code to issue a SQL UPDATE to the jobActivity table.
Good Luck