Is always performing a select statement check before executing the Insert/Update/Delete statements through JDBC a good approach, as opposed to waiting for Oracle to report back an error?
There are differing opinions on which is the best approach, but I prefer trapping errors to SELECTing first. The reason is that if you SELECT first and find that you will do your Insert/Update/Delete statement, you've just doubled the work your program has to do. If you SELECT first and then find that you will go ahead and do the actual statement, you will be doing two I/O's (in effect). If you just do the DML and it fails, you've only done one I/O....thus, it could be considered better performance to let the statement fail, trap it and deal with it that way rather than taking on the extra overhead of doing the SELECT statement.
If you don't mind the extra overhead, doing the SELECT is still an option.
For More Information
- Dozens more answers to tough Oracle questions from Karen Morton are available.
- The Best Oracle Web Links: tips, tutorials, scripts, and more.
- Have an Oracle or SQL tip to offer your fellow DBAs and developers? The best tips submitted will receive a cool prize. Submit your tip today!
- Ask your technical Oracle and SQL questions -- or help out your peers by answering them -- in our live discussion forums.
- Ask the Experts yourself: Our SQL, database design, Oracle, SQL Server, DB2, metadata, object-oriented and data warehousing gurus are waiting to answer your toughest questions.
Dig Deeper on Oracle error messages
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.