Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
wotrac
Yak Posting Veteran
98 Posts |
Posted - 2003-07-22 : 13:25:23
|
| HiCould anyone tell me whether it is good practice to use a trigger to call a stored procedure. Or should I be placing all of my code in the trigger.Paul |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2003-07-22 : 13:28:32
|
| No, that doesn't sound like a good idea. Your code should be inside stored procedures. Your application should call these stored procedures. But what are you trying to do because your questions lead me to believe that you are going down the wrong path?Tara |
 |
|
|
wotrac
Yak Posting Veteran
98 Posts |
Posted - 2003-07-22 : 13:57:23
|
| I have written the trigger to fire when a sales order is savedin my program as I don't have access to the source code of the application.The trigger then calls the stored procedure to modify certain line of my sales order based on certain criteria within the order detail linesWhen you say I am going down the wrong path, exactly what do you mean.Paul |
 |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2003-07-22 : 14:12:34
|
| I would just do it all in the trigger...Brett8-) |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2003-07-22 : 14:20:46
|
| I was just thinking that you were going to put all of your SQL code into triggers. I would probably put all of the code in the trigger but that just depends upon if you have repeated code or not in there. If there is a specific thing that you need to do over and over again, then I would put that in a stored procedure. If the code is a bit lengthy then you might want to break it up into multiple stored procedures, but that would just be based upon your coding style.Tara |
 |
|
|
wotrac
Yak Posting Veteran
98 Posts |
Posted - 2003-07-22 : 14:31:50
|
| TaraI see where you are coming from and as it happens my procedure fits your description exactly.Many thanks for your advicePaul |
 |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2003-07-22 : 14:39:29
|
quote: The trigger then calls the stored procedure to modify certain line of my sales order based on certain criteria within the order detail lines
What's repeatable about that?Just be careful of recursionBrett8-) |
 |
|
|
|
|
|