ORA-06512 Error Message

Error Ora-06512 means the backtrace message as the stack is being unwound by unhandled exceptions in your PLSQL code. This is a catch-all error for PLSQL exceptions and is commonly seen.

Ora-06512 does not indicate the actual error, but the line number of the unhandled error in the PLSQL code. Ora-06512 will typically appear in a message stack in which the preceding message names the reason for the error, such as in the following example:

ORA-06502: PL/SQL: numeric or value error

ORA-06512: at line 12

The preceding message names the reason for the error (“numeric or value error”) while Ora-06512 indicates the line number of the error (line 12).

There are 3 ways to resolve Ora-06512:

Fix the error causing the unhandled error.

Write an exception handler for the unhandled error.

Contact the database administrator (DBA).

The Solution

The steps of fixing the error will depend on the error itself. This is an example of an Ora-06512 message in a “AProc” procedure for which the error is fixed:

CREATE OR REPLACE PROCEDURE AProc

AS

a_number number(3);

BEGIN

a_number := 1000;

END;

/

When this procedure is written, you will see the following error message:

execute AProc();

BEGIN AProc(); END;

*

ERROR at line 1:

ORA-06502: PL/SQL: numeric or value error: number precision too large

ORA-06512: at "EXAMPLE.APROC", line 5

ORA-06512: at line 1

The preceding error indicates the user the error (number precision too large). Ora-06512 indicates the line number in which the error occurred (line 5). In this case, the error occurred because a 4-digit number was assigned to the variable a_number which is set to handle only 3 digits. The error is resolved by setting the variable a_number to handle 4 digits:

CREATE OR REPLACE PROCEDURE AProc

AS

a_number number(4);

BEGIN

a_number := 1000;

END;

/

Write an Exception Handler

To resolve the same example error as above, you may choose to write an exception handler rather than fixing the error. The following is how you would write an exception handler:

CREATE OR REPLACE PROCEDURE AProc

AS

a_number number(3);

BEGIN

a_number := 1000;

EXCEPTION

WHEN OTHERS THEN

a_number := 999;

END;

/

Since the variable a_number can only handle 3-digits, you can write an exception handler to set the variable a_number to a 3-digit number (999) when this error occurs.

If you cannot resolve the error by fixing the error or writing an exception hander, contact your DBA.

 

STILL HAVE QUESTION?

Submit your question