如何在内部执行存储过程而不是触发器 [英] how to execute stored procedure inside instead of trigger

查看:77
本文介绍了如何在内部执行存储过程而不是触发器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,



我有一张表,其中从第三方工具和一个程序中插入记录,以便在那里发生重复记录我想设置其中的触发器,如果​​找到重复的记录,那么它将不会插入,如果没有,那么它将通过该过程插入,但如何调用过程而不是触发器或任何其他方式从任何一方第三方或从过程插入。







谢谢&问候

Srishti

推荐答案

嗨Srishti



否这是不可能的。

因为它的基本规则你不能从函数调用过程。

触发器是一个特殊的函数,它将在表或数据库发生任何事件后触发。 />


为此,你必须手动处理。





谢谢

Mangesh
Hi Srishti

No its not possible.
Because its basic rule you can not call procedure from function.
Trigger is special function which will fired after any event occurred on table or database.

For this purpose,you have to handle manually.


Thanks
Mangesh


您好,



查看此...



使用触发器调用存储过程 [ ^ ]





希望这会对你有所帮助。





干杯
Hi,

Check this...

Using Trigger to Call a stored procedure[^]


Hope this will help you.


Cheers


你可以:

使用BEFORE INSERT触发器

不执行插入操作键值已存在(引发错误)

直接删除另一行或调用删除另一行的存储过程。



如果键值存在,使用AFTER INSERT触发器引发错误



使用唯一的constrint防止输入重复数据



我建议您不要尝试删除导致触发器触发的插入行。
You can:
Use a BEFORE INSERT trigger to
not do the insert if the key value already exists (raise an error)
to delete the other row directly or call a stored procedure that deletes the other row.

Use an AFTER INSERT trigger to raise an error if the key value exists

Use a unique constrint to prevent the entry of duplicate data

I would suggest that you don't try to delete the inserted row that is causing a trigger to fire.


这篇关于如何在内部执行存储过程而不是触发器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆