Click here to Skip to main content
15,064,915 members
Please Sign up or sign in to vote.
3.77/5 (3 votes)
See more:

I have a table in which record is inserted from both third party tool and also from one procedure so that duplicate record occur there i want to set a trigger in it so that if duplicate record found then it will not insert if not then it will insert through that procedure but how to call procedure in instead of trigger or any other way to insert from any side third party or from procedure.

Thanks & regards

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.

srishti_ 14-Aug-14 7:37am
ok thanks
PhilLenoir 14-Aug-14 17:06pm
A trigger is not a function, it is a stored procedure itself. You can call a stored procedure from within a trigger, although you might have issues if the stored procedure causes the trigger to fire or if the trigger is a before trigger and the stored procedure is to work with the rows that fired the trigger.

Check this...

Using Trigger to Call a stored procedure[^]

Hope this will help you.

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.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900