I have a PL/SQL procedure where I need to update a record if it is there, or insert a new record if it isn't. I decided to try the update and if that fails because of no_data_found then do the insert. But if I get a different error I just want to reraise that error.
So my options are:
Code:DECLARE BEGIN UPDATE my_table_name SET ...; EXCEPTION WHEN NO_DATA_FOUND THEN INSERT INTO my_table_name ...; WHEN OTHERS THEN RAISE; END;Is there a reason to do one rather than the other? Which is better?Code:DECLARE BEGIN UPDATE my_table_name SET ...; EXCEPTION WHEN NO_DATA_FOUND THEN INSERT INTO my_table_name ...; WHEN OTHERS THEN RAISE_APPLICATION_ERROR ( SQLCODE, SQLERRM ); END;
Thanks.![]()




Reply With Quote