RAISE()
is a SQL function, you'll need to use it as part of a statement; TRIGGER
s only allow for UPDATE
, INSERT
, DELETE
or SELECT
statements; use it in a SELECT
:
CREATE TRIGGER CheckingDate
BEFORE INSERT ON MyTable
FOR EACH ROW
WHEN NEW.Start_date > NEW.End_date
BEGIN
SELECT RAISE(ABORT, 'End_date must be in the future');
END;
This triggers the error correctly:
sqlite> insert into mytable values ('2030-1-1 20:20:20', datetime('now'));
Error: End_date must be in the future