Reputation: 644
I am using spring-boot and oracle. I am processing data over kafka and a single row is update asynchronously many time updating the count over different topic listeners.
Now i want to terminate this process. Since multiple threads will be updating it. There can be chance that the status is update during this processing part. Can i handle this thing from database itself saying if a particular column's value (say status) is "TERMINATED" it should reject all the updates on this row.
Upvotes: 0
Views: 509
Reputation: 65228
You can create a database trigger during the update dml operation where upcoming value for status column should be prevented if the new column value is TERMINATED
:
CREATE OR REPLACE TRIGGER Trg_Upd_Disable
BEFORE UPDATE ON tab
FOR EACH ROW
BEGIN
IF :OLD.status = 'TERMINATED' THEN
RAISE_APPLICATION_ERROR(-20202, 'The Process cannot be terminated !!');
END IF;
END;
/
Upvotes: 2