Hi All,
I have this trigger wich runs good!
CREATE trigger trUpdateGEOData
on dbo.BK_Machine
after insert, update
as
update BK_Machine
set BK_Machine.LOC_Street = GEO_Postcode.STraatID,
BK_Machine.Loc_City = GEO_Postcode.PlaatsID
from BK_Machine
inner join GEO_Postcode on BK_Machine.loc_postalcode = GEO_Postcode.postcode
and BK_Machine.LOC_Doornumber >= GEO_Postcode.van
and BK_Machine.LOC_Doornumber <= GEO_Postcode.tem
inner join inserted on BK_Machine.MachineID = Inserted.MachineID
Now the thing is that a machine not neccesarily needs a location which mean that if postalcode or doornumber is NULL this trigger should clear the street and city columns.
Does someone have an Idea?
Cheers WimLOC_Street = case when insrted.PostalCode is Null or
inserted.DoorNumber is Null then '' else GEO_Postcode.STraatID end
Change your UPDATE Statment to include this. Do something similar with Loc_City.
Monday, March 19, 2012
Help needed with trigger
Labels:
bk_machineafter,
bk_machineset,
database,
dbo,
goodcreate,
insert,
microsoft,
mysql,
oracle,
runs,
server,
sql,
trigger,
trupdategeodataon,
updateasupdate,
wich
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment