I have a requirement to insert bulk data into an Oracle database from a CSV file. Now table columns specs match those of the CSV file's header with the exception of three additional fields in database:
- A Primary Key field (for which a simple SEQUENCE.NEXTVAL is called)
- A field for the name of the CSV file
- A field for the last modified date+time of the file
The following stack question address an extra column issue, but the solution is pretty easy because it used Oracle sysdate which is internally available. I need to pass a parameter from either batch script/shell script.
Insert actual date time in a row with SQL*loader
Can PARFILE help here somehow?
My other alternative would be to do the whole task in two steps by writing a small java code:
- Use SQL Loader for bulk upload leaving out data for the filename and modified time
- And then run a separate update statement to populate the newly created rows
But I'm looking for something which will get the job done in one shot. Any advice??