| Author |
Topic |
|
olibara
Yak Posting Veteran
94 Posts |
Posted - 2011-03-03 : 17:31:30
|
HelloThis is the first time I'm trying to create a trigger and I'm lostThe goal is to fire the trigger if some specific values are inserted in a table columnThe problem is that I can't found how to test the inserted valueThis is my last unsuccesfull tryThe main problem is how to test the value of the Column Tarra in the inserted recordThank to helpUSE [Clark]GO/****** Object: Trigger [dbo].[tg_DoTotal] Script Date: 03/03/2011 21:18:46 ******/SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOALTER TRIGGER [dbo].[tg_DoTotal]ON [Clark].[dbo].[BakMove]AFTER INSERT@Tarra intASselect @Tarra =Tarra from insertedIF @Tarra <1 BEGIN PRINT 'Test Trigger' END |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
olibara
Yak Posting Veteran
94 Posts |
Posted - 2011-03-03 : 17:55:52
|
| Thanks for HelpI will try to be more clearI have a table BakMove with column Tarra (int), Bruto (int) and DateIf a record are inserted in BakMove having some specific value for Tarra, I want to fire a trigger !This is what I'm trying to do !Is it possible ? |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
olibara
Yak Posting Veteran
94 Posts |
Posted - 2011-03-03 : 18:13:51
|
HelloTarra is a Dutch word it means Tare (the weight of an empty truck) quote: The tare is used to remove the weight of any packaging material or containers, so that only the weight of the material which is packed within the container is displayed. The tare value is then deleted from the remaining weight that can be added to a scale. The word tare is also the weight of a railway car when it is not loaded
But the name of a column has nothing to do with the trigger behaviour I hope So- if a record is inserted in the Table BakMove - And if that record have a value for Tarra < 0, I wand to do somethingHere is a Csharp like pseudo codeif (Record is inserted in BakMove){ if (Record.Tarra < 1) { Do_something(); }} |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
olibara
Yak Posting Veteran
94 Posts |
Posted - 2011-03-04 : 01:23:37
|
quote: Do you thinking you are doing this for 1 Row or many rows???
I want to do it each time A row with specific value is inserted !The do_something will be a stored proc to create a record in another tableBut regarding all your question it seems very difficult to do !Maybe Trigger can't do that ? |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
|