ORA_JAVA.LAST_EXCEPTION
built-in functionThis function returns the last Java exception that occurred when calling Java
from PL/SQL. Use when the PL/SQL exception raised is ORA_JAVA.EXCEPTION_THROWN
.
Note that if you do not add explicit exception handlers to your code, then these Oracle errors might be thrown instead of a named exception:
ORA-105100this is synonymous with ORA_JAVA.JAVA_ERROR
ORA-105101this is synonymous with ORA_JAVA.EXCEPTION_THROWN
FUNCTION ORA_JAVA.LAST_EXCEPTION RETURN ORA_JAVA.JEXCEPTION;
An object of type ORA_JAVA.JEXCEPTION
,
which is a subtype of ORA_JAVA.JOBJECT
.
Whenever you issue a call to a Java method in a PL/SQL block, it is good practice
to use this built-in in the exception-handling part of the calling block to
handle the ORA_JAVA.EXCEPTION_THROWN
type of PL/SQL exception that can occur, for example, NULL pointer. Note that when
ORA_JAVA.EXCEPTION_THROWN
is
thrown, this indicates that an exception was thrown from within the Java method
that was being called.
/*
** This example assumes you have imported the
** java.lang.Exception class.
*/
PROCEDURE foo IS
obj ORA_JAVA.JOBJECT;
excp ORA_JAVA.JEXCEPTION;
BEGIN
obj := jfoo.new;
jfoo.addElement(obj);
EXCEPTION
WHEN ORA_JAVA.EXCEPTION_THROWN THEN
excp := ORA_JAVA.LAST_EXCEPTION;
OFM_MESSAGE(' Java Exception: ' ||
exception_.toString(excp));
...
END;
Handling Java Exceptions from PL/SQL Code
Copyright © 1984, 2005, Oracle. All rights reserved.