• 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
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

I have a pl/sql function that returns an Array

 
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My question is how do I receive that array in Java. To start, I send 2 arrays, int and varchar2 as parameters in my pl/sql function. So, I'm only interested in the java program, the code below is what I started. Could anyone tell me if I'm doing it right. Thanks in advance for any help.
StructDescriptor desc1=StructDescriptor.createDescriptor("RECTYPE",ora._con);
STRUCT p1struct = new STRUCT(desc1, ora._con, p1obj1.toArray());
STRUCT p2struct = new STRUCT(desc1, ora._con, p1obj2.toArray());

OracleCallableStatement ocs = (OracleCallableStatement )
ora._con.prepareCall("{call " +
"pegasustypes.show_pegasus(?,?,?,?)}");

ocs.setOracleObject(1, p1struct);
ocs.setOracleObject(2, p2struct);
ocs.setString(3, ownerid);
ocs.setInt(4, num);
ocs.registerOutParameter(1,OracleTypes.STRUCT,"RECTYPE");
ocs.registerOutParameter(2,OracleTypes.STRUCT,"RECTYPE");
ocs.registerOutParameter(3,OracleTypes.CURSOR);
ocs.execute();

ora._rs=(ResultSet)ocs.getObject(1);

while (ora._rs.next()){
System.out.println(ora._rs.getString("pegasus_id").toString());
}
 
Ranch Hand
Posts: 351
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why do you want to move the data from the ResultSet to an Array?
You already have a while loop that prints the ResultSet, so it would not take much to assign the ResultSet values to an Array.
 
bobby, morkos
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What I'm doing is it correct.
The code below what does it do? I don't know what it does exactly, could you please explain me. Thanks.
ocs.registerOutParameter(1,OracleTypes.STRUCT,"RECTYPE");
ocs.registerOutParameter(2,OracleTypes.STRUCT,"RECTYPE");
ocs.registerOutParameter(3,OracleTypes.CURSOR);

Originally posted by Michael Pearson:
Why do you want to move the data from the ResultSet to an Array?
You already have a while loop that prints the ResultSet, so it would not take much to assign the ResultSet values to an Array.


[ April 25, 2002: Message edited by: bobby, morkos ]
 
I didn't say it. I'm just telling you what this tiny ad said.
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic