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.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Trigger Question

Author  Topic 

ckuo@kahluadesigns.com
Yak Posting Veteran

58 Posts

Posted - 2004-11-29 : 13:58:35
In my trigger, I want to call a SP to return some value based on that row's id. Question is, when the trigger is fired, is that row's data already committed so that my SP will have accurate data to calculate?

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2004-11-29 : 14:08:54
well depends what kind of trigger you use.
if you use instead of... trigger then the inserted/updated data is in
"inserted" pseudo-table.

select * from inserted

Go with the flow & have fun! Else fight the flow
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2004-11-29 : 14:20:28
Return it to whom?

YOu don't have control over the trigger. At best you could put some messgaes in to a "log" table, but when would you know to go and take a look.



Brett

8-)
Go to Top of Page

rockmoose
SQL Natt Alfen

3279 Posts

Posted - 2004-11-29 : 16:03:50
The trigger has to succeed for the data to be commited.
However the data you see in the trigger is the data as it would be if commited.
Thus you can reliably use the row's "id" inside the trigger, ( which would be the same as "id" in inserted / deleted tables)

Are you aware that data modifications can occur in batches,
in which case there is not "just one row" in the trigger ?

rockmoose
Go to Top of Page

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2004-11-30 : 13:01:45
hi,
i have a similar problem, what i did was simple.

i created a variable @id and then after the insert assigned the variable to id value, which was an auto numbering function. that way you can get the table id value

If you use the commit transaction or begin/end transactions, If the trigger fails all transactions are roll back, and if it succeeds, then you get your row id value

hope this is what you need ? :-)
Afrika
Go to Top of Page
   

- Advertisement -