I'm trying to build a trigger in MariaDB to follow this logic:
1. If the primary key val exists, increment the counter column
2. Else, insert the primary key into the table
Here is my prosed trigger:
delimiter //
CREATE TRIGGER volume_manager BEFORE INSERT ON individual_key_log
FOR EACH ROW
BEGIN
IF NEW.reference_key not in (
select *
From individual_key_log
where (NEW.reference_key = 'test')
) THEN -- MISSING THEN
CALL `Insert not allowed`;
END IF;
END;
//
delimiter ;