Insert data into dataset that exists already in database

Forum related to SQLite

Moderators: gto, cipto_kh, EgonHugeist

Post Reply
MainMeat
Fresh Boarder
Fresh Boarder
Posts: 5
Joined: 21.04.2009, 09:02

Insert data into dataset that exists already in database

Post by MainMeat »

Hi again everyone.

How do I insert data into a dataset that already exists in the same database. Basically, say I populate my dataset with some (not all) of the data in the table. Now I want to add some data to the dataset that already exists in the table - how do I go about inserting this without causing a Unique Key violation?

I cannot figure out how to either select data from the database and add this data in addition to the current data in the dataset (which should avoid the Unique Key constraints), nor am I able to figure out how to avoid the Unique Key violations that might be caused.

If anyone has any solution to the above , please let me know!
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

Hi,

Much depends on your specific case, but when you are reading the records to be inserted by a sql statement in the same db, you may rewrite this sql to make sure an already existing record isn't generated anymore.

An other solution might be to use a locate before calling ZQuery.append. If a record with the same PK already exists the line can be skipped.

Mark
Image
Post Reply