0

我想知道是否有人可以确认我正在正确地创建 TRIGGER。为了能够使用搜索,我将普通表同步到 FTS 表。但由于某种原因,我不能只使用 FTS,因为每次搜索我都会获得一个空游标,而且它只适用于普通数据库。

public static final String DATABASE_NAME = "CONTACT";
public static final String DATABASE_TABLE = "CONTACTS";
private static final String DATABASE_TABLE_FTS = "CONTACTS_FTS";
private static final int DATABASE_VERSION = 20;
private Context ourContext;
private DbHelper DBHelper;
private static SQLiteDatabase db;
private static final String DATABASE_CREATE = 
        "CREATE TABLE " + DATABASE_TABLE + " (" +
         COL_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
         COL_NAME + " TEXT NOT NULL, " + 
         COL_EMAIL + " TEXT NOT NULL, " +
         COL_CELL + " TEXT NOT NULL, " + 
         COL_ARRIVAL + " TEXT NOT NULL, " +
         COL_DEPARTURE + " TEXT NOT NULL, " + 
         COL_FLIGHT_NUMBER + " TEXT NOT NULL, " +
         COL_HOTEL_ROOM_NUMBER + " TEXT NOT NULL, " + 
         COL_EVENT1 + " TEXT NOT NULL, " +
         COL_EVENT2 + " TEXT NOT NULL, " + 
         COL_EVENT1_ROOM + " TEXT NOT NULL, " +
         COL_EVENT2_ROOM + " TEXT NOT NULL);";

private static final String DATABASE_CREATE_FTS = 
        "CREATE VIRTUAL TABLE " + DATABASE_TABLE_FTS + " USING fts3(" +
        "content=" + "\"CONTACTS\", " + 
        COL_NAME + ");";

private static final String Trigger = 
        "CREATE TRIGGER contacts_Trigger " + 
        "AFTER INSERT "+ "ON " + DATABASE_TABLE +
        " BEGIN " +
        "INSERT " + DATABASE_TABLE_FTS + " SET " + COL_NAME + " = new.COL_NAME WHERE " + COL_ID + " = old.COL_ID;" +
        " END;";
4

0 回答 0