How to select delta records from two sources of data

I have a requirement where I need to select only delta records between two sources of data and then store only delta records in a table. I have an Entity named as Account  in my application which has three attributes AcountNumber, AccountName and StartDate. I am reading same set of attributes from DB2 database by execution SQL query from a mendix widget. NO my requirement is that whenever My application runs it should compare the data fetched from DB2 system and compare with the records stored in account entity and if there are any new record identfied that is not there in Account Entity, then only those records should be selected and passed for further processing. I tried various ways but every time i run my application the account entity get appended with the entire result fetched from DB2. I guess this is happening because in both the cases medix by default adding an ID column in both the results and this column is also included in the comparison. Any suggestion how to to do that?
1 answers

There are two parts to the solution to this challenge:

  • make sure you transfer as little as possible records from DB2 to Mendix;
  • make sure you don’t import duplicates.

The first part is easily solved if DB2-entity has some auto-increment attribute that you can use to continue where you left off the last time. A creationdate-attribute might do as well, stating in your SQL "WHERE creationdate-attributename > "yourdatevalueforthisrun””

The second part is most easily done by creating an import-mapping, set AccountNumber as key, and create on import:

Any import-objects that already exist will not lead to duplicates in your database.