georgesOne
Technical User
Hi everybody,
I have a table A, which includes among others a date field and a hierarchy field.
I want to add new records to this table A, which are generated dynamically through the input of a form with the following conditions:
1. ADD THE NEW RECORD ONLY, if the table A does not contain a record with higher hierarchy within a certain (actually varying) time range.
2. If the record is added then check the table A for records with lower hierarchy within that specific time range and DELETE THOSE RECORDS.
3. The table A is a backend table on the server, so I would like to minimize network traffic.
4. The table A is pretty large, so I need to restrict the relevant records with a query, which unfortunately is not updatable, and will yield on average approximately 250 - 500 records.
5. The new data are about 50 - 100 records.
My idea was to first add all new records to table A and then to run through the records of the query, identify the matching records and eventually delete the match of lower hierarchy in table A. However, it runs slow.
Now I think it might be better not to add the new records in the first place but to construct two local 'help' tables - one containing the new records, one the relevant existing records in the original table A, then to compare and mark them for the appropriate deletions, and finally delete all matching records in the table A and add the new data remaining from one of the help tables.
However, I wonder, if I will get any better performance, and if there is not a better way...
Any good idea?
Thanks, Georges
I have a table A, which includes among others a date field and a hierarchy field.
I want to add new records to this table A, which are generated dynamically through the input of a form with the following conditions:
1. ADD THE NEW RECORD ONLY, if the table A does not contain a record with higher hierarchy within a certain (actually varying) time range.
2. If the record is added then check the table A for records with lower hierarchy within that specific time range and DELETE THOSE RECORDS.
3. The table A is a backend table on the server, so I would like to minimize network traffic.
4. The table A is pretty large, so I need to restrict the relevant records with a query, which unfortunately is not updatable, and will yield on average approximately 250 - 500 records.
5. The new data are about 50 - 100 records.
My idea was to first add all new records to table A and then to run through the records of the query, identify the matching records and eventually delete the match of lower hierarchy in table A. However, it runs slow.
Now I think it might be better not to add the new records in the first place but to construct two local 'help' tables - one containing the new records, one the relevant existing records in the original table A, then to compare and mark them for the appropriate deletions, and finally delete all matching records in the table A and add the new data remaining from one of the help tables.
However, I wonder, if I will get any better performance, and if there is not a better way...
Any good idea?
Thanks, Georges