What is Exception?
Ø Exceptions
are run time errors that are raised in the PLSQL block.
Definition of SQLCODE:
Ø SQLCODE
returns the error number associated with the most recently raised exception.
Definition of SQLERRM(SQL
Error Message):
Ø SQLERRM
returns the error message associated with the recently raised SQLCODE.
Example:
Result will
be,
PLSQL block results shows error code
with message, Which is known as Runtime
Error.
PLSQL block with exception handling:
Now the result
will be,
We can able to get error code.
SQLERRM:
The result will
be,
- No need to declare any variables just give the Exact name (SQLERRM)
- Now we get SQLCODE with error message in the output block.
Example: 2
v If you want to store a error message in the log table and feel like message is too long then we can use substr() as per the column in the log table.
Now, the length of the error message is
reduced.
No comments:
Post a Comment