Passing an array of beans to PL/SQL proc - can't quite figure it out

Hi
I'm trying to pass in a Java array of beans to a PL/SQL proc and I can't quite get it to work. I did have the more simple case of an array of strings working but I'm stumped as to how to get this more complicated case to work.
I'm using Java 5 and Oracle 10.
My Oracle User Defined Types
create or replace type MY_OBJECT as object (
      id integer,
      join_table_name varchar(30)
create or replace type MY_OBJECT_ARRAY as table of MY_OBJECT;
My PL/SQL proc
create or replace package threshold is
  function validateThresholdSequence (
      thresholdSeqId integer,
      testValue number,
      testDate date,
      validationCriteria in MY_OBJECT_ARRAY
  ) return number;
end;
My Java
  public class ThresholdValidationCriteriaBean
    private String joinTableName = null;
    private Integer id = null;
    //Getters and setters...
  //Map my bean to the PL/SQL UDT - thought this might help but it seems not!
  Map<String, Class<?>> map = c.getTypeMap();
  map.put("MY_OBJECT", ThresholdValidationCriteriaBean.class);
  //Prepair my statement
  String sql=new String("{call threshold.validateThresholdSequence(?,?,?,?) }");
  ps= c.prepareStatement(sql);
  // Set the values to insert
  ps.setInt(1, thresholdSequenceId);
  ps.setDouble(2, testValue);
  ps.setDate(3, new java.sql.Date(date.getTime()));
  //Sort out the array thing
  ArrayDescriptor desc = ArrayDescriptor.createDescriptor("MY_OBJECT_ARRAY", c);
  ThresholdValidationCriteriaBean[] beanArray = new ThresholdValidationCriteriaBean[validationCriteria.size()];
  validationCriteria.toArray(beanArray);
  ARRAY array = new ARRAY (desc, c, beanArray);
  ((oracle.jdbc.driver.OraclePreparedStatement)ps).setARRAY(4, array); When I run this I get the following error on the creation of the ARRAY object
java.sql.SQLException: Fail to convert to internal representation: uk.co.cartesian.ascertain.imm.threshold.ThresholdValidationCriteriaBean@15c7850
     at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
     at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
     at oracle.jdbc.oracore.OracleTypeADT.toDatum(OracleTypeADT.java:239)
     at oracle.jdbc.oracore.OracleTypeADT.toDatumArray(OracleTypeADT.java:274)
     at oracle.jdbc.oracore.OracleTypeUPT.toDatumArray(OracleTypeUPT.java:115)
     at oracle.sql.ArrayDescriptor.toOracleArray(ArrayDescriptor.java:1314)
     at oracle.sql.ARRAY.<init>(ARRAY.java:152)I've spent most of the day so far going from one error to the next - but I seem to be stuck now.
Any help or hints very much appreciated
Cheers
Ian
Edited by: Yanis on Feb 28, 2008 12:12 PM

I've found the answer - I'll put the code here so everyone else can see what seems to work for me
First off the object that is being passed into the array needs to implement a couple of interfaces and so becomes
public class ThresholdValidationCriteriaBean
implements SQLData, Serializable
    private String joinTableName = null;
    private Integer id = null;
    //Getters and Setters
    public String getSQLTypeName()
    throws SQLException
        return "MY_OBJECT";
    public void readSQL(SQLInput stream, String typeName)
        //No need to implement this
    public void writeSQL(SQLOutput stream)
        //No need to implement this
}The code that I used to call the PL/SQL procedure with an array of MY_OBJECT's is
            //Sort out our array stuff
            ArrayDescriptor desc = ArrayDescriptor.createDescriptor("MY_OBJECT_ARRAY", c);
            ThresholdValidationCriteriaBean[] ba = new ThresholdValidationCriteriaBean[validationCriteria.size()];
            //Populate array
            ARRAY arrayToPass = new ARRAY (desc, c, ba);
            //Create our statement
            String sql = new String("{call ? := threshold.validateThresholdSequence(?,?,?,?) }");
            ps = c.prepareCall(sql);
            //Register our out parameter
            ((oracle.jdbc.OracleCallableStatement)ps).registerOutParameter(1, Types.INTEGER);
            // Set the values to insert
            ps.setInt(2, thresholdSequenceId);
            ps.setDouble(3, testValue);
            ps.setDate(4, new java.sql.Date(date.getTime()));
            ((oracle.jdbc.driver.OraclePreparedStatement)ps).setARRAY(5, arrayToPass);
            //Execute call to PL/SQL
            ps.execute(); Edited by: Yanis on 10-Mar-2008 13:17

Similar Messages

  • Passing an array from Java to Pl/SQL Procdures

    I am relatively new to the Java world and I am unable to pass back an array from Java back to the calling PL/SQL procedure. I have read many of the posts that deal with this issue and in specificly have viewed Ask Tom. My main issue is trying to get the data types matched up. I am able to return varchar2, numbers, and the like, but an array of filenames is not happening. I have tried a variety of "types" but unable to accomplish the task. Please help.
    I have my Java class basically defined as:
    public static oracle.sql.ARRAY[] getCollection(String directory)
                   throws SQLException
    { // provide a directory and get a listing of files
    File path = new File( directory );
    String[] list = path.list();
    return list;
    SQL Type and PL/SQL Procedure is:
    CREATE OR REPLACE TYPE PTO_FILE IS TABLE OF VARCHAR2(100);
    create or replace function get_dir_collection( p_directory in varchar2 ) RETURN PTO_FILE
         as language java
    name 'DirCollection.getCollection( java.lang.String ) return oracle.sql.ARRAY[]';
    /

    I know that it is not an ARRAY. It is however an "array" and I am attempting to map Java's String[][ to some "object" on the oracle side.  I have looked at the link you sited and was not able to find the data mapping.  I have found that mapping data types between different "languages" is some of the most difficult aspects of working with multiple languages.
    Any suggestions? Thanks

  • How  to Pass String array from Java to PL/SQL  and this use in CURSOR

    hi,
    I cant understand how to pass Array String as Input Parameter to the Procedure and this array use in Cursor for where condition like where SYMPTOM in( ** Array String **).
    This array containing like (SYMPTOM ) to be returned from the java to the
    pl/sql (I am not querying the database to retrieve the information).
    I cannot find an example on this. I will give the PL/SQL block
    create or replace procedure DISEASE_DTL<*** String Array ***> as
    v_SYMPTOM number(5);
    CURSOR C1 is
    select distinct a.DISEASE_NAME from SYMPTOM_DISEASE_RD a
    where ltrim(rtrim(a.SYMPTOM)) in ('Fever','COUGH','Headache','Rash') ------- ***** Here use this array element(like n1,n2,n3,n4,n5..) ******
    group by a.DISEASE_NAME having count(a.DISEASE_NAME) > 3 ----------- ***** 3 is no of array element - 1 (i.e( n - 1))*****
    order by a.DISEASE_NAME ;
    begin
    for C1rec IN C1 loop
    select count(distinct(A.SYMPTOM)) into v_SYMPTOM from SYMPTOM_DISEASE_RD a where A.DISEASE_NAME = C1rec.DISEASE_NAME;
    insert into TEMP_DISEASE_DTLS_SYMPTOM_RD
    values (SL_ID_SEQ.nextval,
    C1rec.DISEASE_NAME,
    (4/v_SYMPTOM), --------**** 4 is no of array element (n)************
    (1-(4/v_SYMPTOM)));
    end loop;
    commit;
    end DISEASE_DTL;
    Please give the proper solution and step ..
    Thanking you,
    Asish

    I've haven't properly read through your code but here's an artificial example based on a sql collection of object types - you don't need that, you just need a type table of varchar2 rather than a type table of oracle object type:
    http://orastory.wordpress.com/2007/05/01/upscaling-your-jdbc-app/

  • Passing String Array from Java to PL/SQL

    Hi,
    We are having couple of packages which have been written in PL/SQL . I would like to know how i can send arrays as input parameters from Java to any stored proc in Oracle. I am having Oracle 8i as the DB and am using Websphere RSA for deployment purposes.
    please find below Java , PL/SQL code and exception
    PL/SQL Code :
    PACKAGE PKG_SURCHARGE
    IS
    TYPE commodity_key IS TABLE OF VARCHAR2(500) INDEX BY BINARY_INTEGER;
    PROCEDURE RETRIEVE_CHARGES
    in_Commodity_tab IN commodity_key,
    IS
    BEGIN
    dbms_output.put_line('in_Commodity_tab(' || '0' || ') : ' || in_Commodity_tab(0) );
    Java Code :
    CallableStatement cstmt=null;
    Connection conn=null;
    try{
    conn=getConnection();
    System.out.println("++++++connected");
    String sqlStr = "{call Pkg_Surcharge.RETRIEVE_CHARGES(?) }";
    cstmt = conn.prepareCall(sqlStr );
    //1.
    String[] javaArray={"20081117","20081117"};
    ArrayDescriptor dateDescripter = ArrayDescriptor.createDescriptor( "commodity_key", conn );
    oracle.sql.ARRAY dateArray = new oracle.sql.ARRAY(dateDescripter, conn, javaArray);
    System.out.println("++++++registered-1");
    Catch (Exception e){
    e.printStackTrace();
    Exception Occured:
    java.sql.SQLException: Invalid Pattern Name <Schema Name>.commodity_key
    Appreciate your help in this regard
    Thanks
    Srini
    Edited by: [email protected] on Nov 25, 2008 4:55 AM

    Avi is correct. You must create a varray or nested table instead of using a PL/SQL index-by table.
    SQL> create type commodity_key as varray(#) of varchar2(500);
    or
    SQL> create type commodity_key as table of varchar2(500);
    Use the varray if you know the number of items in the array. Otherwise, use the nested table.

  • Problem passing multiple array lists to a single method

    Hi, all:
    I have written a generic averaging method that takes an array list full of doubles, adds them all up, divides by the size of the array list, and spits out a double variable. I want to pass it several array lists from another method, and I can't quite figure out how to do it. Here's the averager method:
         public double averagerMethod (ArrayList <Double> arrayList) {
              ArrayList <Double> x = new ArrayList <Double> (arrayList); //the array list of integers being fed into this method.
              double total = 0;//the total of the integers in that array list.
              for (int i = 0; i < x.size(); i++) {//for every element in the array list,
                   double addition = x.get(i);//get each element,
                   total = total + addition; //add it to the total,
              double arrayListSize = x.size();//get the total number of elements in that array list,
              double average = total/arrayListSize;//divide the sum of the elements by the number of elements,
              return average;//return the average.
         }And here's the method that sends several array lists to that method:
         public boolean sameParameterSweep (ArrayList <Double> arrayList) {
              sameParameterSweep = false;//automatically sets the boolean to false.
              arrayList = new ArrayList <Double> (checker);//instantiate an array list that's the same as checker.
              double same = arrayList.get(2); //gets the third value from the array list and casts it to double.
              if (same == before) {//if the third value is the same as the previous row's third value,
                   processARowIntoArrayLists(checker);//send this row to the parseAParameterSweep method.
                   sameParameterSweep = true;//set the parameter sweep to true.
              if (same != before) {//if the third value is NOT the same,
                   averagerMethod(totalTicks);//go average the values in the array lists that have been stored.
                   averagerMethod(totalNumGreens);
                   averagerMethod(totalNumMagentas);
                   sameParameterSweep = false;
              before = same; //problematic!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
         return sameParameterSweep;
         }Obviously, the problem is that I'm not passing the array lists from this method to the averager method the right way. What am I doing wrong?

    Encephalopathic wrote:
    There are several issues that I see, but the main one is that you are calculating average results but then just discarding them. You never assign the result to a variable.
    In other words you're doing this:
    averagerMethod(myArrayList);  // this discards the resultinstead of this:
    someDoubleVariable = averagerMethod(myArrayList); // this stores the resultAlso, do you wish to check for zero-sized array lists before calculating? And what would you return if the array list size were zero?So in solving that problem, I've come up with another one that I can't figure out, and I can't fix this problem until I fix that.
    I have several thousand lines of data. They consist of parameter sweeps of given variables. What I'm trying to do is to store pieces of
    data in array lists until the next parameter adjustment happens. When that parameter adjustment happens, I want to take the arraylists
    I've been storing data in, do my averaging thing, and clear the arraylists for the next set of runs under a given parameter set.
    Here's the issue: I'm having the devil of a time telling my application that a given parameter run is over. Imagine me doing stuff to several variables (number of solders, number of greens, number of magentas) and getting columns of output. My data will hold constant the number of soldiers, and for, say, ten runs at 100 soldiers, I'll get varying numbers of greens and magentas at the end of each of those ten runs. When I switch to 150 soldiers to generate data for ten more runs, and so forth, I need to average the number of greens and magentas at the end of the previous set of ten runs. My problem is that I can't figure out how to tell my app that a given parameter run is over.
    I have it set up so that I take my data file of, say, ten thousand lines, and read each line into a scanner to do stuff with. I need to check a given line's third value, and compare it to the previous line's third value (that's the number of soldiers). If this line has a third value that is the same as the previous line's third value, send this line to the other methods that break it up and store it. If this line has a third value that is NOT the same as the previous line's third value, go calculate the averages, clear those array lists, and begin a new chunk of data by sending this line to the other methods that break it up and store it.
    This is not as trivial a problem as it would seem at first: I can't figure out how to check the previous line's third value. I've written a lot of torturous code, but I just deleted it because I kept getting myself in deeper and deeper with added methods. How can I check the previous value of an array list that's NOT the one I'm fiddling with right now? Here's the method I use to create the array lists of lines of doubles:
         public void parseMyFileLineByLine() {
              totalNumGreens = new ArrayList <Double>();//the total number of greens for a given parameter sweep
              totalNumMagentas = new ArrayList <Double>();//the total number of magentas for a given parameter sweep.
              totalTicks = new ArrayList <Double>();//the total number of ticks it took to settle for a given parameter sweep.
              for (int i = 8; i < rowStorer.size() - 2; i++) {//for each line,
                   checker = new ArrayList <Double>();//instantiates an array list to store each piece in that row.
                   String nextLine = rowStorer.get(i); //instantiate a string that contains all the information in that line.
                   try {
                        Scanner rowScanner = new Scanner (nextLine); //instantiates a scanner for the row under analysis.
                        rowScanner.useDelimiter(",\\s*");//that scanner can use whitespace or commas as the delimiter between information.
                        while (rowScanner.hasNext()) {//while there's still information in that scanner,
                             String piece = rowScanner.next(); //gets each piece of information from the row scanner.
                             double x = Double.valueOf(piece);//casts that stringed piece to a double.
                             checker.add(x);//adds those doubles to the array list checker.
                   catch (NoSuchElementException nsee) {
                        nsee.printStackTrace();
                   //System.out.println("checker contains: " + checker);
                   processARowIntoArrayLists(checker);//sends checker to the method that splits it up into its columns.
         }

  • Passing values to form bean string array from dynamic added textboxes

    Hi,
    I am unable to pass values to form bean string array from a jsp in which I have incorporated dynamically adding of textboxes in javascript.
    I have given add/delete row option in the jsp. If there is single row, this is working fine. But after adding a row, I am not able to either do any validations on added textboxes or pass the values to the String array form bean variable.
    code snippet:
    var cell6 = row.insertCell(4);
    var element5 = document.createElement("input");
    element5.type = "text";
    element5.className = "formtext1";
    element5.size = "5";
    element5.value = "00.00";
    element5.name= "qty"; // this is a string array of the form bean.
    element5.onchange=function() {checkNumeric(this);};
    cell6.appendChild(element5);
    <html:text styleClass="formtext1" property="qty" value="" size="5" styleId="qty" onchange="checkNumeric(this)"/></td>
    form bean declaration
    private String[] qty; Please help.
    Edited by: j2eefresher on Jan 12, 2010 11:23 PM

    Shivanand,
    There's no need to post that much code when you could create a very short test case that demonstrates only the problem you are having.
    You're using &NAME. notation on something that isn't a page or application item. You can't reference PL/SQL variables that way (or any other way) outside the PL/SQL scope. For your situation, you could create a page item named P55_DOCID and assign it a value in the PL/SQL process (:P55_DOCID := DOCID;), then reference &P55_DOCID. in HTML areas like the success message.
    Scott

  • Need help on passing an array to  java routine from PL/SQL

    I got a math routine in java and the idea is have an array of integer and the java routine does some computatoin and then pass the array back to pl/sql
    and I google the web most code is calling pl/sql from java but not the other way round. any help will be really appreciated.
    {code}
    package tst;
    import java.util.*;
    public class plsql3 {
            private final static int factor1 = 2;
            public static void getFib2(int[] in, int[] out, int k){
                            for (int i=0;i<=k-1;i++){
                    out[i]= in[i] * factor1;
      public static void main(String[] arg){
         int[] in2 = {1,2,3,4,5};
         int[] out2= {0,0,0,0,0};
         getFib2(in2,out2,2);
         for ( int j = 0 ; j <= out2.length-1;j++) {
                    System.out.println(out2[j]);
    {code}
    {code}
    CREATE or replace PROCEDURE getfib5 (x IN OUT numlist, y IN OUT numlist, k in number)
    AS LANGUAGE JAVA
    NAME 'tst.plsql3.getFib2(int[], int[],int)';
    set serveroutput on format wraped;
    declare
      in2 numlist := numlist(1,2,3,4,5,6);
      out2 numlist := numlist(0,0,0,0,0,0);
    begin
    --in2(0) := 1;
    --in2(1) := 2;
    --in2(2) := 3 ;
    for i in 1..in2.count
      loop
        dbms_output.put_line(in2(i));
      end loop;
       for i in 1..in2.count
      loop
        dbms_output.put_line(out2(i));
      end loop;
      getFib5(in2,out2,2);
      for i in 1..in2.count
      loop
        dbms_output.put_line(in2(i));
      end loop;
       for i in 1..in2.count
      loop
        dbms_output.put_line(out2(i));
      end loop;
    --dbms_output.put_line(in2.count);
    end;
    {code}
    {code}
    javac -source 1.5 -target 1.5 tst/plsql3.java
    {code}
    Error report:
    ORA-00932: inconsistent datatypes: expected a value at argument position 1 that is convertible to a Java int got an Oracle named TYPE (ADT, REF etc)
    ORA-06512: at "TK1.GETFIB5", line 1
    ORA-06512: at line 18
    00932. 00000 -  "inconsistent datatypes: expected %s got %s"
    *Cause:   
    *Action:

    http://asktom.oracle.com/pls/asktom/f?p=100:11:::::P11_QUESTION_ID:3696816290928

  • Can I pass an array as an input parameter for a stored procedure on SQL Server 2000

    I am trying to pass an array to a stored procedure residing on my SQL Server 2000 database server. Is this even possible? If it is possible, what is the syntax for this?
    Any help would be greatly appreciated.
    Thanks

    I have passed arrays to and from a database using SQL and ActiveX, including to and from stored procedures, but I cannot recall the precise method used to do so. If memory serves, everything is in the form of a string. You need to do a lot of parsing and 'unparsing' to get this data into your stored procedure.
    You are left with a couple of options to get your data to the stored procedure. I recommend using SQL in LabVIEW wherever possible as it saves the amount of external code calls (and believe me, calling ActiveX procedures developed by someone else in Visual Basic is NOT much fun at all...). You can either send the array and other data to the stored procedure (you will find the syntax in the SQL references in LabVIEW help under SQL), or you can send
    the array to the database, and have the database then act upon the array.
    I strongly recommend making routines (subVIs) to handle these operations.
    Sorry I don't have the syntax, I don't have SQL installed on this machine. If you can't find the syntax in the help, please post here again.
    -Mike Du'Lyea

  • How to pass an array to a procedure & how to use array in IN clause in SQL

    Hi all,
    how do i pass an array of varchar2[10] in an procedure and i want to use this array in the IN caluse of the SQL statement inside the procedure. Can anyone please help me on this.
    Thanks & regards
    shyam~

    There are multiple ways. For example:
    SQL> create or replace
      2    type str10_tbl_type is table of varchar2(10)
      3  /
    Type created.
    SQL> -- Using TABLE operator
    SQL> create or replace
      2    procedure p1(
      3                 p_str10_tbl str10_tbl_type
      4                )
      5      is
      6      begin
      7          for rec in (
      8                      select  ename,
      9                              sal
    10                        from  emp,
    11                              table(p_str10_tbl)
    12                        where ename = column_value
    13                     ) loop
    14            dbms_output.put_line(rpad(rec.ename,10) || rec.sal);
    15          end loop;
    16  end;
    17  /
    Procedure created.
    SQL> set serveroutput on format wrapped
    SQL> exec p1(str10_tbl_type('KING','ALLEN','SMITH'));
    KING      5000
    ALLEN     1600
    SMITH     800
    PL/SQL procedure successfully completed.
    SQL> -- Using MEMBER OF method
    SQL> create or replace
      2    procedure p1(
      3                 p_str10_tbl str10_tbl_type
      4                )
      5      is
      6      begin
      7          for rec in (
      8                      select  ename,
      9                              sal
    10                        from  emp
    11                        where ename member of p_str10_tbl
    12                     ) loop
    13            dbms_output.put_line(rpad(rec.ename,10) || rec.sal);
    14          end loop;
    15  end;
    16  /
    Procedure created.
    SQL> set serveroutput on format wrapped
    SQL> exec p1(str10_tbl_type('KING','ALLEN','SMITH'));
    SMITH     800
    ALLEN     1600
    KING      5000
    PL/SQL procedure successfully completed.
    SQL> SY.

  • Pass an array of a user defined class to a stored procedure in java

    Hi All,
    I am trying to pass an array of a user defined class as an input parameter to a stored procedure. So far i have done the following:
    Step 1: created an object type.
    CREATE TYPE department_type AS OBJECT (
    DNO NUMBER (10),
    NAME VARCHAR2 (50),
    LOCATION VARCHAR2 (50)
    Step 2: created a varray of the above type.
    CREATE TYPE dept_array1 AS TABLE OF department_type;
    Step 3:Created a package to insert the records.
    CREATE OR REPLACE PACKAGE objecttype
    AS
    PROCEDURE insert_object (d dept_array);
    END objecttype;
    CREATE OR REPLACE PACKAGE BODY objecttype
    AS
    PROCEDURE insert_object (d dept_array)
    AS
    BEGIN
    FOR i IN d.FIRST .. d.LAST
    LOOP
    INSERT INTO department
    VALUES (d (i).dno,d (i).name,d (i).location);
    END LOOP;
    END insert_object;
    END objecttype;
    Step 4:Created a java class to map the columns of the object type.
    public class Department
    private double DNO;
    private String Name;
    private String Loation;
    public void setDNO(double DNO)
    this.DNO = DNO;
    public double getDNO()
    return DNO;
    public void setName(String Name)
    this.Name = Name;
    public String getName()
    return Name;
    public void setLoation(String Loation)
    this.Loation = Loation;
    public String getLoation()
    return Loation;
    Step 5: created a method to call the stored procedure.
    public static void main(String arg[]){
    try{
    Department d1 = new Department();
    d1.setDNO(1); d1.setName("Accounts"); d1.setLoation("LHR");
    Department d2 = new Department();
    d2.setDNO(2); d2.setName("HR"); d2.setLoation("ISB");
    Department[] deptArray = {d1,d2};
    OracleCallableStatement callStatement = null;
    DBConnection dbConnection= DBConnection.getInstance();
    Connection cn = dbConnection.getDBConnection(false); //using a framework to get connections
    ArrayDescriptor arrayDept = ArrayDescriptor.createDescriptor("DEPT_ARRAY", cn);
    ARRAY deptArrayObject = new ARRAY(arrayDept, cn, deptArray); //I get an SQLException here
    callStatement = (OracleCallableStatement)cn.prepareCall("{call objecttype.insert_object(?)}");
    ((OracleCallableStatement)callStatement).setArray(1, deptArrayObject);
    callStatement.executeUpdate();
    cn.commit();
    catch(Exception e){ 
    System.out.println(e.toString());
    I get the following exception:
    java.sql.SQLException: Fail to convert to internal representation
    My question is can I pass an array to a stored procedure like this and if so please help me reslove the exception.
    Thank you in advance.

    OK I am back again and seems like talking to myself. Anyways i had a talk with one of the java developers in my team and he said that making an array of structs is not much use to them as they already have a java bean/VO class defined and they want to send an array of its objects to the database not structs so I made the following changes to their java class. (Again hoping some one will find this useful).
    Setp1: I implemented the SQLData interface on the department VO class.
    import java.sql.SQLData;
    import java.sql.SQLOutput;
    import java.sql.SQLInput;
    import java.sql.SQLException;
    public class Department implements SQLData
    private double DNO;
    private String Name;
    private String Location;
    public void setDNO(double DNO)
    this.DNO = DNO;
    public double getDNO()
    return DNO;
    public void setName(String Name)
    this.Name = Name;
    public String getName()
    return Name;
    public void setLocation(String Location)
    this.Location = Location;
    public String getLoation()
    return Location;
    public void readSQL(SQLInput stream, String typeName)throws SQLException
    public void writeSQL(SQLOutput stream)throws SQLException
    stream.writeDouble(this.DNO);
    stream.writeString(this.Name);
    stream.writeString(this.Location);
    public String getSQLTypeName() throws SQLException
    return "DOCCOMPLY.DEPARTMENT_TYPE";
    Step 2: I made the following changes to the main method.
    public static void main(String arg[]){
    try{
    Department d1 = new Department();
    d1.setDNO(1);
    d1.setName("CPM");
    d1.setLocation("LHR");
    Department d2 = new Department();
    d2.setDNO(2);
    d2.setName("Admin");
    d2.setLocation("ISB");
    Department[] deptArray = {d1,d2};
    OracleCallableStatement callStatement = null;
    DBConnection dbConnection= DBConnection.getInstance();
    Connection cn = dbConnection.getDBConnection(false);
    ArrayDescriptor arrayDept = ArrayDescriptor.createDescriptor("DEPT_ARRAY", cn);
    ARRAY deptArrayObject = new ARRAY(arrayDept, cn, deptArray);
    callStatement = (OracleCallableStatement)cn.prepareCall("{call objecttype.insert_array_object(?)}");
    ((OracleCallableStatement)callStatement).setArray(1, deptArrayObject);
    callStatement.executeUpdate();
    cn.commit();
    catch(Exception e){
    System.out.println(e.toString());
    and it started working no more SQLException. (The changes to the department class were done manfully but they tell me JPublisher would have been better).
    Regards,
    Shiraz

  • Passing an array as parameter from java (java controls) to stored procedure

    Hi,
    I'm using java controls (BEA Weblogic Workshop 8.1) to call a stored procedure and send an array as a parameter to the stored procedure from java. The following code below throws an exception "Fail to convert to internal representation".
    Java code
    import com.bea.control.DatabaseControl.SQLParameter;
    // Here i create the java array
    int[] javaArray={12,13,14};
    //The code below is used to create the oracle sql array for the procedure
    SQLParameter[] params = new SQLParameter[1];
    Object obj0=javaArray;
    params[0] = new SQLParameter(obj0, oracle.jdbc.OracleTypes.ARRAY, SQLParameter.IN);
    // the code below calls the testFunc method in OJDBCtrl.jcx file
    String succ= dbControl.testFunc(params);
    OJDBCtrl.jcx
    * @jc:sql statement="call CMNT_TST_PROC(?))"
    String testFunc(SQLParameter[] param);
    The stored procedure used:
    TYPE SL_tab IS TABLE OF number INDEX BY PLS_INTEGER;
    Procedure cmnt_tst_proc (cmnt_tst sl_tab);
    Procedure cmnt_tst_proc (cmnt_tst sl_tab) is
    BEGIN
    dbms_output.put_line('Hello');
    END;
    I am getting the following exception
    Failure=java.sql.SQLException: Fail to convert to internal representation: [I@438af4 [ServiceException]>
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:125)
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:162)
    at oracle.jdbc.driver.DatabaseError.check_error(DatabaseError.java:861)
    at oracle.sql.ARRAY.toARRAY(ARRAY.java:210)
    at oracle.jdbc.driver.OraclePreparedStatement.setObjectCritical(OraclePreparedStatement.java:7768)
    at oracle.jdbc.driver.OraclePreparedStatement.setObjectInternal(OraclePreparedStatement.java:7449)
    at oracle.jdbc.driver.OraclePreparedStatement.setObjectInternal(OraclePreparedStatement.java:7837)
    at oracle.jdbc.driver.OracleCallableStatement.setObject(OracleCallableStatement.java:4587)
    at weblogic.jdbc.wrapper.PreparedStatement.setObject(PreparedStatement.java:244)
    at com.bea.wlw.runtime.core.control.DatabaseControlImpl._setParameter(DatabaseControlImpl.jcs:1886)
    at com.bea.wlw.runtime.core.control.DatabaseControlImpl.getStatement_v2(DatabaseControlImpl.jcs:1732)
    at com.bea.wlw.runtime.core.control.DatabaseControlImpl.invoke(DatabaseControlImpl.jcs:2591)
    at com.bea.wlw.runtime.core.dispatcher.DispMethod.invoke(DispMethod.java:377)
    at com.bea.wlw.runtime.core.container.Invocable.invoke(Invocable.java:433)
    at com.bea.wlw.runtime.core.container.Invocable.invoke(Invocable.java:406)
    at com.bea.wlw.runtime.core.container.Invocable.invoke(Invocable.java:249)
    at com.bea.wlw.runtime.jcs.container.JcsContainer.invoke(JcsContainer.java:85)
    at com.bea.wlw.runtime.core.bean.BaseContainerBean.invokeBase(BaseContainerBean.java:224)
    at com.bea.wlw.runtime.core.bean.SLSBContainerBean.invoke(SLSBContainerBean.java:109)
    at com.bea.wlwgen.StatelessContainer_ly05hg_ELOImpl.invoke(StatelessContainer_ly05hg_ELOImpl.java:153)
    Can you please let me know, what i'm doing wrong and how i can pass an array to a procedure/function using java controls.
    Any help will be highly appreciated.
    Edited by: user12671762 on Feb 24, 2010 5:03 AM
    Edited by: user9211663 on Feb 24, 2010 9:04 PM

    Thanks Michael.
    Here's the final code that i used, this might be helpful for those who face this problem
    Java Code
    // Following code gets the connection object
    InitialContext ctx = new InitialContext();
    dataSource = (DataSource)ctx.lookup("<DataSourceName>");
    conn=dataSource.getConnection();
    // Following code is used to create the array type from java
    String query="CREATE OR REPLACE TYPE STR_ARRAY AS VARRAY(3) OF NUMBER";
    dbControl.runTypeQuery(query);
    // Following code is used to obtain the oracle sql array as SQLParameter
    ArrayDescriptor desc = ArrayDescriptor.createDescriptor("<schemaName>.STR_ARRAY", conn);
    Object[] elements = new Object[3];
    elements[0] = new Integer(12);
    elements[1] = new Integer(13);
    elements[2] = new Integer(14);
    oracle.sql.ARRAY newArray = new oracle.sql.ARRAY( desc, conn, elements);
    SQLParameter[] params = new SQLParameter[1];
    params[0] = new SQLParameter(newArray, oracle.jdbc.OracleTypes.ARRAY, SQLParameter.IN);
    String succ= dbControl.testFunc(params);

  • Passing an array in a for loop to a procedure

    I am trying to pass an array in a cursor for loop to a procedure which performs a table insert using the array's contents. Somehow I am missing something, or it is not possible. The compile error states: PLS-00306: wrong number or types in call to 'insert_address' I checked to be sure I am creating the arrays in both cases from similar data objects. Both address and work_address_table contain the same 4 columns with the same data types.
    create or replace package work_address as
    FUNCTION populate_address return boolean;
    procedure insert_address(in_address IN work_address_table%ROWTYPE);
    end work_address;
    create or replace package body work_address as
    function populate_address return boolean is
    cursor c1 is
    select 'H' as header,
    street1 as street
    city as city,
    NULL as state
    from address
    where city = 'HANOVER';
    TYPE addressT IS TABLE OF c1%ROWTYPE INDEX BY BINARY_INTEGER;
    rec1 addressT;
    BEGIN
    OPEN c1;
    FETCH c1 BULK COLLECT INTO rec1 LIMIT 500;
    FOR i IN 1..rec1.count LOOP
    rec1(i).state := 'US'
    insert_address(rec1(i));
    exit when c1%notfound;
    END LOOP;
    CLOSE c1;
    return TRUE;
    END populate_address;
    PROCEDURE insert_address(in_address IN work_address_table%ROWTYPE) IS
    BEGIN
    INSERT INTO work_address_table
    VALUES (in_address.header,
    in_address.street,
    in_address.city,
    in_address.state);
    COMMIT;
    END insert_address;
    END work address;
    /

    Both address and work_address_table contain the same 4 columns with the same data types.Are you 100% sure about this?
    SQL> declare
      cursor c1
      is
        select 1 deptno, dummy dname, 'Loc' location from dual;
      type addresst is table of c1%rowtype
        index by binary_integer;
      rec1   addresst;
      procedure p (d dept%rowtype)
      as
      begin
        dbms_output.put_line(d.dname);
      end p;
    begin
      rec1 (1).dname := 'z';
      p (rec1 (1));
    end;
    z
    PL/SQL procedure successfully completed.but changing just the first column of the cursor:
    SQL> declare
      cursor c1
      is
        select 'xy' deptno, dummy dname, 'Loc' location from dual;
      type addresst is table of c1%rowtype
        index by binary_integer;
      rec1   addresst;
      procedure p (d dept%rowtype)
      as
      begin
        dbms_output.put_line(d.dname);
      end p;
    begin
      rec1 (1).dname := 'z';
      p (rec1 (1));
    end;
    Error at line 3
    ORA-06550: line 20, column 3:
    PLS-00306: wrong number or types of arguments in call to 'P'
    ORA-06550: line 20, column 3:
    PL/SQL: Statement ignored

  • Trouble while passing an array as a parameter to an JDBC Control

    Hi everyone, recently I have upgraded my WLS Workshop 8.1 application to WLS 10gR3 using the workshop 8.1 application upgrade but after the upgrade to beehive controls I'm having troubles in a couple of methods that receive an array as a parameter. One of the methods is the following:
    * @jc:sql array-max-length="all" max-rows="all"
    * statement::
    * select COUNT(*) FROM (
    * SELECT la.lea_gkey,la.eme_gkey
    * FROM (SELECT gkey, name, role FROM employees WHERE {sql:fn in(gkey,{emeGkeyArray})}) e,
    * lead_assignees la,
    * leads le,
    * cities ct,
    * (select lea_gkey,name,email,phone,title from contacts where principal = 'X') cn,
    * (SELECT lea_gkey, tag FROM lead_tags WHERE tag = 'TARGET') targets,
    * (SELECT lea_gkey, tag FROM lead_tags WHERE tag = 'TOP5') top5,
    * (SELECT lea_gkey, tag FROM lead_tags WHERE tag = 'TOP100') top100
    * WHERE e.gkey = la.eme_gkey
    * AND la.lea_gkey = le.gkey
    * AND le.city = ct.gkey(+)
    * AND le.gkey = cn.lea_gkey(+)
    * AND le.gkey = targets.lea_gkey(+)
    * AND le.gkey = top5.lea_gkey(+)
    * AND le.gkey = top100.lea_gkey(+)
    * {sql: whereClause}
    * UNION
    * SELECT DISTINCT la.lea_gkey,la.eme_gkey
    * FROM (SELECT gkey, name, role FROM employees WHERE {sql:fn in(gkey,{emeGkeyArray})}) e,
    * lead_assignees la,
    * shared_accounts sa,
    * leads le,
    * cities ct,
    * employees asign,
    * (select lea_gkey,name,email,phone,title from contacts where principal = 'X') cn,
    * (SELECT lea_gkey, tag FROM lead_tags WHERE tag = 'TARGET') targets,
    * (SELECT lea_gkey, tag FROM lead_tags WHERE tag = 'TOP5') top5,
    * (SELECT lea_gkey, tag FROM lead_tags WHERE tag = 'TOP100') top100
    * WHERE e.gkey = sa.eme_gkey
    * AND asign.gkey = la.eme_gkey
    * AND asign.active='X'
    * AND sa.lea_gkey = le.gkey
    * AND sa.lea_gkey = la.lea_gkey
    * AND le.city = ct.gkey(+)
    * AND le.gkey = cn.lea_gkey(+)
    * AND le.gkey = targets.lea_gkey(+)
    * AND le.gkey = top5.lea_gkey(+)
    * AND le.gkey = top100.lea_gkey(+)
    * {sql: assigneeClause}
    * UNION
    * SELECT DISTINCT la.lea_gkey,la.eme_gkey
    * FROM (SELECT gkey, name, role FROM employees WHERE {sql:fn in(gkey,{emeGkeyArray})}) e,
    * lead_assignees la,
    * shared_accounts sa,
    * leads le,
    * cities ct,
    * (select lea_gkey,name,email,phone,title from contacts where principal = 'X') cn,
    * (SELECT lea_gkey, tag FROM lead_tags WHERE tag = 'TARGET') targets,
    * (SELECT lea_gkey, tag FROM lead_tags WHERE tag = 'TOP5') top5,
    * (SELECT lea_gkey, tag FROM lead_tags WHERE tag = 'TOP100') top100
    * WHERE e.gkey = la.eme_gkey
    * AND sa.lea_gkey = le.gkey
    * AND sa.lea_gkey = la.lea_gkey
    * AND le.city = ct.gkey(+)
    * AND le.gkey = cn.lea_gkey(+)
    * AND le.gkey = targets.lea_gkey(+)
    * AND le.gkey = top5.lea_gkey(+)
    * AND le.gkey = top100.lea_gkey(+)
    * {sql: sharedClause})::
    @JdbcControl.SQL(arrayMaxLength = 0,
    maxRows = JdbcControl.MAXROWS_ALL,
    statement = "select COUNT(*) FROM ( SELECT la.lea_gkey,la.eme_gkey FROM (SELECT gkey, name, role FROM employees WHERE {sql:fn in(gkey,{emeGkeyArray})}) e, lead_assignees la, leads le, cities ct, (select lea_gkey,name,email,phone,title from contacts where principal = 'X') cn, (SELECT lea_gkey, tag FROM lead_tags WHERE tag = 'TARGET') targets, (SELECT lea_gkey, tag FROM lead_tags WHERE tag = 'TOP5') top5, (SELECT lea_gkey, tag FROM lead_tags WHERE tag = 'TOP100') top100 WHERE e.gkey = la.eme_gkey AND la.lea_gkey = le.gkey AND le.city = ct.gkey(+) AND le.gkey = cn.lea_gkey(+) AND le.gkey = targets.lea_gkey(+) AND le.gkey = top5.lea_gkey(+) AND le.gkey = top100.lea_gkey(+) {sql: whereClause} UNION SELECT DISTINCT la.lea_gkey,la.eme_gkey FROM (SELECT gkey, name, role FROM employees WHERE {sql:fn in(gkey,{emeGkeyArray})}) e, lead_assignees la, shared_accounts sa, leads le, cities ct, employees asign, (select lea_gkey,name,email,phone,title from contacts where principal = 'X') cn, (SELECT lea_gkey, tag FROM lead_tags WHERE tag = 'TARGET') targets, (SELECT lea_gkey, tag FROM lead_tags WHERE tag = 'TOP5') top5, (SELECT lea_gkey, tag FROM lead_tags WHERE tag = 'TOP100') top100 WHERE e.gkey = sa.eme_gkey AND asign.gkey = la.eme_gkey AND asign.active='X' AND sa.lea_gkey = le.gkey AND sa.lea_gkey = la.lea_gkey AND le.city = ct.gkey(+) AND le.gkey = cn.lea_gkey(+) AND le.gkey = targets.lea_gkey(+) AND le.gkey = top5.lea_gkey(+) AND le.gkey = top100.lea_gkey(+) {sql: assigneeClause} UNION SELECT DISTINCT la.lea_gkey,la.eme_gkey FROM (SELECT gkey, name, role FROM employees WHERE {sql:fn in(gkey,{emeGkeyArray})}) e, lead_assignees la, shared_accounts sa, leads le, cities ct, (select lea_gkey,name,email,phone,title from contacts where principal = 'X') cn, (SELECT lea_gkey, tag FROM lead_tags WHERE tag = 'TARGET') targets, (SELECT lea_gkey, tag FROM lead_tags WHERE tag = 'TOP5') top5, (SELECT lea_gkey, tag FROM lead_tags WHERE tag = 'TOP100') top100 WHERE e.gkey = la.eme_gkey AND sa.lea_gkey = le.gkey AND sa.lea_gkey = la.lea_gkey AND le.city = ct.gkey(+) AND le.gkey = cn.lea_gkey(+) AND le.gkey = targets.lea_gkey(+) AND le.gkey = top5.lea_gkey(+) AND le.gkey = top100.lea_gkey(+) {sql: sharedClause})")
    public Long getProspectsCount(String[] emeGkeyArray, String whereClause, String assigneeClause, String sharedClause) throws SQLException;
    The execution of the method is the following:
    pendingApprovals = leadsListingDB.getProspectsCount(employeeHierarchyArray, pendingApprovalsClause, pendingApprovalsClause, pendingApprovalsClause);
    When the method is executed all the String parameters (whereClause, assigneeClause & sharedClause) are replaced well except the array parameter (emeGkeyArray) so the execution throws the following exception because the array is not replaced:
    <Jan 20, 2010 1:01:26 PM CST> <Debug> <org.apache.beehive.controls.system.jdbc.JdbcControlImpl> <BEA-000000> <Enter: onAquire()>
    <Jan 20, 2010 1:01:26 PM CST> <Debug> <org.apache.beehive.controls.system.jdbc.JdbcControlImpl> <BEA-000000> <Enter: invoke()>
    <Jan 20, 2010 1:01:26 PM CST> <Info> <org.apache.beehive.controls.system.jdbc.JdbcControlImpl> <BEA-000000> <PreparedStatement: select COUNT(*) FROM ( SELECT la.lea_gkey,la.eme_gkey FROM (SELECT gkey, n
    me, role FROM employees WHERE (gkey IN ())) e, lead_assignees la, leads le, cities ct, (select lea_gkey,name,email,phone,title from contacts where principal = 'X') cn, (SELECT lea_gkey, tag FROM lead
    tags WHERE tag = 'TARGET') targets, (SELECT lea_gkey, tag FROM lead_tags WHERE tag = 'TOP5') top5, (SELECT lea_gkey, tag FROM lead_tags WHERE tag = 'TOP100') top100 WHERE e.gkey = la.eme_gkey AND la.l
    a_gkey = le.gkey AND le.city = ct.gkey(+) AND le.gkey = cn.lea_gkey(+) AND le.gkey = targets.lea_gkey(+) AND le.gkey = top5.lea_gkey(+) AND le.gkey = top100.lea_gkey(+) AND LA.ACTIVE = 'X' AND LE.WE
    KLY_POTENTIAL > 0 AND (LE.APPROVED IS NULL OR LE.APPROVED != 'Y') AND LA.SALE_STAGE IN(3034,3005) UNION SELECT DISTINCT la.lea_gkey,la.eme_gkey FROM (SELECT gkey, name, role FROM employees WHERE (gkey I
    ())) e, lead_assignees la, shared_accounts sa, leads le, cities ct, employees asign, (select lea_gkey,name,email,phone,title from contacts where principal = 'X') cn, (SELECT lea_gkey, tag FROM lea
    tags WHERE tag = 'TARGET') targets,  (SELECT leagkey, tag FROM lead_tags WHERE tag = 'TOP5') top5, (SELECT lea_gkey, tag FROM lead_tags WHERE tag = 'TOP100') top100 WHERE e.gkey = sa.eme_gkey AND asi
    n.gkey = la.eme_gkey AND asign.active='X' AND sa.lea_gkey = le.gkey AND sa.lea_gkey = la.lea_gkey AND le.city = ct.gkey(+) AND le.gkey = cn.lea_gkey(+) AND le.gkey = targets.lea_gkey(+) AND le.gkey
    = top5.lea_gkey(+) AND le.gkey = top100.lea_gkey(+) AND LA.ACTIVE = 'X' AND LE.WEEKLY_POTENTIAL > 0 AND (LE.APPROVED IS NULL OR LE.APPROVED != 'Y') AND LA.SALE_STAGE IN(3034,3005) UNION SELECT DISTINCT
    la.lea_gkey,la.eme_gkey FROM (SELECT gkey, name, role FROM employees WHERE (gkey IN ())) e, lead_assignees la, shared_accounts sa, leads le, cities ct, (select lea_gkey,name,email,phone,title from c
    ntacts where principal = 'X') cn, (SELECT lea_gkey, tag FROM lead_tags WHERE tag = 'TARGET') targets, (SELECT lea_gkey, tag FROM lead_tags WHERE tag = 'TOP5') top5, (SELECT lea_gkey, tag FROM lead_tags
    WHERE tag = 'TOP100') top100 WHERE e.gkey = la.eme_gkey AND sa.lea_gkey = le.gkey AND sa.lea_gkey = la.lea_gkey AND le.city = ct.gkey(+) AND le.gkey = cn.lea_gkey(+) AND le.gkey = targets.lea_gkey(+
    AND le.gkey = top5.lea_gkey(+) AND le.gkey = top100.lea_gkey(+) AND LA.ACTIVE = 'X' AND LE.WEEKLY_POTENTIAL > 0 AND (LE.APPROVED IS NULL OR LE.APPROVED != 'Y') AND LA.SALE_STAGE IN(3034,3005)) Params:
    {}>
    <Jan 20, 2010 1:01:26 PM CST> <Debug> <org.apache.beehive.netui.pageflow.FlowController> <BEA-000000> <Invoking exception handler method handleException(java.lang.Exception, ...)>
    [LeadsMailer] Unhandled exception caught in Global.app:
    java.sql.SQLSyntaxErrorException: ORA-00936: missing expression
    So the big question is if that behavior is due to a bug of I'm doing something wrong. Do someone can give me an advice about this problem because the array parameter has no problems in workshop 8.1?
    Thanks in advance!

    Greetings
    I may not have an answer for you, but i am in the same boat! I am trying to pass an array to store in the database. I have 2 out of 8 columns that need to be stored as arrays. Everything saves EXEPT for the 2 arrays in question. I am using BEEHIVE with my web app. The strange thing is that i do not receive any syntax errors or runtime codes. I am still searching for an answer. If i find anything out, i will let you know.
    John Miller
    [email protected]

  • Passing an array of objects to a named query

    I'm trying to use a named query that will have a
    in() expression operator (clause) to retrieve a set of objects.
    The in() operator requires an array of objects to pass in.
    Specifically I want to pass an array of BigDecimal of unknown size.
    The query looks like that:
    ExpressionBuilder seq = new ExpressionBuilder();
    Expression exp = seq.get("id").in(keys);
    ReadAllQuery query = new ReadAllQuery();
    query.setReferenceClass(RegistrationNumberSequencer.class);
    query.addArgument("keys");
    query.setSelectionCriteria(exp);
    And the "keys" would be:
    Object[] keys = new Object[2];
    keys[0]= new BigDecimal(1);
    keys[1]= new BigDecimal(2);
    I have got a conversion exception(Could not convert to BigDecimal class) when executing the query.
    Can I pass this array as a parameter somehow ?
    Thanks a lot
    Ovidiu

    Hi Ovidiu,
    My apologies for the missed code. You need to pass the vector of elements into another vector, so TopLink will interpret the single element of the second vector as the correct query argument, and expend the elements in the first vector into the IN clause.
    The named query defined I sent in previous mail is still correct, but you need to pass in the argument like:
    Vector keys = new Vector();
    keys.addElement(new BigDecimal(1));
    keys.addElement(new BigDecimal(2));
    Vector arg = new Vector(1);
    arg.addElement(keys);
    Now you can pass the arg in when executing the query, and should get the correct result.
    To stand my claim, I did a mini test using our TopLink Employee demo and here is the generated SQL:
    Call:SELECT t0.VERSION, t1.EMP_ID, t0.L_NAME, t0.F_NAME, t1.SALARY, t0.EMP_ID, t0.GENDER, t0.END_DATE, t0.START_DATE, t0.MANAGER_ID, t0.START_TIME, t0.END_TIME, t0.ADDR_ID FROM EMPLOYEE t0, SALARY t1 WHERE ((t0.EMP_ID IN (1, 2)) AND (t1.EMP_ID = t0.EMP_ID))
    You can see the IN clause in generated as expected!
    As Doug said, we do not officially support array as query argument yet. I would use the proper way to build the query.
    King

  • Passing array of timestamps into oracle stored proc

    Hey there,
    I have an interesting problem. I need to pass an array of java.sql.Timestamp into a stored proc.
    I see that the PreparedStatement provides a setArray() method which takes as arguments an int, java.sql.Array
    Anybody know how I can use the java.sql.Array to my advantage here ? Basically, I don't see how I can create a java.sql.Array of Timestamps
    thanks in advance for all your help.
    Manish Mandelia

    The java.sql.Array implementation is provided by your jdbc driver.
    For exemple using Oracle you can obtain an sql.Array with something like this :
    Connection con=getConnection() // get a connection to the DB
    //first declare what type of array you will use in the DB
    // you probably want to replace CHAR(7) by Timestamp here
    PreparedStatement createArray=
    con.prepareStatement("CREATE OR REPLACE TYPE MYARRAY AS VARRAY(100) OF CHAR(7)");
    createArray.execute();          
    //then get an java instance of this Array
    oracle.sql.ArrayDescriptor arrayDescriptor = oracle.sql.ArrayDescriptor.createDescriptor("MYARRAY",con);
    // content is used to fill the Array
    String[] content= {"string0", "string1"};
    java.sql.Array sqlArray=new oracle.sql.ARRAY(arrayDescriptor, con, content);               
    // then call your stored procedure
    java.sql.CallableStatement callStmt=con.prepareCall("call MyStoredProcedure(?)");
    // passing the array as an argument
    callStmt.setArray(1,sqlArray);
    callStmt.execute();
    As you can see the code is quite database specific.
    hope that helps.

Maybe you are looking for

  • Why is my page running both these conditional processes?

    Could someone explain this to me please? I have 2 submit buttons on my page - let's call them Button1 and Button2. I have 2 After Submit page processes, let's call them Process1 and Process2. Process1 is is set to conditionally run if Button1 is clic

  • Allow user to import excel file without using wizard ?

    Hi ! How can i realize an application where the user can import an excel sheet. The user should just choose the file to import and all the other things should happen automatically. The files are allways equal, allways same colums, allways same delimi

  • Remove marker from chart legend.

    How do I remove a marker with no display name from a legend?

  • Launch iFS Domain

    Hello, I have some problems in starting the iFS-Domain. I have installed the iFS as written in the Installation Guide. Now I want to start the iFS-Domain. I started the the Oracle Enterprise Manager, clicked on the node "Internet File System" and sel

  • Structural Org Management

    Dear All, I'm asked to study on Structural Org Management, because soon I'll have to work on the same. As I have no clue what it is all about, can somebody help me with relevant document. Thanks in advance Regards, Taran