Hi,
I have been looking at an old A5 app that we have been using for quite a few years. Its used to compare a match file (match.dbf, with partial zip/postcodes and other address info) against a sample file (process file.dbf) and then flag any records in the sample file that match.
The address data is concatenated into a single field called address (one long string).
We can have tens of thousands of records in the sample file and hundreds of records in the match file.
This takes quite a while to chew through, is the routine below efficient! Is there a better way to do this and get a faster result?
I have been looking at an old A5 app that we have been using for quite a few years. Its used to compare a match file (match.dbf, with partial zip/postcodes and other address info) against a sample file (process file.dbf) and then flag any records in the sample file that match.
The address data is concatenated into a single field called address (one long string).
We can have tens of thousands of records in the sample file and hundreds of records in the match file.
This takes quite a while to chew through, is the routine below efficient! Is there a better way to do this and get a faster result?
Code:
t1=toseconds(time()) m_tbl=table.open("match",FILE_RW_EXCLUSIVE) total_records=m_tbl.records_get() update.fields = 1 update.field1 = "match_cnt" update.expr1 = "0" m_tbl.update() p_tbl=table.open("process file",FILE_RW_EXCLUSIVE) m_tbl.fetch_first() p_tbl.fetch_first() p_tbl.batch_begin() While .not. m_tbl.fetch_eof() While .not. p_tbl.fetch_eof() If rtrim(upper(match->match1))$upper(process file->address).and.rtrim(upper(match->match2))$upper(process file->address) p_tbl.change_begin() p_tbl.area =m_tbl.area p_tbl.area_name =m_tbl.area_name p_tbl.std =m_tbl.std p_tbl.change_end(.t.) m_tbl.change_begin() m_tbl.match_cnt =m_tbl.match_cnt+1 m_tbl.change_end(.t.) End If p_tbl.fetch_next() End While m_tbl.fetch_next() p_tbl.fetch_first() statusbar.percent(m_tbl.recno(),total_records) End While p_tbl.batch_end() p_tbl.close() m_tbl.close() t2=toseconds(time()) XMsg=ui_msg_Box("","Process Finished"+chr(10)+ltrim(str(t2-t1))+" seconds",ui_ok)
Comment