How can I compare the result of a COUNT inside a trigger in SQLite?
So far, this is the code I've come up with:
CREATE TRIGGER mytrigger
BEFORE INSERT ON mytable
BEGIN
    SELECT CASE WHEN 
        SELECT COUNT (*) FROM mytable >= 3
    THEN
        RAISE(FAIL, "Activated - mytrigger.")
    END;
END;
It fails to compile with:
Error: near "SELECT": syntax error
If I replace SELECT COUNT (*) FROM mytable >= 3 with 1 == 1, it compiles fine, and the trigger executes always.
 
     
     
     
    