当我在trigger
中创建sqlite
时,会发生此错误:
错误:
Failed to create database
android.database.sqlite.SQLiteException: near ")": syntax error (code 1): , while compiling: CREATE TRIGGER tr_cell AFTER INSERT ON cell_info
FOR EACH ROW
BEGIN
UPDATE
cell_info
SET first_seen = (select datetime(first_seen,'-4 hour','-30 minute')) where (id=NEW.id AND 10 < (SELECT strftime('%s','now') - (SELECT strftime('%s',first_seen) from cell_info c where c.id = id)))
这是我的SQL 代码:
drop trigger if exists tr_cell;
CREATE TRIGGER tr_cell AFTER INSERT ON cell_info
FOR EACH ROW
BEGIN
UPDATE
cell_info
SET first_seen = (select datetime(first_seen,'-4 hour','-30 minute')) where (id=NEW.id AND 10 < (SELECT strftime('%s','now') - (SELECT strftime('%s',first_seen) from cell_info c where c.id = id)));
END;
SQL代码在DB Browser for SQlite中成功运行,但是在构建应用程序时发生上述错误。