I guess the example below shows the intended behaviour for Sqlite?

PRAGMA FOREIGN_KEYS=1;
CREATE TABLE t1 (
    id    INTEGER PRIMARY KEY
);

CREATE TABLE t2(
    id    INTEGER PRIMARY KEY,
    t1_id INT NOT NULL,
    CONSTRAINT fk FOREIGN KEY(t1_id) REFERENCES t1(id)
);

INSERT INTO t1 VALUES(2);

BEGIN TRANSACTION;
INSERT OR IGNORE INTO t2 VALUES(1, 1);
INSERT OR IGNORE INTO t2 VALUES(2, 2);
INSERT OR IGNORE INTO t2 VALUES(3, 3);
COMMIT;

Error: FOREIGN KEY constraint failed

I thought row id 1 & 3 simply would get ignored (due to the foreign key mismatch) when specifying INSERT OR IGNORE, but instead the whole transaction gets aborted. Is there any functionality availible to achieve what I want instead (get row 2,2 added to table t2)?

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

Reply via email to