• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Oracle Function returns ?

 
Luis Felipe Bacca Arango
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, i have a problem with a function call from java.

I post here what i done, please help me.

//Create a type named arreglo
CREATE OR REPLACE TYPE ARREGLO IS VARRAY(28) OF VARCHAR2(50)

//Create a function that return an "arreglo" data type
CREATE OR REPLACE FUNCTION OBTIENEENTIDADES RETURN ARREGLO AS

datos ARREGLO := ARREGLO();
CURSOR c_datos is SELECT ENTIDAD_NOMBRE FROM A_ENTIDAD;

BEGIN

FOR cont IN c_datos LOOP
datos.extend;
datos(datos.count) := cont.ENTIDAD_NOMBRE;
END LOOP;

return datos;
END;

//Java code

Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con=DriverManager.getConnection("jdbc racle:thin:@197.0.0.245:1521:ASOFHEIN","SIAFDES","Q1E3T5");
OracleCallableStatement ocs = (OracleCallableStatement)con.prepareCall("{ ? = call OBTIENEENTIDADES}");
ocs.registerOutParameter(1, OracleTypes.ARRAY, "ARREGLO");
ocs.executeUpdate();
ARRAY sA = ocs.getARRAY(1);
String [] valores = (String[])sA.getArray();
for(int i=0; i<valores.length; i++){
System.out.println(valores[i]);
}

That code return an array of 28 positions but all the data is '???',

what is wrong with my code ?? Please help me
[ February 25, 2005: Message edited by: Bear Bibeault ]
 
Carol Enderlin
drifter
Ranch Hand
Posts: 1364
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you try calling the getArray() method instead of getARRAY()?

Looks like it works the same, but returns java.sql.Array instead of oracle's ARRAY.

Array array = proc.getArray( 3 );

String[] timePeriods = (String[]) array.getArray();

I haven't used oracles ARRAY, but am interested.
 
Luis Felipe Bacca Arango
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Carol,

I already tried but the result its the same.

An array with '???' in all the positions.

Thanks
 
Avi Abrami
Ranch Hand
Posts: 1141
1
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Luis Felipe,
My guess is that it is an internationalization (I18N) issue. Oracle do have special JARs to handle such issues. I can't be more specific because I have no experience in these matters.

The question marks ("?") probably mean that your java code cannot correctly display the Spanish characters you retrieved from your database.

If you haven't already done so, I suggest reading the Oracle "Globalization Support Guide" and check the OTN Web site for details on the relevant, required JAR files.

Good Luck,
Avi.
 
Luis Felipe Bacca Arango
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Avi, Thanks for your reply.

I will going to read the "Globalization Support Guide" looking for solutions to my problem.

Regards,
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic