SQL 在触发器中执行过程

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1709399/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 04:21:58  来源:igfitidea点击:

Execute procedure in a trigger

sqloraclestored-proceduresexecute

提问by user207902

Is it possible to execute a stored procedure inside a trigger?

是否可以在触发器内执行存储过程?

Thank you

谢谢

回答by Tony Andrews

Yes, like this:

是的,像这样:

create or replace trigger trg
after insert on emp
for each row
begin
   myproc(:new.empno, :new.ename);
end;

回答by Manish Dubey

Yes you can fire a procedure from a Trigger. But, keep in mind that trigger & procedur e should not acess the same table.

是的,您可以从触发器中触发程序。但是,请记住触发器和过程不应访问同一个表。

回答by David Seiler

In SQL Server it is. What DBMS are you using?

在 SQL Server 中是这样。你用的是什么数据库管理系统?

ETA: Oracle, eh? I've no personal experience with it, but thisseems to indicate that you can. I found it by googling "oracle trigger stored procedure".

ETA:甲骨文,嗯?我已经与它没有亲身经历,但这个似乎表明,你可以。我通过谷歌搜索“oracle 触发器存储过程”找到了它。

回答by Kuberchaun

Yes you can. Just keep in mind that a trigger can fire for every row affected with a DML trigger. So your stored procedure should be optimized or you could will run into performance issues. Triggers are a good thing but you just have to keep in mind the performance issues that can come up when using them.

是的你可以。请记住,触发器可以为受 DML 触发器影响的每一行触发。所以你的存储过程应该被优化,否则你可能会遇到性能问题。触发器是一件好事,但您只需要记住使用它们时可能出现的性能问题。