I have a requirement when I have to upload a file in db. The file will contain about 100 thousand records daily and once a month from 8 to 10 million records.
There are also some field level checks that need to be done.
validations: all fields are present, a numerical number contains a valid number, a date contains a valid date, a number in the specified range, does the format of the string match, etc.
There are 3 ways.
1: Upload to temp and then validate - Create a temp table (all string columns), have extra error column - upload all entries to temp table - run validation, populate error column if needed - move valid entries to correct table
Cons: records must be written twice in db, even the correct ones.
2: Upload to db directly - upload all entries directly to table - check which entries are not uploaded
Cons: you will need to read each line even after loading, as good as reading twice
3: Validate and then Upload - read each line, run all validations on all columns - if valid then write to db
Cons: reading a file should be slower than bulk loading in db.
I am writing an application in: C # and ASP.NET, DB - Oracle.
Which of the three ways is better?
source share