I am getting a MariaDB server version for the right syntax to use near 'END IF; END'
I've tried to remove the semi colons sitting getting the errors, I thought I had done it in the correct syntax.
Can anyone spot where I have messed up?
/* Trigger on account table to prevent users entering a opening balance less than 51 */
DELIMITER $$
CREATE TRIGGER account_opening_balance_check
BEFORE INSERT ON account
FOR EACH ROW
BEGIN
IF NEW.opening_balance <= 50.00 THEN
SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = 'Your opening balance must be greater then 50.';
ROLLBACK
END IF;
END$$
DELIMITER ;
ALTER TABLE account ADD CONSTRAINT ob_greater CHECK (opening_balance > 50);This will prevent inserts - as well as updates - from setting the opening_balance lower than 50 for any row. – dbdemon Dec 14 '21 at 16:10