"Igor Tandetnik" wrote... > jose isaias cabrera > wrote: >> I am updating an sqlite db from another sqlite db and it is working >> fine, unless the record does not exists. ie. >> >> "ATTACH db2 AS client; "; >> >> BEGIN; >> INSERT OR REPLACE INTO LSOpenJobs >> SELECT * FROM client.LSOpenJobs >> WHERE login='x' AND XtraB > '2000'; >> COMMIT; >> >> this works fine if the record already exists in the db getting >> updated. However, if the record was deleted, inadvertively, from the >> db getting updated, this will not work. > > What do you mean, will not work? In precisely what way does the observed > behavior differ from one you expect?
I expected the INSERT to insert the record that no longer exists in the main DB. There are two DBs. One that guide the unique record number system and another one, that is a copy of it. I expected, that if a record is deleted from the main DB, but it still existed on another DB, when that user pushed the data to the main DB, the INSERT will find out that it was not there and it would insert it back into the main db. >> Is there a way to insert the record back in the db getting updated if >> it is not there? > > That's precisely what the INSERT part of "INSERT OR REPLACE" would do. I know, but it is not working. > Or are you saying that there's a record that isn't currently in the main > db (perhaps it existed some time ago, but was deleted) nor in the > attached db, and you expect SQLite to somehow magically conjure it up > out of thin air? I don't think real world works quite this way. No. The record exists in the attached DB, but not in the connected db, though, it did exist there. I allowed deletion for records because I expected the INSERT to insert it to the main db. > Igor Tandetnik thanks for the help. josé _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users