Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> problems passing table of object to Java from PL/SQL

problems passing table of object to Java from PL/SQL

From: obakesan <cjeastwd_at_powerup.com.au>
Date: 17 Aug 2004 06:03:05 -0700
Message-ID: <666a787e.0408170351.3b858101@posting.google.com>


HiYa

I've been trying to pass a structure rather than simply an array of string to some Java, however I've been unsucessful. Can anyone suggest what I might be doing wrong?

I've made the following types

create or replace type array_of_persons as table of person;

   PROCEDURE j_test_people (p_dummy IN strArray
                          , p_in IN array_of_persons
                          , p_out OUT strArray) AS
      LANGUAGE JAVA NAME 

'paramPassingTest.pass_person_array(oracle.sql.ARRAY, oracle.sql.ARRAY,
oracle.sql.ARRAY[])';

BEGIN

     people.EXTEND;
     people(1) := person('Chris', 'Eastwood');
     people.EXTEND;
     people(2) := person('James', 'Cook');
     people.EXTEND;
     people(3) := person('Billy', 'Bragg');
     people.EXTEND;
     people(4) := person('Tommy', 'Emanuel');
     cell.EXTEND;
     cell(1) := 'yo there';
     java_test.j_test_people( cell , people , returnData);
   dbms_output.put_line('return data has '|| returnData.COUNT );    FOR i IN 1 .. returnData.COUNT LOOP
     dbms_output.put_line( 'returnData(' || i || ') = ' || returnData(i) );

   END LOOP; END;

public class paramPassingTest
{

   public static void pass_person_array( oracle.sql.ARRAY p_dummy,
                                         oracle.sql.ARRAY p_in,
                                         oracle.sql.ARRAY[] p_out
                                      ) throws java.sql.SQLException
   {
       String[] stringArray = new String[6];
       String[] dataRow;

       Connection conn = new OracleDriver().defaultConnection();
       ArrayDescriptor descriptor =
         ArrayDescriptor.createDescriptor( p_dummy.getSQLTypeName(),
conn );

       stringArray[0] = p_dummy.getSQLTypeName(); //EASTWOOC_DEV.STRARRAY
       stringArray[1] = p_dummy.getBaseTypeName(); //VARCHAR

       stringArray[2] = p_in.getSQLTypeName(); //EASTWOOC_DEV.ARRAY_OF_PERSONS

       stringArray[3] = p_in.getBaseTypeName();  //EASTWOOC_DEV.PERSON
       String[] values = (String[])p_in.getArray();
       p_out[0] = new ARRAY( descriptor, conn, stringArray );
   }

}

its here at the end where I'm falling down. I know that the parameter is getting in, and I'm able to get in my OUT parameter the SQLTypeName and BaseType, but I don't know how to access my data.

I know that if I was passing in a table of varchar2 I could use something like

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

but, I'm beginning to think that it won't support passing anything else.

help! Received on Tue Aug 17 2004 - 08:03:05 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US