0

if sqlcode is not 0 (in oracle plsql) then always throw an exception?

makes sense to ask for SQLCODE if not is an exepcion. Example:

if (sqlcode = 0) ...
Tim
  • 8,669
  • 31
  • 105
  • 183
user60108
  • 3,270
  • 2
  • 27
  • 43

2 Answers2

4

IF you are asking if you should always throw an exception if SQLCODE is not zero, not always.

Here is a list of some SQLCodes. As you can see, some SQLCodes ( such as 100 ) do not necessarily mean that there is an error.

Hope this helps

  • oracle is inconsistent. As I understand sqlcode only makes sense inside an exception handler. But not always throw an exception if sqlcode is not zero. – user60108 Jul 11 '13 at 18:23
  • Yes. I would only look at the SQLCODE in the context of an exception handler. It can, however, be useful when tracing down bugs in code. Since I didn't know in what context to take your question, I was trying to be as generic as possible. – Thomas Erdman Jul 11 '13 at 19:15
3

Looks like you're mixing error checking and exception handling. SQLCODE, by definition, only makes sense inside an exception handler.

Raising exceptions happens automatically. Unless your code is catching exceptions and returning them instead of re-raising them. Which kind of ruins the whole point of exception handling.

Jon Heller
  • 34,999
  • 6
  • 74
  • 132