Is there a way to use trigger to stop INSERT, UPDATE or DELETE from happening?
Yes, raise an exception. Example:
CREATE EXCEPTION noname 'Name cannot be empty';
SET TERM ^ ;
CREATE TRIGGER EMPLOYEE_BIU0 FOR EMPLOYEE
ACTIVE BEFORE INSERT OR UPDATE POSITION 0
AS
BEGIN
if (new.FIRST_NAME = '') then exception noname;
END^
SET TERM ; ^
You can also raise a custom exception message like this:
if (new.FIRST_NAME = '')
then exception noname 'Custom message text';
Please note that exception text is limited to 80 characters in Firebird 1.5 and 1024 characters in Firebird 2.0. Although the engine will accept longer strings, it would silently truncate them to this internal limit.