• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Oracle Function returns ?

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
drifter
Posts: 1364
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Carol,

I already tried but the result its the same.

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

Thanks
 
Ranch Hand
Posts: 1143
1
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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,
 
If we don't do the shopping, we won't have anything for dinner. And I've invited this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic