Hi!
Thank You for replying Stefanos!

Unfortunately, the errors were typos on my part. Sorry about that.
As I wrote, everything works fine the first time around.
What I am trying to accomplish is an update from the source data. If the entry is already there, just ignore it. Otherwise add the new data.

I'm using version 3.7.12.

Theories anyone?

Regards,
/Jörgen

 skrev 1970-01-01 01:00:
<pre wrap>
You are missing parentheses here:

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);


Also here you miss 'a'

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


Also what sqlite version are you using?

I have run this with the latest available version (3.7.12.1) under SQLite Manager (Firefox / Iceweasel extension).

If you need any further help, please let me know.

Cheers.

Stefanos



</pre><blockquote type=cite><pre wrap>
________________________________
From: Jörgen Hägglund &lt;jor...@sirlucifer.mine.nu&gt;
To: sqlite-users@sqlite.org
Sent: Sunday, June 3, 2012 11:10 PM
Subject: [sqlite] Foreign key constraint failed

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



</pre></body>
</html>
</html>
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to