Page 1 of 1

Insert data into dataset that exists already in database

Posted: 29.04.2009, 18:42
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!

Posted: 04.05.2009, 00:27
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