1
我是Android新手& SQlite。我試圖在Android中的SQLite數據庫上創建以下觸發器。SQlite觸發器執行問題
final String CREATE_TRIGGER_STATES =
"CREATE TRIGGER fk_insert_state BEFORE "
+ "INSERT on tbl_states"
+ "FOR EACH ROW "
+ "BEGIN "
+ "SELECT RAISE(ROLLBACK, 'insert on table "
+ "\"tbl_states\" violates foreign key constraint "
+ "\"fk_insert_state\"') WHERE (SELECT id FROM "
+ "tbl_countries WHERE id = NEW.country_id) IS NULL; "
+ "END;";
db.execSQL(CREATE_TRIGGER_STATES);
錯誤日誌:
android.database.sqlite.SQLiteException: near "EACH": syntax error: CREATE TRIGGER fk_insert_state BEFORE INSERT on tbl_statesFOR EACH ROW BEGIN SELECT RAISE(ROLLBACK, 'insert on table "tbl_states" violates foreign key constraint "fk_insert_state"') WHERE (SELECT id FROM tbl_countries WHERE id = NEW.country_id) IS NULL; END;
是否存在與語法有問題?
是的,這是問題,它現在的作品!謝謝 – 2011-06-13 06:32:32