Oracle 10g语句级触发器如何访问受语句级触发器影响的行
我正在编写一个触发器,我需要使用语句级触发器。现在,当这样做时,我需要以某种方式访问受此触发器影响的行。我的问题是我是否可以访问类似于 MSSQL 使用的插入和更新表的内容,或者是否有人有任何其他方式可以实现我想要做的事情?
谢谢!
I am writing a trigger and I need to use a statement level trigger. Now when doing so I need to somehow access the rows that have been affected by this trigger. My question is can I access something similar the Inserted and Updated tables that MSSQL uses, or does anyone have any other way in which I could achieve what I am trying to do?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要多个触发器(或 11g 中具有行级和语句级部分的复合触发器)。在行级触发器中,您将看到已更改的行,并将一些数据(主键、ROWID 或整行,具体取决于您的需要)放置在临时表、包中定义的集合或在复合触发器中定义的集合中。在语句级触发器中,您将迭代行级触发器刚刚识别的行。就我个人而言,我还倾向于创建一个 before 语句触发器来初始化集合,以防在首次执行语句时您所维护的任何结构中仍然存在数据)。
You'd need multiple triggers (or a compound trigger in 11g with row-level and statement-level sections). In a row-level trigger, you would see the row that was changed and place some data (a primary key, the ROWID, or the entire row depending on your needs) in either a temporary table, a collection defined in a package, or in a collection defined in your compound trigger. In your statement-level trigger, you would iterate over the rows that your row-level trigger just identified. Personally, I'd also tend to create a before statement trigger that initialized the collection just in case there was still data in whatever structure you're maintaining when the statement is first executed).