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 |
|
kumar7704
Starting Member
4 Posts |
Posted - 2005-04-01 : 08:51:48
|
| I have table 'REQUEST' REQUEST(REQ_ID,REQ_START_DATE,REQ_INITIATOR_ID,REQ_IMPLEMENTOR_ID,REQ_VERIFIER_ID,REQ_NEW_ID)Everytime a new record is inserted into REQUEST I want to check if user REQ_NEW_ID if it is null I want to copy REQ_ID into REQ_NEW_ID..to acheive this I want to write aAFTER Trigger, CREATE TRIGGER myTrigAFTER INSERT ON REQUESTBEGIN IF(REQ_NEW_ID is null) UPDATE REQUEST SET REQ_NEW_ID = :NEW.REQ_IDEND;But I get an error saying that trigger is trying to modify the mutating record, what does this mean? How can I fix this trigger.. |
|
|
rfrancisco
Yak Posting Veteran
95 Posts |
Posted - 2005-04-01 : 09:40:22
|
| Looking at your syntax, it looks like your trigger is for Oracle and not SQL Server. If you are working with SQL Server, try this one:CREATE TRIGGER myTrigAFTER INSERT ON REQUESTBEGINUPDATE ASET REQ_NEW_ID = ISNULL(A.REQ_NEW_ID, A.REQ_ID)FROM REQUEST A INNER JOIN INSERTED B ON A.REQ_ID = B.REQ_IDEND; |
 |
|
|
|
|
|