문제

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;
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top