B
Bill Le May
We are debugging a problem with an application that sporadically writes to
record 0 in a certain database table. So far we can't determine what
conditions cause it to write to this record, but we would like to alleviate
the problems it causes. I thought maybe a trigger would be a solution to
detect when Record 0 is being updated. The examples of triggers that I've
found don't cover cases where only a certain record is being updated.
My table name is Lienholder
The Primary key is LienholderID
The field that's being updated erroneously is Name
So, I want this trigger to fire when LienHolderID=0
I'm not sure what to put in /* */
Does the following look correct?
CREATE TRIGGER CheckZeroRecord ON [Lienholder]
FOR UPDATE
AS
IF (SELECT LienholderID FROM inserted) = 0
BEGIN
PRINT 'Cannot write to record 0'
PRINT 'Transaction has been cancelled'
ROLLBACK
END
Thanks,
Bill
record 0 in a certain database table. So far we can't determine what
conditions cause it to write to this record, but we would like to alleviate
the problems it causes. I thought maybe a trigger would be a solution to
detect when Record 0 is being updated. The examples of triggers that I've
found don't cover cases where only a certain record is being updated.
My table name is Lienholder
The Primary key is LienholderID
The field that's being updated erroneously is Name
So, I want this trigger to fire when LienHolderID=0
I'm not sure what to put in /* */
Does the following look correct?
CREATE TRIGGER CheckZeroRecord ON [Lienholder]
FOR UPDATE
AS
IF (SELECT LienholderID FROM inserted) = 0
BEGIN
PRINT 'Cannot write to record 0'
PRINT 'Transaction has been cancelled'
ROLLBACK
END
Thanks,
Bill