jeudi 19 mars 2015

android.database.sqlite.SQLiteException: foreign key mismatch (code 1) While Updating Primary Key

I'm using Foreign Keys in SQLite ( Android )


My error :



android.database.sqlite.SQLiteException: foreign key mismatch (code 1): , while compiling: UPDATE partidacapturainfo SET capturaid=68135 WHERE capturaid=1


I'm trying to update primary key of partidacapturainfo


Table partidacapturainfo



CREATE TABLE capturainfo(
capturainfoid INTEGER PRIMARY KEY AUTOINCREMENT,
usuarioid INTEGER,
proyectoid INTEGER,
proyectotiendaid INTEGER,
fecha TEXT,
posicioninicial DOUBLE,
imageninicial TEXT,
fechainicial TEXT,
posicionfinal DOUBLE,
imagenfinal TEXT,
fechafinal TEXT,
estatus INTEGER,
sincronizado INTEGER,
foreign key (proyectotiendaid, proyectoid) references tienda (id, proyecto_id);


Inside table, I just have 1 record, with capturaindoid = 1


I don't understand why can't I update PK capturaindoid...


In documentation,


http://ift.tt/1eCkxPY


it says : Foreign key DML errors are may be reported if:



  • The parent table does not exist, or

  • The parent key columns named in the foreign key constraint do not exist, or

  • The parent key columns named in the foreign key constraint are not the primary key of the parent table and are not subject to a unique constraint using collating sequence specified in the CREATE TABLE, or

  • The child table references the primary key of the parent without specifying the primary key columns and the number of primary key columns in the parent do not match the number of child key columns.


I don't think it is my case.


Any Idea????


Aucun commentaire:

Enregistrer un commentaire