|
From: Alan Campin I know this is a question about which is more efficient but wouldn't the answer be neither? In other words, wouldn't this be much more efficient to use SQL especially if you have multiple records?
Well, it MIGHT perform better on SQL for multiple updates, but you'd have to be very careful in your coding. It would have to be something like: UPDATE filename SET field=newvalue WHERE key1=tgtkey1 and key2=tgtkey2 and key3=tgtkey3 Followed by: UPDATE filename SET field=newvalue WHERE key1=tgtkey1 and key2=tgtkey2 And NOT EXISTS (SELECT 1 from filename WHERE key1=tgtkey1 and key2=tgtkey2 and key3=tgtkey3) Followed by: UPDATE filename SET field=newvalue WHERE key1=tgtkey1 And NOT EXISTS (SELECT 1 from filename WHERE key1=tgtkey1 and key2=tgtkey2) Ignoring issues of atomicity (where a records gets added, updated or deleted between two of those statements), you still have to figure out how to modify each of those statements to process multiple records (the tgtkeyX fields would actually have to come from another file). I think if you actually tried to write the code, you'd find it quite a challenge. What Shannon is asking for is far more a traditional database-driven solution, where the logic executed depends on records or fields in the database. This continues to remain the domain of native I/O. Joe
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.