Trying to pass Oracle array/object type to Java

I have a Java class with two inner classes that are loaded into Oracle:
public class PDFJ
    public static class TextObject
        public String font_name;
        public int font_size;
        public String font_style;
        public String text_string;
    public static class ColumnObject
        public int left_pos;
        public int right_pos;
        public int top_pos;
        public int bottom_pos;
        public int leading;
        public TextObject[] column_texts;
}I have object types in Oracle as such that bind to the Java classes:
CREATE OR REPLACE TYPE "PROGRAMMER"."PDFJ_TEXT" AS OBJECT
EXTERNAL NAME 'PDFJ$TextObject'
LANGUAGE JAVA
USING SQLData(
  "FONT_NAME" VARCHAR2(25) EXTERNAL NAME 'font_name',
  "FONT_SIZE" NUMBER EXTERNAL NAME 'font_size',
  "FONT_STYLE" VARCHAR2(1) EXTERNAL NAME 'font_style',
  "TEXT_STRING" VARCHAR2(4000) EXTERNAL NAME 'text_string'
CREATE OR REPLACE TYPE "PROGRAMMER"."PDFJ_TEXT_ARRAY" AS
  TABLE OF "PROGRAMMER"."PDFJ_TEXT";
CREATE OR REPLACE TYPE "PROGRAMMER"."PDFJ_COLUMN" AS OBJECT
EXTERNAL NAME 'PDFJ$ColumnObject'
LANGUAGE JAVA
USING SQLData(
  "LEFT_POS" NUMBER EXTERNAL NAME 'left_pos',
  "RIGHT_POS" NUMBER EXTERNAL NAME 'right_pos',
  "TOP_POS" NUMBER EXTERNAL NAME 'top_pos',
  "BOTTOM_POS" NUMBER EXTERNAL NAME 'bottom_pos',
  "LEADING" NUMBER EXTERNAL NAME 'leading',
  "COLUMN_TEXTS" "PROGRAMMER"."PDFJ_TEXT_ARRAY" EXTERNAL NAME 'column_texts'
CREATE OR REPLACE TYPE "PROGRAMMER"."PDFJ_COLUMN_ARRAY" AS
    TABLE OF "PROGRAMMER"."PDFJ_COLUMN";
/I successfully (as far as I know) build a PDFJ_COLUMN_ARRAY object in a PL/SQL procedure. The PDFJ_COLUMN_ARRAY contains PDFJ_COLUMN objects; each of those objects contains a PDFJ_TEXT_ARRAY of PDFJ_TEXT objects (Example: pdf_column_array(i).pdf_text_array(i).text_string := 'something';). In this procedure, I pass this PDFJ_COLUMN_ARRAY as a parameter to a Java function. I assume the Java function parameter is supposed to be a oracle.sql.ARRAY object.
I cannot figure out how to decompose this generic ARRAY object into a ColumnObject[] array. I also tried Googling and searching the forums, but I can't figure out matching search criteria. I was wondering if anyone here knows anything about passing user-defined Oracle type objects to a Java function and retrieving the user-defined Java class equivalents that they are supposedly mapped to--especially a user-defined array type of user-defined object types containing another user-defined array type of user-defined object types.

Ok. I will try asking on the JDBC forum. So, don't
flame me for cross-posting. :PWe won't, if over there you just post basically a
link to this one.
sigh Guess what, he did it the flame-deserving way. It's crossposted at:
http://forum.java.sun.com/thread.jspa?threadID=602805
<flame level="mild">Never ceases to amaze me how people don't think that posting a duplicate rather than a simple link isn't wasteful, as people could end up answering in both of them, not seeing each other's answers</flame>

Similar Messages

  • Issue in passing Oracle User Defined Types to PL SQL from Websphere Applica

    HI,
    I am facing an issue when trying to pass Oracle collection object(User Defined Types) from Java to PL SQL. The issue happens inside J2EE application which is running inside Websphere Application Server 6.x. My database is Oracle 10g and i am using ojdbc1.4.jar as thin driver.
    The issue is that when i pass the Oracle Object from java side, the attribute values of the collection objects at the Oracle PL SQL side is coming as empty. I have tried the same java code in a standalone application and it works fine. The issue happens only when the application is running inside WAS.
    Anybody has any idea how to pass Oracle User Defined Types from WAS 6.x server to Oracle PL SQL?

    Andy Bowes wrote:
    Hi
    I am using WebLogic 8.14 & Oracle 9i with thin JDBC driver.
    Our application needs to perform the same DB operation for every item in a Java Collection. I cannot acheive the required performance using the standard Prepare & Execute loop and so I am looking to push the whole collection to Oracle in a single invocation of a Stored Procedure and then loop on the database.
    Summary of Approach:
    In the Oracle database, we have defined a Object Type :
    CREATE OR REPLACE
    TYPE MYTYPE AS OBJECT
    TxnId VARCHAR2(40),
    Target VARCHAR2(20),
    Source VARCHAR2(20),
    Param1 VARCHAR2(2048),
    Param2 VARCHAR2(2048),
    Param3 VARCHAR2(2048),
    Param4 VARCHAR2(2048),
    Param5 VARCHAR2(2048),
    and we have defined a collection of these as:
    CREATE OR REPLACE
    TYPE MYTYPE_COLLECTION AS VARRAY (100) OF MYTYPE
    There is a stored procedure which takes one of these collections as an input parameter and I need to invoke these from within my code.
    I am having major problems when I attempt to get the ArrayDescriptor etc to allow me to create an Array to pass to the stored procedure. I think this is because the underlying Oracle connection is wrapped by WebLogic.
    Has anyone managed to pass an array to an Oracle Stored procedure on a pooled DB connection?
    Thanks
    AndyHi. Here's what I suggest: First please get the JDBC you want to work in a
    small standalone program that uses the Oracle thin driver directly. Once
    that works, show me the JDBC code, and I will see what translation if
    any is needed to make it work with WLS. Will your code be running in
    WebLogic, or in an external client talking to WebLogic?
    Also, have you tried the executeBatch() methods to see if you can
    get the performance you want via batches?
    Joe

  • Passing array of Types to java class

    I am trying to pass a user defined type (that is an array) from PL/Sql to a javaclass. Here are the definitions that make-up the parameter to pass from PL/Sql to Java (uri_digest_array):
    CREATE OR REPLACE TYPE uri_digest as object (uri VARCHAR2(256),
    digest_value CLOB);
    CREATE OR REPLACE TYPE uri_digest_array AS VARRAY(10) OF uri_digest;
    In Oracle-land, java classes are published to PL/Sql by way of the following definition. Note that the intent here is to have compatible data-types.
    CREATE OR REPLACE FUNCTION SIGNRETURNINGXML (p_array IN uri_digest_array)
    RETURN LONG
    AS LANGUAGE JAVA
    NAME 'SignReturningXml.main(oracle.sql.Array) return java.lang.String';
    Here is a fragment of the java class code:
    class SignReturningXml {
    public static String main(String [] [] signItems ) // I have no idea what datatype to use here!
    { . . . . The code in here would process the passed array normally from first entry to last.
    Currently I get the following error:
    PLS-00311: the declaration of
    "SignReturningXml.main(oracle.sql.Array) return
    java.lang.String" is incomplete or malformed
    I could use some suggestions on resolving the datatype conflicts. Any ideas? Has anyone tried this kind of thing?
    Thanks,
    Michael

    Michael,
    At the risk of another [non] useful response, I meant that you should try searching the "Ask Tom" Web site, because usually you will find an answer to your question that has already been asked by someone else. Perhaps these will be helpful:
    [url=http://asktom.oracle.com/pls/ask/f?p=4950:8:1320383202207153292::NO::F4950_P8_DISPLAYID,F4950_P8_CRITERIA:8908169959941
    ]Can I Pass a nested table to Java from a pl/sql procedure
    [url=http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:712625135727
    ]passing arrays into pl/sql stored procedures
    Good Luck,
    Avi.

  • Oracle Spatial Object types in Designer 6

    Hi all,
    I'm trying to design a database that uses the new Oracle Spatial Object types (MDSYS.SDO_GEOMETRY) etc. I have been able to capture the object types from Oracle8i but when i try to save the design in the repository it fails. I am assuming that the version of Oracle Designer I am using does not support MDSYS.SDO_GEOMETRY. Is this correct and if so what version of Designer should I be using?
    Martin

    Hi Saso,
    I'm sorry I don't have any help for you but maybe yo can answer a question for me relating to sdo_geometry. I'm trying to capture a database schema which contains tables with sdo_geometry columns & this fails because I don't have that object defined.
    So how do I access the Oracle Object Types branch to define MDSYS.SDO_GEOMETRY? Is it in the object navigator or designer?
    Thanks,
    Jim Greetham

  • Passing Values to Object Type Attributes

    Hi Experts,
    I need to pass values to object type attributes amount,channel and company code from zprogram.
    I have got FM 'SWO_INVOKE'.But in this FM how will I pass values to 3 attributes.
    I have created object type through SWO1 .Is it necessary to call FM SWO_CREATE before FM 'SWO_INVOKE'.
    Please suggest.
    Regards,
    Kaustubh.

    Hi,
    I guess you will have to Initialize business object first by using the function module "SWO_CREATE' and then call the other function module to pass the attributes. I am not sure, but please check by passing the attribute name and value to the tables parameter 'CONTAINER'.
    CONTAINER-ELEMENT = <Attribute name>.
    CONTAINER-VALUE = <value from the Zprogram>.
    Hope this will help.
    Thanks,
    Samson

  • Can't access packaged object type in Java

    Hi
    I am getting the following error while accessing an oracle packaged object type. Can You please give me an advise..!!
    java.sql.SQLException: invalid name pattern: XXGW_RMA_CREATION_PKG.XXGW_RMA_RECRegards

    HI
    I am not asking how to search in google. If You know how to resolve my problem..then help me. I don't what this kind of answers.
    This is my problem
    Error in java.
    java.sql.SQLException: invalid name pattern: XXGW_RMA_CREATION_PKG.XXGW_RMA_REC
    This is my package
    create or replace package xxgw_rma_creation_pkg
    is
    type xxgw_rma_rec is record (dealer_name varchar2(40), dealer_desc varchar2(300));
    type xxgw_rma_line is table of xxgw_rma_rec; --(item_name varchar2(40), item_desc varchar2(300)) index by binary_integer;
    xx_rma_rec  xxgw_rma_rec;
    xx_rma_line xxgw_rma_line
    procedure xxgw_rma_creation (p_rma_rec in xxgw_rma_rec ,p_rma_line in xxgw_rma_line,p_rma_no out varchar2);
    end;
    create or replace package body xxgw_rma_creation_pkg
    is
    procedure xxgw_rma_creation (p_rma_rec in xxgw_rma_rec ,p_rma_line in xxgw_rma_line,p_rma_no out varchar2)
    is
    l_rma_rec xxgw_rma_rec := p_rma_rec;
    l_rma_line xxgw_rma_line := p_rma_line;
    begin
    dbms_output.put_line(l_rma_rec.dealer_name||'  '||l_rma_rec.dealer_desc);
    for i in  l_rma_line.first..l_rma_line.last loop
    dbms_output.put_line(l_rma_line(i).dealer_name||'  '||l_rma_line(i).dealer_desc);
    end loop;
    p_rma_no := '20';
    end;
    end;Rekha

  • Executing a Stored Procedure passing Oracle Defined User Type

    Hello All,
    I am having problems in executing a SP from Java. Here is the detailed info of the prob I am facing.
    I have a SP created which takes in a Table Type as one of the input parameter. This table type say "SERVICE" is of the Object Type "OBJ_SERVICETOMOVE".
    Now I am writing a simple Java Clinet which executes the procedure. and below is the sample code I am pasting.
    public class DBClient {
         public static void main(String args[])
              DBConnection dbclass = new DBConnection();
              dbclass.getConnection();
              //String movingOrder = args[0];
              ArrayList arrList = new ArrayList();
              arrList.add("10001");
              arrList.add("10002");
              arrList.add("10003");
              java.sql.Date date = null;
              try
                   SimpleDateFormat objSDF = new SimpleDateFormat("dd/MM/yyyy");
                   java.util.Date dtCcDate = (java.util.Date) objSDF.parse("02/01/2005");
                   java.sql.Date localdate = new java.sql.Date(dtCcDate.getTime());
                   date = localdate;
              catch(ParseException e)
                   System.out.println("Parse Exception CAUGHT"+e.getMessage());
              combttmOE04ServicesToMove inputParam = new combttmOE04ServicesToMove(arrList);
              try
                   OracleCallableStatement cs = dbclass.getCallableStatement("saveMovingOrder4Service(?,?,?)");
                   cs.setInt(1,10);
                   cs.setInt(2,date);
                   cs.setObject(3,inputParam);
                   dbclass.executeStoreProc();
              catch(SQLException e)
                   e.printStackTrace();
              catch(Exception e)
                   System.out.println("Exception CAUGHT"+e.getMessage());
    The error I am getting is
    java.sql.SQLException: Invalid column type
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java)
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java)
    at oracle.jdbc.driver.OraclePreparedStatement.setObject(OraclePreparedStatement.java)
    at oracle.jdbc.driver.OraclePreparedStatement.setObject(OraclePreparedStatement.java)
    at DBClient.main(DBClient.java:84)
    Can anyone of you advise me on this
    Regards
    Rags

    Rags,
    Have you looked at the JDBC sample code available from here:
    http://www.oracle.com/technology/sample_code/tech/java/sqlj_jdbc/index.html
    And the "how-to" documents, available from here:
    http://www.oracle.com/technology/sample_code/tech/java/codesnippet/jdbc/index.html
    I once did something similar to what (I think) you are trying to do -- but unfortunately I lost that code when the hard-disk on my PC died. I do remember though, finding how to do it from the above-listed URLs.
    Good Luck,
    Avi.

  • Oracle 9i Object Type ..using self

    I have created and object with
    several attributes of standard oracle datatypes. I have one that is of a custom object type. this object provides encapsulated functionality. I instansiate the internal custom object using a constructor function. the constructor includes the creation of a primary key. once the constructor is done, the object is initialized( an internal flag is set, which should only be done once)
    To use this custom object in a member method, I have to do something like this..
    ( i have summarized code for brevity)
    MEMBER FUNCTION foo( ) return obj
    is
    l_self PARENT_OBJ_TYPE:= SELF;
    local INTERNAL_OBJ :=SELF.internal_obj;
    begin
    local.method1() -- insert record( flag is true)
    local.method1() --insert another record( but this time the flag that was set upon construction is now set to FALSE..
    I get an error.)
    end;
    I do not do anything tricky. the behavior seems to be that object types do not keep state appropriately.
    any ideas of why this could be happening?

    there was no real error code just unexpected behavior. it did not crash. I figured it out. it had to do with passing self as a parameter in out so that it keeps state

  • How to return Values from Oracle Object Type to Java Class Object

    Hello,
    i have created an Oracle Object Types in the Database. Then i created Java classes with "jpub" of these types. Here is an example of the type.
    CREATE OR REPLACE TYPE person_type AS OBJECT
    ID NUMBER,
    vorname VARCHAR2(30),
    nachname VARCHAR2(30),
    geburtstag DATE,
    CONSTRUCTOR FUNCTION person_type RETURN SELF AS RESULT,
    CONSTRUCTOR FUNCTION person_type(p_id NUMBER) RETURN SELF AS RESULT,
    CONSTRUCTOR FUNCTION person_type(p_vorname VARCHAR2,
    p_nachname VARCHAR2,
    p_geburtstag DATE) RETURN SELF AS RESULT,
    MEMBER FUNCTION object_exists(p_id NUMBER) RETURN BOOLEAN,
    MEMBER PROCEDURE load_object(p_id NUMBER),
    MEMBER PROCEDURE save_object,
    MEMBER PROCEDURE insert_object,
    MEMBER PROCEDURE update_object,
    MEMBER PROCEDURE delete_object
    MEMBER PROCEDURE load_object(p_id NUMBER) IS
    BEGIN
    SELECT p.id, p.vorname, p.nachname, p.geburtstag
    INTO SELF.ID, SELF.vorname, self.nachname, SELF.geburtstag
    FROM person p
    WHERE p.id = p_id;
    END;
    My problem is, that if i use the member function "load_object" from my java app it doesnt return the selected values to the java class and i dont know why. I use the java class like this:
    PersonObjectType p = new PersonObjectType();
    p.load_object(4);
    There is a reocrd in the database with id = 4 and the function will execute successful. But if i try to use "p.getVorname()" i always get "NULL". Can someone tell me how to do that?
    Thanks a lot.
    Edited by: NTbc on 13.07.2010 15:36
    Edited by: NTbc on 13.07.2010 15:36

    CallableStatement =
    "DECLARE
    a person_type;
    BEGIN
    a.load_object(4);
    ? := a;
    END;"
    And register as an out parameter.
    Edited by: michael76 on 14.07.2010 05:01

  • Oracle table object type - Error

    Hi,
    I have created an oracle object as like
    [CREATE OR REPLACE TYPE t_test_obj IS OBJECT (
       testid      INTEGER,
       testdesc    VARCHAR2(64)
    Then created the type table from above
    [ create or replace type t_table as table of t_test_obj;]
    i want to create the table containing the above type like below
    create table t_tab_test (test1 t_table); but i received the error as like
    ERROR at line 1:
    ORA-22913: must specify table name for nested table column or attribute
    Requirement: As one my function returns this table type object and i want to insert those values in a table hence i want this. Any other pointers are also helpful.
    Please help.
    Regards,
    Kapil

    Thanks for reply.
    As i described in Requirement, my function return the table type, hence if i try to insert i get error as below. t_table is the return type from function. I need conversion from table type to object type.
    SQL> insert into testing values(1,t_table(1,'a'));
    insert into testing values(1,t_table(1,'a'))
    ERROR at line 1:
    ORA-00932: inconsistent datatypes: expected IRP_DBO.T_TEST_OBJ got IRP_DBO.T_TABLE

  • '.class' expected Error when trying to pass an Array

    In the below method I am trying to return an array. The compiler gives me one error: '.class' expected. I am not sure if I am writing the 'return' statement correctly and not really sure of another way to code it. Below is a portion of the code and I can post all of it if need be but the other methods seem to be fine.
    import java.util.Scanner;
    public class LibraryUserAccount
    Scanner input=new Scanner(System.in);
    private final int MAX_BOOKS_ALLOWED;
    private int checkedOutBookCounter;
    private long accountNumber;
    private String socialSecurityNumber, name, address;
    private final long isbnNumbers[];
    //constructor
    public LibraryUserAccount(long accountNumber, int maxBooksAllowed)
         this.accountNumber = 0;
         MAX_BOOKS_ALLOWED = maxBooksAllowed;
    //returns the array isbnNumbers[]
    public long getCheckedOutBooksISBNNumbers()
         return isbnNumbers[];
    The error displayed as:
    LibraryUserAccount.java:111: '.class' expected
         return isbnNumbers[];
    ^
    1 error
    Thanks in advance for the help.

    Rewriting the method as:
    public long[] getCheckedOutBooksISBNNumbers()
    return isbnNumbers;
    ... has fixed that particular compiler error. Thanks jverd. I appreciate the help.
    On a separate note I am having trouble with initializing the array. What I am trying to do is initialize an array of a size equal to a value passed to the class. Example being:
    //variables
    private final int MAX_BOOKS_ALLOWED;
    private long accountNumber;
    private final long[] isbnNumbers;
    //constructor method
    public LibraryUserAccount(long accountNumber, int maxBooksAllowed)
    this.accountNumber = 0;
    MAX_BOOKS_ALLOWED = maxBooksAllowed;
    long[] isbnNumbers = new long[MAX_BOOKS_ALLOWED];
    My goal is to set the size of isbnNumbers[] to the value of MAX_BOOKS_ALLOWED. I've tried a couple of different ways to initialize the array (the latest listed above) but the compiler doesn't like what I have done. Thanks again.

  • 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 parameter of object type between Oracle & VB

    Hello,
    I want to pass parameters of ref cursor type variable between oracle 8i routines and Vb routines. It will be very helpfull for me if you can help in telling me about how to do it.
    Regards
    Rakesh Banerjee

    1. On the Oracle side, you may need to do the following:-
    (a) define a ref cursor of the desired type in a package specification
    (b) define a procedure that returns the ref cursor type as an out parameter, or alternately a function that returns the ref cursor type as a return value.
    (c) associate a select statement in the definition of the procedure or function using the synrtax OPEN ref_cursor_name FOR "select XYZ from abc"
    (d) compile and debug the package
    2. On the VB side one can:-
    (a) call the stored procedure or function using the ODBC call syntax for calling stored procedures
    (b) bind the output parameter or return value to a resultset variable in VB.
    3. The critical step would be using an ODBC driver that supports this syntax and functionality. If the driver available at your site does not work you may need to buy a third party driver that does.
    Hope that helps ...
    Regards,
    Narayan.

  • Trying to Clone an array object that contains other objects

    I have an employee object with the fields name (String), Salary (Double), and hireDay (Date). Since the date field contains many int fields (year, month etc..), using a straight clone will not work.
    What I want to do is copy an array of employees into a new array.
    For example:
    Employee [] newEmps = (Employee[])OldEmps.clone()
    In the employee class, I implement the Cloneable interface and my code so far will copy one Employee. How do I change this to copy an array of empoyees? Specifically, since hireDay contains many fields, a straight super.clone of the array won't work. Here is my clone code:
         public Object clone()
         try {
              // call Object.clone()
         Employee cloned = (Employee)super.clone();
              // clone mutable fields
    cloned.hireDay = (Date)hireDay.clone();
         return cloned;
         catch (CloneNotSupportedException e)
         { return null; }
    Any help is appreciated. Thanks!
    -Eric

    There's so much I don't understand about that, it just
    isn't worth asking. Let me spell out my previous post
    since it seems to have gone right over your
    head.Employee[] emps;
    // here you fill in the array of Employees
    Employee[] clonedEmps = new Employee[emps.length];
    for (int z=0; z<emps.length; z++) {I understand this next line of code. My question lies within the clone() function
    clonedEmps[z] = emps[z].clone();OK - Let me try to clear things up. If we take from your example the original array "emps". Now for me, emps, is already filled up in main().
    So in main() when I call emps.clone(), my clone function starts running:
    // the employee class (which I created) implements the Cloneable
    // interface
    // This clone function is inside my employee class
    public Object [] clone()
    try {
    Employee [] cloned = (Employee)super.clone();
    // IS THIS NEXT LINE OF CODE REQUIRED TO MAKE A DEEP COPY? IF SO, How would I implement perhaps a for loop that would copy the hireDay from each element in the original array to the elements in the the new array?
    // Obviously, each employee (element in the array) has a hireDay
    // Please modify this next line of code to show me how.
    cloned.hireDay = (Date)hireDay.clone();
    return cloned;
    catch (CloneNotSupportedException e)
    { return null; }
    If I wanted to access say the "hireDay" field of the 3rd element in the original employee array INSIDE THE CLONE FUNCTION - then how would i access it?
    Thanks
    -Eric

  • How to call procedure with Object types in java

    Hi,
    We have procedure declaration as follows
    ===============
    TYPE TEST_TYPE AS OBJECT (NAME VARCHAR2(10));
    TYPE TESTTYPE1 AS object (student1 TESTTYPE,student2 TESTTYPE,student3 TESTTYPE);
    TYPE rect AS OBJECT
    -- The type has 3 attributes.
    length NUMBER,
    width NUMBER,
    area NUMBER,
    -- Define a constructor that has only 2 parameters.
    CONSTRUCTOR FUNCTION rect(length NUMBER, width NUMBER)
    RETURN SELF AS RESULT
    PROCEDURE G(obj1 in TESTTYPE1,obj2 out rect) as
    n1 testtype;
    n2 testtype;
    n3 testtype;
    n4 testtype;
    begin
    obj2 := NEW rect(10,20,200);
    n1 := obj1.student1;
    n2 := obj1.student2;
    n3 := obj1.student3;
    obj2.length :=20;
    end;
    =====================================================
    I am not able to call the procedure in java code as I cannot figure out which out parameter type will it be registered using registeroutparameter. using cursor or struct type fails.
    please let me know how I can pass values from stored procedure with objects to java.

    I'm not sure what you're trying to accomplish with your procedure, but in general, this is an example of how you could use oracle.sql.STRUCT.
    First, prepare your java.sql.CallableStatement using java.sql.CallableStatement cStmt = java.sql.Connection.prepareCall({ call G(?, ?) });
    Note that you don't have to use the OracleCallableStatement. The java.sql.CallableStatement will work just fine.
    For the IN parameter, you need to create three TEST_TYPE objects. Then you need to create one TESTTYPE1 object.
    These will all be instances of oracle.sql.STRUCT.
    To create a oracle.sql.STRUCT object you need a descriptor and a set of attributes. For example, to create a TEST_TYPE object you would do the following
    1. StructDescriptor sd = StructDescriptor.createDescriptor("TEST_TYPE", java.sql.Connection).
    2. Add a VARCHAR2 attribute to an array of attributes (e.g. Object[] attributes = new Object[]{"Student Name"})
    3. oracle.sql.STRUCT struct = new oracle.sql.STRUCT(sd, java.sql.Connection, attributes)
    Then do something similar to create the TESTTYPE1 object, except that the attribute array will contain three instances of TEST_TYPE struct objects.
    To bind the IN parameter you need to use the java.sql.CallableStatement.setObject(1, <Instance of TESTTYPE1 object>).
    To register the OUT parameter, you need to call java.sql.CallableStatement.registerOutParameter(2, oracle.jdbc.OracleTypes.STRUCT, "RECT").
    Then, execute your procedure using cStmt.execute();
    Retrieve your OUT parameter using oracle.sql.STRUCT struct = (oracle.sql.STRUCT)cStmt.getObject(2).
    Once you've done that, to get the values of the attributes of all of your STRUCT objects, you need their descriptors and their metadata.

Maybe you are looking for

  • Ipod doesn't show in Windows or ITunes

    I wanted to update my Ipod today with several songs that I had purchased. I opened the Itunes folder. I plugged the Ipod in and nothing happened. I went into "My Computer" and nothing there (usually shows up in G). I went to the Help area here and de

  • Error In Create Transfer Order LT01

    Hi System cannot find source storage bin Message no. L3008 Am getting the above error  in transaction LT01. How to solve this. Pls explain the full scenarion with step details to get rid of this issue Vijay Edited by: Vijay on Nov 4, 2009 6:54 PM

  • Jpeg export, gradients look nasty

    Hey when i export the gradients is like its 16bit color. here you see it.. its just a screenshot with the export by the side of the program. see the shadow on the left on her chin. http://postimg.org/image/8ljwbq2ql/full/ in dont see any way to alter

  • Can't connect to .mac smtp

    For whatever reason I can't send mail, because the smtp won't connect. I've tried deleting and adding the account again, what is wrong with it?

  • Logo not showing up

    I'm not sure if this is an Indesign problem or Illustrator problem so I'm starting with the Illustrator forums. I have a logo created in Illustrator that I have imported into an inDesign document. Only part of the logo is showing up when I print it (