Getting ORA-06502 or ORA-01461 When Calling Stored Procedure That Has a CHAR OUT Parameter From JDBC

(Doc ID 1300792.1)

Last updated on MAY 19, 2017

Applies to:

JDBC - Version and later
Information in this document applies to any platform.
***Checked for relevance on 12-Dec-2013***
***Checked for relevance on 21-May-2015*** ( retested using database and JDBC driver version


A simple JDBC standalone testcase gets ORA-06502 PL/SQL: numeric or value error: character string buffer too small (when database parameter blank_trimming=false) or ORA-01461: can bind a LONG value only for insert into a LONG column (when database parameter blank_trimming=true).
The error is triggered by a CallableStatement executing a PL/SQL stored procedure that has an argument of CHAR(10) defined through a %TYPE which is based on a database table column.

JDBC code excerpt:

String sql = "{CALL P_TEST_PROCEDURE(?)}";
stmt = oracleConn.prepareCall(sql);
stmt.registerOutParameter(1, OracleTypes.CHAR);
String o_res = stmt.getString(1);

Table and stored procedure:

SQL> create table TEST_CHAR( "VAL" char(10) NOT NULL);
Table created.

SQL> create or replace
) AS

v_res VARCHAR2(10);


v_res := 'char';
o_res := v_res;
-- reassigning varchar from char will fail with ORA-06512 only when called from java with blank_trimming=false
v_res := o_res;

-- reassigning varchar from char will fail with ORA-01461 only when called from java
insert into test_char values(o_res);


Error Stack:

Exception in thread "main" java.sql.SQLException: ORA-06502: PL/SQL: numeric or value error: character string buffer too small
ORA-06512: at "SCOTT.P_TEST_PROCEDURE", line 12
ORA-06512: at line 1
at oracle.jdbc.driver.T4CTTIoer.processError(
at oracle.jdbc.driver.T4CTTIoer.processError(
at oracle.jdbc.driver.T4C8Oall.processError(
at oracle.jdbc.driver.T4CTTIfun.receive(
at oracle.jdbc.driver.T4CTTIfun.doRPC(
at oracle.jdbc.driver.T4C8Oall.doOALL(
at oracle.jdbc.driver.T4CCallableStatement.doOall8(
at oracle.jdbc.driver.T4CCallableStatement.executeForRows(
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(
at oracle.jdbc.driver.OraclePreparedStatement.execute(
at oracle.jdbc.driver.OracleCallableStatement.execute(
at oracle.jdbc.driver.OraclePreparedStatementWrapper.execute(
at RunTest.callProcedure(
at RunTest.main(


The issue appears to occur with all versions of the JDBC Driver.



Sign In with your My Oracle Support account

Don't have a My Oracle Support account? Click to get started

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms