Gerbrand van Dieijen wrote:
In any database, you don't actually delete a row, but you execute a DELETE FROM .. WHERE <where_predicate>, the <where_predicate> identifies the row, in case you want to delete a row.
Therefore, Oracle won't throw an exception when you delete a non-existing record/row in a table, it will just don't delete anything.
I'm sorry, but that isn't true. It can be caught.
ben oliver wrote:Does Oracle 10g throw an exception when you try to delete a non-existing row ?
I tried in my application it does not cause any problem. But I am using java data mapping, so I don't know if the database itself would throw exception when it tries to delete a row but can't find the row ?
Yes, you could catch this in pl/sql stored procedure by taking advantage of the cursor attribute %NOTFOUND. You would need to do something like the following:
But if it is already deleted... I wouldn't worry about it.
You can also do a select to query for the data and perform exception handling for not returning any data (in PL/SQL you would do the same with an exception block catching the NO_DATA_FOUND exception).