This CF tag will read a csv file with over 20k records in it, then compare each record with a table in the database. The table is called ci_real. The table name may vary, for this there is a variable that can be easily changed. There will be an ID field in the csv file that never changes (employeeid). This script will ran nightly so it is imperative that the file runs at optimum performance. The file starts by using a CF page so if the file is in .net or java, it will be called by CF page. Tables Structure: CI_REAL id - primary key, identity company - varchar employeeid - unique identifier for record - varchar firstname - varchar lastname - varchar dob - varcahr orglevel - varchar internaljobcode - tinyint jobtitle - varchar currentstatus - char(1) regaljobcode - varchar cistatus - bit - default 1 certTrackCompletion - bit defaul 0 CI_RE_Updates id - forieng key to ci_re.id date_time - timestamp - dbstatuscode - tinyint LOGS_ScheduledTasks id - primary key, identity date_time - timestamp scheduledTaskID - integer status - tinyint description - text 1. Search directory for csv files. 2. Read Each record in the CSV files found. File length (amount of records) will change each time. File location is passed in as a variable as file location will change daily. 2. Check each record: If a record exists in the file but not in the database, will insert it. If a record exists in the file and in the database and there has been a change in the records, will update it. Only changes if information varies. If a record exists in the database but not in the file, updates the cistatus field to 0 in the table. Each time a record is modified in the ci_re table, you will need to modify the ci_re_updates table. When insert, dbstatuscode = 1, when update, dbstatuscode = 2, when record no longer in the file but in the database, dbstatuscode = 0. 3. When all records have been reviewed, copy the csv file to archived folder and insert into logs_scheduledtasks (scheduledTaskId=1, status=1), if unsuccesfull, enters status =0 and description and notify administrator.
This tag is unbelievably fast. You will get entire codes.
|