SQLITE_CONSTRAINT_TRIGGER: RAISE() in a trigger aborted it
A trigger called RAISE(ABORT, ...), RAISE(FAIL, ...) or RAISE(ROLLBACK, ...) and stopped the statement. The message is the text the trigger passed to RAISE.
- Result code
SQLITE_CONSTRAINT_TRIGGER- Name
1811- Category
- Extended result codes
What it means
SQLITE_CONSTRAINT_TRIGGER (1811) means a RAISE() function inside a trigger fired. Triggers use it to enforce rules a CHECK can't express, such as rules that look at other tables. The error message is the text given to RAISE, so a well-written trigger tells you exactly what was wrong.
Common causes
- The data broke a business rule enforced by a trigger.
- A trigger left over from an older version of the schema, enforcing a rule that no longer applies.
How to fix it
-
Read the message and find the trigger that raised it.
SELECT name, sql FROM sqlite_schema WHERE type = 'trigger' AND tbl_name = 'orders';
-
Fix the data, or drop and recreate the trigger if the rule is outdated.
DROP TRIGGER IF EXISTS orders_no_negative_total;
Reproduce it safely
CREATE TABLE t (n INTEGER); CREATE TRIGGER t_positive BEFORE INSERT ON t WHEN NEW.n < 0 BEGIN SELECT RAISE(ABORT, 'n must not be negative'); END; INSERT INTO t VALUES (-1); -- Runtime error: n must not be negative (19)
Related errors
SQLITE_CONSTRAINTconstraint failedSQLITE_ABORTquery abortedORA-04088Oracle: error during execution of trigger
More extended result codes errors
SQLITE_ERROR_MISSING_COLLSEQno such collation sequenceSQLITE_BUSY_RECOVERYanother process is recovering the WALSQLITE_LOCKED_SHAREDCACHErecord locked in shared cacheSQLITE_CONSTRAINT_CHECKCHECK constraint failedSQLITE_ABORT_ROLLBACKstatement aborted by ROLLBACKSQLITE_BUSY_SNAPSHOTstale read can't become a writeSQLITE_IOERR_SHORT_READread returned fewer bytesSQLITE_CANTOPEN_ISDIRthe path is a directory
The code and message text are from the SQLite result and error codes documentation. Browse the full SQLite error list or search every database error.
Work on SQLite in SQLly
A native SQL client for macOS, Windows and Linux with schema-aware IntelliSense, guardrails for risky statements and clear error messages, for SQLite and the other databases you use.