Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

access to row value in a trigger

Status
Not open for further replies.
Sep 27, 2001
179
AU
Hi

I wish to fire a trigger when a record is updated or inserted in a table. I want the trigger to take the unique ID field of the row being inserted/updated to use to match a row in another table to update a field.

I have the basics of the trigger accept that the trigger I have written updates all the rows in the target table. Which means although the trigger works it isn't very effecient.

How do I get access to the unique ID field of the record being inserted / updated so that it can update just the matching row in the target table?

So far I have:

Code:
Create Trigger PassportXP
on Data
for Insert, Update
as 
Update Person
	Set person.Passport = Data.Date
	From Data, Person
	Where person.Personid =  Data.entityID 
        and Data.fieldID = '23'

Thanks

Rob
 
There is pseudo-table named inserted available within trigger code. It holds new data (affected rows) during INSERTs and UPDATEs.

------
heisenbug: A bug that disappears or alters its behavior when one attempts to probe or isolate it
schroedinbug: A bug that doesn't appear until someone reads source code and realizes it never should have worked, at which point the program promptly stops working for everybody until fixed.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top