
How to modify records in a table from a csv-file
How to modify records in a table from a csv-file
Hi,
I want to update records in my app from a csv-file. The csv-file holding only 2 fields; 1) e-mail adress and 2) a number. Both fields are defined in my app. The e-mail adress is unique.
Can anybody tell me how to do it?
Thanks
PerB
Re:How to modify records in a table from a csv-file
I forget to mention that the form have several fields but I want only to update the number-field.
Re:How to modify records in a table from a csv-file and DataEase Uniqueness discussed
There si many ways to do this but I will give you two:
1. The standard/default way and how it should work.
Simply create a fixed import by field name and run it. DataEase default functionality is to insert records if new and modify/update if they already exist. Already exist is defined by unique constraint.
Problem with this solution: DataEase uniqueness. When you make fields unique in a DataEase form it is the combination of all the unique fields in the form that is being enforced, not each field individually (a lot of mistakes with this). Ex. If you have unique email address and unique record ID and the Record ID is a sequence you can have as many desales@dataease.com records you like as long as they all have a different record ID.
2. The second and more controlled solution.
Create a temporary table that match your import.
Import the data into it.
Run a DQL like the one under.
for MyTemporaryTableName ;
if count of ActualTable with Email=MyTemporaryTableName Email >0 then
modify records in ActualTable with Email=MyTemporaryTableName email
Number := MyTemporaryTableName Number .
else
enter a record in ActualTable
Number := MyTemporaryTableName Number .
end
this is all written from the top of my head without any testing so treat it as inspiration and guidance rather than copy paste code ;-)