Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Mailing Lists -> Oracle-L -> Opinion on duplicate values
There is a coder here who has a lot of code that goes like this:
PROCEDURE fsf IS
-- declare some stuff
BEGIN
INSERT into a table
EXCEPTION
WHEN DUP_VAL_ON_INDEX THEN
NULL; -- or it actually performs an update
END fsf;
It is quite a legitimate thing that there could be duplicates because of the fact that data is being read out of files, etc. I do not know if its the norm or the unusual.
If I was coding it and I new there was a possibility of duplicates and I either did not want to insert it or wanted to update the record instead I would check the database first via a SELECT and then base my code on what got returned.
Is one really any better then the other. I am kind of against letting ORA errors being raised on purpose. Its one thing if something goes wrong but this is expected. Which would be harder on the database? They both have to get the data from disk (or memory as the case may be).
--
Please see the official ORACLE-L FAQ: http://www.orafaq.com
--
Author: Kimberly Smith
INET: kimberly.smith_at_gmd.fujitsu.com
Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051 San Diego, California -- Public Internet access / Mailing Lists --------------------------------------------------------------------To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing). Received on Tue Feb 06 2001 - 15:15:20 CST