Foros del Web » Programación para mayores de 30 ;) » Java »

Recuperar array de Oracle

Estas en el tema de Recuperar array de Oracle en el foro de Java en Foros del Web. Tengo el siguiente procedimiento en oracle: Código PHP: PROCEDURE COMPROBAR_FILTRO_TEST  ( pResultadoFiltro IN OUT RES_FILTRO ) IS BEGIN     presultadofiltro := RES_FILTRO ();      presultadofiltro . extend ( 5 ); ...
  #1 (permalink)  
Antiguo 02/02/2010, 06:12
 
Fecha de Ingreso: febrero-2010
Mensajes: 1
Antigüedad: 14 años, 2 meses
Puntos: 0
Recuperar array de Oracle

Tengo el siguiente procedimiento en oracle:

Código PHP:
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 
RES_FILTRO es un tipo declarado por mí de la siguiente manera:
Código PHP:
CREATE OR REPLACE TYPE "RES_FILTRO" AS VARRAY(100OF CHAR
Ahora desde Java, lo intento recuperar de la siguiente manera:

Código PHP:
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(1oracle.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(
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());
    }


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

Etiquetas: oracle, recuperar
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 04:29.