You don't show any code but it sounds like you're using volatile variables.

Are you using SQLITE_STATIC instead of SQLITE_TRANSIENT?
http://www.sqlite.org/c3ref/bind_blob.html


Michael D. Black
Senior Scientist
Advanced Analytics Directorate
Advanced GEOINT Solutions Operating Unit
Northrop Grumman Information Systems

________________________________________
From: sqlite-users-boun...@sqlite.org [sqlite-users-boun...@sqlite.org] on 
behalf of Duquette, William H (318K) [william.h.duque...@jpl.nasa.gov]
Sent: Monday, October 01, 2012 3:32 PM
To: Discussion of SQLite Database
Subject: EXT :[sqlite] Problem with Foreign Key constraints

Howdy!

I have some code that does the following:

1. Takes a snapshot of some number of database tables, e.g., saves the data 
from those tables as a text string.
2. Later, clears the tables and restores their content from the snapshot.

The snapshot is restored by creating a new INSERT statement for each row, with 
the literal column values in it, and evaluating each of these statements in 
sequence.

The tables contain foreign key constraints with "DEFERRABLE INITIALLY DEFERRED" 
specified; thus, I execute all of these INSERTs within a transaction so that I 
won't get spurious constraint failures.

This has been working, but it's slow, so I'm trying to rework the algorithm to 
use queries with variable references.  Then I update the variables once for 
each row, and call the same query over and over again.  This is much 
faster...but at the end of the transaction I'm getting a foreign key constraint 
failure.  So far as I can tell, all the data is as it should be; and the only 
difference, so far as I can tell, is that I'm now using variables rather than 
literals.

Any ideas?

Will


--
Will Duquette -- william.h.duque...@jpl.nasa.gov
Athena Development Lead -- Jet Propulsion Laboratory
"It's amazing what you can do with the right tools."

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

Reply via email to