Passing arrays to Oracle Stored procedure.

Have any body passed arrays to Oracle stored procedures while the app is running in Weblogic app server. I am able to pass the arrays with regular JDBC connection. If I run the same piece of code using a connection recieved from the datasource of weblogic server, its not working. I am getting serialization errors with the ArrayDescriptor class. Looks like the ArrayDescriptor is not serializable.
Does anybody know solution/workaround to pass arrays ?
Thanks in advance

you could write a wrapper class that extends ArrayDescriptor and implements serializable...
for example your class would look something like this.
public class MyArrayDescriptor extends ArrayDescriptor
implements Serializable
in your regular code use the wrapper class in place of the ArrayDescriptor (it will contain all the same methods as the real ArrayDescriptor) and you should be able to toss your wrapper class anywhere you please.

Similar Messages

  • Passing array to oracle stored procedure in VC++ 2005

    Hi,
    I am try to send an array of integers to a stored procedure via ODBC 10.2.0.3 on VC++2005 enviornment. I get the below error
    ORA-06550: line 1, column 7:
    PLS-00306: wrong number or types of arguments in call to 'MYPROC1'
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored ... Error Code = 6550
    []E R R O R
    The same code works if I use an INSERT statement.
    SQLUSMALLINT* rowsProcessed = new SQLUSMALLINT;
    RETCODE nRetCode;
    const int arraySize = 200;
    long ptrVal[arraySize];
    long ptrInd[arraySize];
    long ptrStatus[arraySize];
    for (int i = 0; i < arraySize; i++)
    ptrVal = i;
    ptrInd = 0;
    nRetCode = SQLSetStmtAttr(m_hstmt, SQL_ATTR_PARAM_BIND_TYPE, SQL_PARAM_BIND_BY_COLUMN, 0);
    // assign the number of sets of parameters that are to be inserted
    nRetCode = SQLSetStmtAttr(m_hstmt, SQL_ATTR_PARAMSET_SIZE, (SQLPOINTER)iSizeOfArray, 0);
    // assign an array to retrieve status info for each row of parameter values
    nRetCode =SQLSetStmtAttr(m_hstmt, SQL_ATTR_PARAM_STATUS_PTR, (SQLPOINTER)ptrStatus, 0);
    // assign a buffer to store the number of sets of parameters that have been processed
    nRetCode = SQLSetStmtAttr(m_hstmt, SQL_ATTR_PARAMS_PROCESSED_PTR, (SQLPOINTER)rowsProcessed, 0);
    nRetCode = SQLBindParameter(m_hstmt, nParamIndex, nDirection, SQL_C_LONG, SQL_INTEGER, 0, 0, ptrVal, 0, ptrInd);
    //suceeds
    SQLPrepare(m_hstmt, (SQLCHAR*)"INSERT INTO my_table VALUES (?)", SQL_NTS);
    //fails
    SQLPrepare(m_hstmt, (SQLCHAR*)"{CALL mypackage.myproc1(?)}", SQL_NTS);
    SQLExecute(m_hstmt);
    package is
    create or replace package mypackage
    as
    type mytable is table of binary_integer;
    procedure myproc1( l_tab in mytable);
    end;
    show errors
    create or replace package body mypackage
    as
    procedure myproc1( l_tab in mytable)
    as
    begin
    insert into my_table values (100);
    commit;
    FORALL i IN l_tab.first .. l_tab.last
    INSERT into my_table values( l_tab(i) );
    end;
    end;
    any ideas?

    I believe when you're doing it with an insert, you're saying "execute this insert statement a bunch of times, here's all the values in advance", which is different than passing an array to a stored procedure where you want it to execute once.
    Oracle's ODBC driver doesnt support Associative Arrays (aka index-by tables).
    Hope it helps,
    Greg

  • Passing array to Oracle stored procedure

    Is it possible to pass an array (TYPES.Array) to an oracle stored procedure in WLI? I know it can be done in vanilla jdbc.
    I have tried to do this but I'm getting this exception:
    java.sql.SQLException: Fail to convert to internal representation:

    Well well well......I was able to fix the same.
    The implementation for writeSQL is the catch. We need to give the conversion only in that.
    Anyway, thanks.

  • Pass array to oracle stored procedure

    I have such a problem: I have to pass array to stored procedure, so I declare type:
    create type tNumberArray as table of number
    and create procedure:
    create or replace procedure proc_1 (in_param in tNumberArray) as
    .... BODY OF PROCEDURE ...
    when I call this procedure from C# like this:
    int []pParam = new int[3] {1,2,3};
    OracleCommand cmd = new OracleCommand("proc_1", dbConn);
    cmd.CommandType = CommandType.StoredProcedure;
    OracleParameter param14 = new OracleParameter("param", OracleDbType.Decimal);
    param14.Value = pParam;
    param14.CollectionType = OracleCollectionType.PLSQLAssociativeArray;
    param14.Size = 3;
    param14.Direction = ParameterDirection.Input;
    cmd.Parameters.Add(param14);
    cmd.ExecuteNonQuery();
    an error occures. It say that there invalid number or type of parameters.
    But when I declare both type and procedure in a package everything goes fine.
    What is the matter? Did anybody have the same problem?

    Not I got next problem:
    when I cannot pass parameter to stored procedure and get array fro it. In other words returning array from procedure and passing some input parameters to it does not word!
    Does anybody know why it happens?

  • Passing data from Oracle stored procedures to Java

    We're going to write a new web interface for a big system based on Oracle database. All business rules are already coded in PL/SQL stored procedures and we'd like to reuse as much code as possible. We'll write some new stored procedures that will combine the existing business rules and return the final result dataset.
    We want to do this on the database level to avoid java-db round trips. The interface layer will be written in Java (we'd like to use GWT), so we need a way of passing data from Oracle stored procedures to Java service side. The data can be e.g. a set of properties of a specific item or a list of items fulfilling certain criteria. Would anyone recommend a preferable way of doing this?
    We're considering one of the 2 following scenarios:
    passing objects and lists of objects (DB object types defined on the schema level)
    passing a sys_refcursor
    We verified that both approaches are "doable", the question is more about design decision, best practice, possible maintenance problems, flexibility, etc.
    I'd appreciate any hints.

    user1754151 wrote:
    We're going to write a new web interface for a big system based on Oracle database. All business rules are already coded in PL/SQL stored procedures and we'd like to reuse as much code as possible. We'll write some new stored procedures that will combine the existing business rules and return the final result dataset.
    We want to do this on the database level to avoid java-db round trips. The interface layer will be written in Java (we'd like to use GWT), so we need a way of passing data from Oracle stored procedures to Java service side. The data can be e.g. a set of properties of a specific item or a list of items fulfilling certain criteria. Would anyone recommend a preferable way of doing this?
    We're considering one of the 2 following scenarios:
    passing objects and lists of objects (DB object types defined on the schema level)
    passing a sys_refcursor
    We verified that both approaches are "doable", the question is more about design decision, best practice, possible maintenance problems, flexibility, etc.
    I'd appreciate any hints.If logic is already written in DB, and the only concern is of passing the result to java service side, and also from point of maintenance problem and flexibility i would suggest to use the sys_refcursor.
    The reason if Down the line any thing changes then you only need to change the arguments of sys_refcursor in DB and as well as java side, and it is much easier and less efforts compare to using and changes required for Types and Objects on DB and java side.
    The design and best practise keeps changing based on our requirement and exisiting design. But by looking at your current senario and design, i personally suggest to go with sys_refcursor.

  • Passing parameters to oracle stored procedure in business objects universe

    Hello,
    Wanted to create a web intelligence usind oracle stored procedure.
    Create the  following SP
    create or replace procedure proc_name1
        proc_freq in number,
        proc_cur1 in out sys_refcursor
    as
    begin
        INSERT INTO
                cc    VALUES
                ( 'Frequency Value = ' || proc_freq, SYSDATE) ;
        COMMIT ;   
        --daily
            if(proc_freq = 2) then
            open proc_cur1 for SELECT
                        EVENT_DATE
                    FROM rqm_mapsigng_dly_stats;
            end if;
    end;
    tried using the above SP in universe, it is needed to pass the parameter for proc_freq, when i pass value 2 , in oracle it is passed as 0(is being traced in rqm_checkpoint  table)
    Hence the table cannot be inserted in the universe.
    Can anyone tell why the value is not being passed correctly

    I believe when you're doing it with an insert, you're saying "execute this insert statement a bunch of times, here's all the values in advance", which is different than passing an array to a stored procedure where you want it to execute once.
    Oracle's ODBC driver doesnt support Associative Arrays (aka index-by tables).
    Hope it helps,
    Greg

  • Pass xmltype to oracle stored procedure

    I need to pass an xmltype from java to an oracle stored procedure. Does anybody have any sample code to do this? I am using jdeveloper 10.1.2
    Thanks
    MM

    Oracle provides several ways of passing objects to and from java to Oracle Stored Procedure.
    One way is to directly create oracle.sql.STRUCT object and pass array of values to this object. Another way is to implement java.sql.SQLData or oracle.sql.ORAData interfaces in your class and pass this class to setObject function.
    It is all well described in manual in chapter "Working with Oracle Object Types", there is also a lot of examples in this chapter and on the web.
    http://download-uk.oracle.com/docs/cd/B19306_01/java.102/b14355/oraoot.htm - Working with Oracle Object Types
    Some of the examples:
    http://www.oracle.com/technology/sample_code/tech/java/sqlj_jdbc/files/advanced/ObjectOracleSample/Readme.html
    http://javaalmanac.com/egs/java.sql/InsertObjectOraclePreparedStatement.html

  • Passing array from java stored procedure to plsql

    I have a java store procedure that is parsing an xml document and returning element values to my plsql application(8.1.7). I'm mapping a java.lang.String return type to VARCHAR2. However I'm running into the 4k limit when trying to return a string from java that is over 4k. Truncation of varchar returning over 4k is a known issue in 8i.
    So my next idea was to split that value of the element into 2000char and put in an array then pass that back to the plsql procedure. I know that oracle.sql.ARRAY can be converted into a plsql TABLE. But I believe you can only use the oracle.sql.ARRAY type when you are doing jdbc programming and are working with a connection.
    SO FINALLY MY QUESTION IS...
    Can anyone think of a solution that will allow me to pass over 4k of character data from my java stored procedure (not jdbc), back to my plsql app?
    Thanks.

    My understanding is that oracle 8 has a 4k limitation on any plsql function return data. A varchar can hold 32k within a function/package, but it cannot return more than 4k outside it's scope.
    Do you have an example you could share where you use the clob as a return type?
    Thanks!

  • Passing ARRAY object to stored procedure problem

    I've created a stored procedure that accepts as a parameter a
    database type
    that I have defined as a VARRAY. (create type XXX)
    When I attempt to pass an ARRAY object to this stored procedure
    through JDBC
    (Thin-client driver) I recieve the Oracle internal error ORA-
    00600 and the
    first "parameter" is [12760].
    Has anyone else attempted the same sort of thing w/ success?
    I am including the Java source code to help the investigation
    private void chad(int[] railcarIds) throws NonFatalDBException,
    FatalDBException {
    CallableStatement theStatement = null;
    try {
    theStatement = this.getDatabaseConnection().prepareCall("{call
    RomsRepairPackage.chad(?)} ");
    // create an ARRAY object to send to the procedure
    ArrayDescriptor ad =
    ArrayDescriptor.createDescriptor("RAILCARIDVARRAYTYPE",
    this.getDatabaseConnection());
    ARRAY theArray = new ARRAY(ad, this.getDatabaseConnection(),
    railcarIds);
    // set the input parameter which is the array of railcar ids
    ((OracleCallableStatement)theStatement).setARRAY(1, theArray);
    theStatement.execute();
    theStatement.close();
    } catch (SQLException sqle) {
    System.out.println("ouch");
    Thank you for any help,
    Chad Sheley
    Senior Consultant
    Cap Gemini
    Des Moines, IA
    null

    Hi
    Can u plzz help me as to how did u write the procedure to take arrays as input.I also have to write aprocedure that takes arrays and returns arrays.Plzz can u give me a working sample as I have not found any help anywhere
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Chad Sheley ([email protected]):
    I've created a stored procedure that accepts as a parameter a
    database type
    that I have defined as a VARRAY. (create type XXX)
    When I attempt to pass an ARRAY object to this stored procedure
    through JDBC
    (Thin-client driver) I recieve the Oracle internal error ORA-
    00600 and the
    first "parameter" is [12760].
    Has anyone else attempted the same sort of thing w/ success?
    I am including the Java source code to help the investigation
    private void chad(int[] railcarIds) throws NonFatalDBException,
    FatalDBException {
    CallableStatement theStatement = null;
    try {
    theStatement = this.getDatabaseConnection().prepareCall("{call
    RomsRepairPackage.chad(?)} ");
    // create an ARRAY object to send to the procedure
    ArrayDescriptor ad =
    ArrayDescriptor.createDescriptor("RAILCARIDVARRAYTYPE",
    this.getDatabaseConnection());
    ARRAY theArray = new ARRAY(ad, this.getDatabaseConnection(),
    railcarIds);
    // set the input parameter which is the array of railcar ids
    ((OracleCallableStatement)theStatement).setARRAY(1, theArray);
    theStatement.execute();
    theStatement.close();
    } catch (SQLException sqle) {
    System.out.println("ouch");
    Thank you for any help,
    Chad Sheley
    Senior Consultant
    Cap Gemini
    Des Moines, IA<HR></BLOCKQUOTE>
    null

  • Passing array parameters to Stored procedure

    Hi,
    I need to call a procedure repeatedly with different set of parameters. Instead To do this, I can form a parameter arrays and pass it to the procedure. This is working fine with Oracle 8.1.7 database and Oracle 8.1.7 odbc driver.
    Is there any difference in the way 8.1.6 Oracle ODBC driver behave? When we use the same code with 8.1.6 ODBC driver (with either 8.1.6 database or 8.1.7 database), and pass an array of n elements to the stored procedure, first elemet in the array is processed correctly and for the remaining n-1 times the same value is getting used (which leades to a unique constraint violation since procedure in this case does an insert). Soem of our clients are on 8.1.6 and so we need to get this working on it too.
    Also are you aware if Microsoft ODBC driver implements this correctly. When we traced with ODBC trace, it was executing the procedure n times one after the other thereby simulating the effect but poor performance. (MDAC 2.6).
    Is there any extra settings to be done?
    Thanks
    Sree

    Hi Justin,
    When I installed 8.1.6.6 ODBC driver this problem went off, but I recieved another problem.
    I am getting
    "ORA-01460 unimplemented or unreasonable conversion requested"
    on execution of some procedures with parameter arrays. They work fine with 8.1.7.0.
    Any idea? Is it suggested that I use 8.1.7 ODBC driver with 8.1.6 server/client? Will it create some other problem?
    Thanks
    Sree

  • Pass array in Oracle 9i procedure

    I would like to pass an array in a procedure. I would like to know how can we use array in Oracle 9i.
    I would like to use sp's to insert data from frontend. For this i need an array to pass the values of master and transactions. Is there any other way to do this plz let me know. All suggestions are welcome.

    This is the Oracle9i Lite forum. Please post your message on teh Oracle9i forum

  • Pass array to a stored procedure

    I have a comma delimited string that looks like this:
    1,t,2,t,3,f,4,t
    So I want to parse threw ththis string I send and update the DB. The numbers are ID's and t and f is the other field. An example would be great

    Actually, Tom, what you missed was the important bit. The poster wants to parse a comma separated string. .
    v := myTableType( myType( 1,'t' ), myType( 2,'f' ) );Your solution skips the hard bit ;)
    Here's my go. Of course, it requires the inputter to ensure that the string is correctly parsable (i.e. an even number of values, alternate values numeric).
    Cheers, APC
    SQL> CREATE OR REPLACE TYPE o AS OBJECT  (col1 NUMBER, col2 VARCHAR2(1));
      2  /
    Type created.
    SQL> CREATE OR REPLACE TYPE ot AS TABLE OF o;
      2  /
    Type created.
    SQL> DECLARE
      2     lv VARCHAR2(32767);
      3     i NUMBER;
      4     j NUMBER;
      5     tt ot;
      6     x number;
      7     y varchar2(1);
      8  BEGIN
      9     -- initialise
    10     lv := '1,t,2,t,3,f,4,t';
    11     tt := ot();
    12     i := 0;
    13     j := 0;
    14     LOOP
    15        i := i+1;
    16        EXIT WHEN instr(lv, ',', 1, i) = 0;
    17        --  get first value
    18        j := j+1;
    19        x := to_number(trim(substr(lv, instr(lv, ',', 1, i)-1, 1)));
    20        --  get second value
    21        i := i+1;
    22        y := trim(substr(lv, instr(lv, ',', 1, i)-1, 1));
    23        -- add found values to array
    24        tt.extend;
    25        tt(j) := o(x, y);
    26     END LOOP;
    27     dbms_output.put_line('recs='||to_char(tt.count));
    28  END;
    29  /
    recs=4
    PL/SQL procedure successfully completed.
    SQL>

  • Passing Arrays of User Defined Types to Oracle Stored Procedures

    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
    Andy

    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 an array of structures to an Oracle stored procedure (CFMX)

    I'm looking to write a Oracle stored procedure where I would pass in an array of structures and loop over each iteration to insert the bits and pieces within the structures to the DB.,
    I haven't written this type of procedure / package before.  I am planning to do an sp / package similar to what is sketched out in the second reply to this thread: http://forums.oracle.com/forums/thread.jspa?threadID=1078772
    Assuming I do, how can I call the procedure from ColdFusion (I'm using MX) and pass in my array?  As far as I can see, none of the CF_SQL_Types make sense.

    Let me know if you make any progress.  I'm fighting the same battle.  What I've done so far is to convert my array of struct into a delimited CLOB that looks like this:
    prop1;prop2;prop3|prop1;prop2;prop3|prop1;prop2;prop3|prop1;prop2;prop3|
    Then I wrote a stored proc to suck it up using a pipelined function.  It's not to bad but parsing the CLOB on the ORACLE side is somewhat time consuming.
    I've also converted the array to XML and used dbms_xmlstore to convert but, on large arrays, it is very slow and the CLOB gets huge fast.
    I was hoping to use the cf_sql_refcursor but I can't figure out how.
    Warren

  • Scripted JDBC and Oracle Stored Procedure with in/out Array

    The com.waveset.util.pooledconnection used by Scripted JDBC Adapter extends java.sql.connection.
    I need to pass an Varchar2 Array to the Stored Procedure. I tried using the oracle.sql.ARRAY and oracle.sql.ArrayDescriptor to pass the values, but get a casting exception,as the polledconnection implements only the java.sql.connection and not oracle.sql.connection.
    What are my options of using java.sql.Array with a PL/SQL procedure that takes a varchar2 array as in out parameter?
    Thanks
    Venki

    i ran my procedure which is very similar syndra posted
    create or replace procedure foo(p_dt in date, cv out sys_refcursor) as
    begin
    open cv for
    select e.*
    from table_xyz e
    where start_dt = p_dt;
    end;
    /Here is how is executed
    DECLARE
      P_DT DATE;
      CV SYS_REFCURSOR;
    BEGIN
      P_DT := '10-oct-2005';
      -- CV := NULL;  Modify the code to initialize this parameter
      scott.foo ( P_DT, CV );
      COMMIT;
    END;           
    -- i get PL/SQL procedure successfully complted , But i dont see the result set Or output
    - How do i see the output when i m using refcursor ?? i tried using print , but nothing didnt work
    - Any idea ??
    Thank you!!
    Edited by: user642297 on Jun 24, 2010 1:35 PM

Maybe you are looking for

  • Item having 0 price is going through credit check

    Hi, We are facing following issue- Our sales order is having multiple line items including a line item which creates network. When we enter the line items with price in sales order, the sales order goes into credit check. Then we review & release the

  • Submit report using internal table

    Hi Experts!!, REPORT 1 TYPES:   BEGIN OF ty_out_table,          partner LIKE /sapsll/pntbp-partner,          bpvsy   LIKE /sapsll/pntbp-bpvsy,          country LIKE adrc-country,         END OF ty_out_table. internal table declaration & definition DA

  • *How can we use the internal table in module pool programming? Clarify plz*

    If we creating a screen using the table having four fields(for e.g.). The screen has the functions of display, modify, delete, save, exit etc for the fields. The front-end of the screen having I/O fields of the table using internal table. How can we

  • How to find out the error PL/SQL

    Actually I have written stored procedures in oracle. Which contains 5 insert statements. While calling stored procedures in java. I get an error. How find out error in which line. How to debug.

  • BAPI to create OrgUnit or Position in Organizational Management (ppome)

    Hi, does an function module exits to create an OrgUnit or Position in the Organizational Management in ECC 6.0? Is there a similar fm like CRM_ORGMAN_CREATE_REL_OBJ as in CRM? Or can I also insert just an entry in Table for Infotype 1000 and 1001(Rel