Hi all!
I have just recently discovered the strengths of foreign keys but now, I've been banging my head against the wall for a couple of days.
I just can't figure out what is causing the error or how to get around it.
Here's the specs (simplified) of my DB;

create table if not exists a (id integer primary key autoincrement, a text unique, b default current_timestamp); create table if not exists b (id integer primary key autoincrement, a integer references a(id) on update cascade on delete cascade, b text, c text, d text, e text, f real, g text, h text, unique (a, b) on conflict ignore; create table if not exists c (id integer primary key autoincrement, a integer, b integer references b(id) on update cascade on delete cascade, c integer, d text, e integer, f text, g blob, unique (a, b, c) on conflict ignore;

And the insert query;

insert into c (b, c, d, e, f, g) values (:a, :b, :c, :d, :e, :f, :g);

The problem is that I get a "Foreign key constraint failed" error when I try to insert the same data twice. The first time it works as it should and the data is inserted correctly. But, the second time, I get the exception.

Is there anyone out there who's willing (and able) to help me? And hopefully explain what I'm doing wrong.

Regards,
/Jörgen

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to