My recommendation, in this particular situation, is that “you dare not substitute any ‘alternative source of truth,’ such as a Perl hash, for the one-and-only Source of Truth™ that exists here: “the Oracle database.”
I recommend that your logic in this situation should be absolutely brute-force:
- Start an Oracle transaction.
- Query to see if the value exists.
- If it does not, issue a INSERT query. If it does, UPDATE.
- COMMIT the transaction.
- Rinse and Repeat.™
... but, before you get too much farther into this ... “might there not already be a data-migration utility out there which already does this?” Do you, in fact, really have to create a brand-new custom piece of software to do this? (Frankly, I doubt ...)