如何使用 OracleDataApdater 检测触发器对单行所做的更改
我使用 OracleDataAdapter 和数据表更新一行数据。调用 apdapter 的 .update 方法可以正常工作,但是数据库触发器会在更新后更新其中一个字段值。这导致我出现数据表与数据库不同步的问题。
可能的解决方案 我可以在每个更新语句后重新查询数据或使用 oracle 依赖项触发,但我相信最好的方法是让 DataTable 自身更新为更改后的值,但我该如何执行此操作?我尝试使用 oracle 命令生成器作为更新语句,然后将每个参数更改为输入输出,但这不起作用我也尝试挂钩 RowUpdated 的事件,但不确定在那里看什么。
有什么建议吗?
Im updateing a single row of data using the OracleDataAdapter and datatable. Calling the .update method of the apdapter works fine however a database trigger updates one of the field values after the update. This causes me the problem where the datatable is out of sync with the database.
Possible Solutions
I could requery the data after each update statement or use oracle dependency fires however I believe that the best method would be to have the DataTable update itself to that of the changed values, but how do I do this? I have tried using using the oracle command builder for the update statement and then alter each of the parameters to be inputoutput, this has not worked i have also tried hooking into the events of RowUpdated but unsure as to what to look at there.
Any Suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我能想到的两种方法
1-要么开始维护表更改的历史记录,以便您可以查询历史表以获取更新。
2-维护一个时间戳列,以便当您要更新记录时,可以匹配记录的时间戳来检查您正在更新的记录是否陈旧,如果陈旧则抛出并发异常或重新加载数据。
Two Ways i Can think of
1- Either start maintaing history of table changes so that , you can query your history table for update mades.
2- Maintain a timestamp column so that when you are going to update the record , you can match the timestamp of records to check whether the record you are updating is stale or not if its stale either throw Concurrency exception or reload the data.