无法创建数据库android.database.sqlite.SQLiteException

时间:2019-07-08 04:26:26

标签: android sqlite

当我在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中成功运行,但是在构建应用程序时发生上述错误。

0 个答案:

没有答案