Saturday, April 6, 2013

java.sql.SQLException: ORA-01403: no data found

In a PL/SQL function, I do:
SELECT ISRETRIABLE INTO isRetriable
from ACME_ERRORCODES
where ERRORCODE=theERRORCODE;

If theERRORCODE is not found, I get a "ORA-01403: no data found".
In reality, in this case I would like to return 0.
This can be achieved by adding the clause:

  EXCEPTION
    WHEN NO_DATA_FOUND THEN
      return 0;
  WHEN OTHERS THEN
    RAISE;



No comments: