Java - Recuperar array de Oracle

 
Vista:

Recuperar array de Oracle

Publicado por Guillermo (2 intervenciones) el 02/02/2010 12:47:34
Tengo el siguiente procedimiento en oracle:

INICIO PROCEDIMIENTO

PROCEDURE COMPROBAR_FILTRO_TEST (pResultadoFiltro IN OUT RES_FILTRO)

IS
BEGIN

presultadofiltro:=RES_FILTRO();
presultadofiltro.extend(5);
presultadofiltro(1) := 'N';
presultadofiltro(2) := 'S';
presultadofiltro(3) := 'S';
presultadofiltro(4) := 'S';
presultadofiltro(5) := 'N';

EXCEPTION
WHEN OTHERS THEN
raise_application_error(-20009,'OTHERS: '|| sqlcode || sqlerrm);
END; --END PROCEDURE COMPROBAR_FILTRO_TEST

FIN PROCEDIMIENTO

RES_FILTRO es un tipo declarado por mí de la siguiente manera:
CREATE OR REPLACE TYPE "RES_FILTRO" AS VARRAY(100) OF CHAR;

Ahora desde Java, lo intento recuperar de la siguiente manera:

INICIO JAVA

Connection conn = null;
OracleCallableStatement stmt = null;

try {

DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());

conn = DriverManager.getConnection("jdbc:oracle:thin:@<ip>:1521:<instancia>", "usuario", "password");

stmt =(OracleCallableStatement)conn.prepareCall("CALL GBAEZA.COMPROBAR_FILTRO_TEST(?)" );

// The name we use below, EMPARRAY, has to match the name of the type defined in SQL
stmt.registerOutParameter(1, oracle.jdbc.driver.OracleTypes.ARRAY, "RES_FILTRO" );

stmt.executeQuery();

oracle.sql.ARRAY simpleArray = stmt.getARRAY(1);

System.out.println("Array is of type " + simpleArray.getSQLTypeName());
System.out.println("Array element is of type code " +simpleArray.getBaseType());
System.out.println("Array is of length " + simpleArray.length());

String[] values = (String[])simpleArray.getArray();

int intContador = 0;
while(5 > intContador) {
String value = values[intContador];

System.out.println("row " + intContador + " = " + value);
intContador++;
}
}
catch (SQLException se) {
System.out.println(se.toString());
}
catch (Exception e) {
System.out.println(e.toString());
}
finally {
try {
stmt.close();
conn.close();
}
catch (SQLException se) {
System.out.println(se.toString());
}
}

FIN JAVA

Y esto es lo que obtengo por pantalla:

INICIO SALIDA

Array is of type <esquema>.RES_FILTRO
Array element is of type code 1
Array is of length 5
row 0 = ???
row 1 = ???
row 2 = ???
row 3 = ???
row 4 = ???

FIN SALIDA

¿Alguien sabe por qué obtengo como contenido del array los caracteres ????

Muchas gracias
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder