To Keep From Overwriting Existing Fields With Your Lookup You Can Use The Upsert Clause.
When working with databases, it is often necessary to update existing data. This is where the Upsert clause comes into play. The Upsert clause is a combination of “update” and “insert” and allows you to perform both operations in one statement. This reduces the amount of code required to accomplish the task and can improve performance.
The Upsert clause is a database command that permits you to modify existing rows and insert new ones. A successful Upsert operation will update any existing records with the new values and, if no record is found to match the criteria, it will create one. The Upsert clause prevents existing fields from being overwritten. For example, if you run an Upsert and your criteria matches a record, the record will be updated with the new values you’ve supplied. However, any fields not specified in the Upsert statement will remain the same.
The Upsert clause can be used to simplify data processing. It saves time and code by reducing the amount of data modifications necessary and thus improves performance. It also prevents data loss by protecting existing data from being overwritten. By using the Upsert clause, you can easily and safely update existing database records.