I am fairly certain I have seen something similar to this before, but can't for the life of me find it. Maybe I'm asking the wrong question in the search...
a brief "what I need" out of the question is at the bottom, if you don't want to know the background.
I have a table tblTU with a number of fields. Each record has a unique reference code within the field TUid.
I then have a text file that contains data to update tblTU. This is imported into two tables:
Table 1 tbl_TmpUploads where updates are in the required format (i.e. no blank/missing data)
Table 2 tbl_TmpIncompleteUploads where updates are not recognised. There are only a few in each upload, so I will ignore these for now.
tbl_TmpUploads has an additional field action with either ADD, REMOVE, MODIFY in the text. This identifies how the data should be interperated in tblTU:
If it is ADD, then add the record.
If it is MODIFY, then an existing entry is to be modified (if it exists, as I do not have the original base data)
If it is REMOVE, then remove the corresponding record from tblTU.
BASICALLY:
Fastest route to read each record in tbl_TmpUploads, if the reference in TUid matches to a reference in tblTU then carry out the action in action (ADD, REMOVE, MODIFY). If the reference in TUid does not exist in tblTU, then add the record.
I'm sure this can be done with two nested while loops, but I could imagine this would take forever to go through either of the tables multiple times for each update.
Would it be quicker adding each table to an array (is there any limitation? - multiple arrays - found 'Multidimensional Arrays' should work)
Many thanks in advance for any help. All comments greatly appreciated.
Aubs
a brief "what I need" out of the question is at the bottom, if you don't want to know the background.
I have a table tblTU with a number of fields. Each record has a unique reference code within the field TUid.
I then have a text file that contains data to update tblTU. This is imported into two tables:
Table 1 tbl_TmpUploads where updates are in the required format (i.e. no blank/missing data)
Table 2 tbl_TmpIncompleteUploads where updates are not recognised. There are only a few in each upload, so I will ignore these for now.
tbl_TmpUploads has an additional field action with either ADD, REMOVE, MODIFY in the text. This identifies how the data should be interperated in tblTU:
If it is ADD, then add the record.
If it is MODIFY, then an existing entry is to be modified (if it exists, as I do not have the original base data)
If it is REMOVE, then remove the corresponding record from tblTU.
BASICALLY:
Fastest route to read each record in tbl_TmpUploads, if the reference in TUid matches to a reference in tblTU then carry out the action in action (ADD, REMOVE, MODIFY). If the reference in TUid does not exist in tblTU, then add the record.
I'm sure this can be done with two nested while loops, but I could imagine this would take forever to go through either of the tables multiple times for each update.
Would it be quicker adding each table to an array (is there any limitation? - multiple arrays - found 'Multidimensional Arrays' should work)
Many thanks in advance for any help. All comments greatly appreciated.
Aubs