A script-enabled browser is required for this page to function properly.

ORA_JAVA.LAST_ERROR

This function returns the error text of the last PL/SQL exception that occurred when calling Java from PL/SQL. Use when the PL/SQL exception raised is ORA_JAVA.JAVA_ERROR.

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:

Syntax

FUNCTION ORA_JAVA.LAST_ERROR RETURN VARCHAR2;

Usage notes

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.JAVA_ERROR type of PL/SQL exception. Note that when ORA_JAVA.JAVA_ERROR is thrown, this doesn't indicate that an exception was thrown from within the Java method that was being called.

Example

/*
** Example of an invalid array element error.
*/

PROCEDURE foo IS
 arr ORA_JAVA.JARRAY;
 n PLS_INTEGER;
BEGIN
 ...
 arr := ORA_JAVA.NEW_BYTE_ARRAY(5);
 n := ORA_JAVA.GET_BYTE_ARRAY_ELEMENT(arr, 5);
 ...
 EXCEPTION
 WHEN ORA_JAVA.JAVA_ERROR THEN
  OFM_MESSAGE(' Alert: ' || ORA_JAVA.last_error);
END;

See also

Handling Runtime Errors

ORA_JAVA.CLEAR_ERROR

ORA_JAVA.LAST_EXCEPTION