A trigger is written to update the status of the corresponding records in the subtable of the record after a record is deleted.
First, it is written as follows:
Create trigger update_sended on oa_goodssending
After Delete
Update oa_commit_inform_list set sendid = '0' where sendid = deleted. sendid
I thought this would work. Because the deleted data is stored in the deleted table during the delete operation, use the deleted table directly. Who knows the following error:
Message 4104, level 16, status 1, process update_sended, 3rd rows
Unable to bind the identifier "deleted. sendid" consisting of multiple parts ".
After careful research, I found that the data in the deleted table must be selected first, so I changed it
Create trigger update_sended on oa_goodssending
After Delete
Declare @ sendid varchar (50) -- Issuance ID
Select @ sendid = sendid from deleted
-- Print @ sendid
Update oa_commit_inform_list set sendid = '0' where
Sendid = @ sendid
Everything is done!