We have a customer who sends us an email with all our jobs in a csv file. The problem with this is that this is a list of all the open jobs, so each day contains duplicates of jobs that are still being worked on, rather than just new jobs. They do at least contain a unique ID. I have been talking to their IT bods and have suggested many solutions, but they don't want to go for them. Finally, I have been told to work with the data I have.
So, I need to be able to import the data (with minimal user intervention), less the duplicates. This is the solution I am considering;
Set up 2 identical tables (importtemp and importlog). Set the customers job number as a primary key in import log only. Add an additional yes/no field in import log call 'imported', or similar, with 'no' as the default value.
The procedure would work as follows;
Clear the import temp table
Import the csv data into import temp. Append it to import log, which should only append new records that don't have a corresponding primary key (the unique ID).
Append all records with a 'no' in the imported field into the main database table as required, carry out any required manipulation, etc. Set all the records imported field to 'yes' in import log table using a query.
I have used two tables because if I just import the csv directly into the import log table, the 'failed' ones (i.e. the duplicates) will result in many 'import error' type of tables clogging up my database.
This doesn't appear to be a very elegant solution, as I now have the same data (all be it in a non manipulated form) in two places in my database, import log and the main table. But I can't think of a better way of doing this.
Any advice appreceated.
So, I need to be able to import the data (with minimal user intervention), less the duplicates. This is the solution I am considering;
Set up 2 identical tables (importtemp and importlog). Set the customers job number as a primary key in import log only. Add an additional yes/no field in import log call 'imported', or similar, with 'no' as the default value.
The procedure would work as follows;
Clear the import temp table
Import the csv data into import temp. Append it to import log, which should only append new records that don't have a corresponding primary key (the unique ID).
Append all records with a 'no' in the imported field into the main database table as required, carry out any required manipulation, etc. Set all the records imported field to 'yes' in import log table using a query.
I have used two tables because if I just import the csv directly into the import log table, the 'failed' ones (i.e. the duplicates) will result in many 'import error' type of tables clogging up my database.
This doesn't appear to be a very elegant solution, as I now have the same data (all be it in a non manipulated form) in two places in my database, import log and the main table. But I can't think of a better way of doing this.
Any advice appreceated.