I'm trying to limit a table to only one record and disable all attempt to add more.
I have created this trigger: CREATE TRIGGER abort_insert_to_my_tbl BEFORE INSERT ON my_tbl
BEGIN
RAISE(ABORT,"You can't add records to my_tbl")
END;
But I keep getting this error:
Error: near line 3080: near "RAISE": syntax error
What am I doing wrong?
As the documentation shows, RAISE is a function, not a statement, so it cannot be used directly in the trigger body.
To use a function in a statement, use, for example, a SELECT statement:
CREATE TRIGGER abort_insert_to_my_tbl
BEFORE INSERT ON my_tbl
BEGIN
SELECT RAISE(ABORT, 'You can''t add records to my_tbl');
END;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With