How to pass ARRAY to Oracle Procedure

Hi
We are using BC4J with JSP in our project. We need to send an Array to the procedure.
Could somebody provide some info as how this can be achieved.

A while back, I used a SQLJ client to call a Java (also SQLJ) stored procedure and I needed to pass an array of strings to the procedure. I did something like this:
Java Class that was loaded in DB:
public class MyClass
// method that the stored procedure uses
public static void CALL_DOSTUFF(String a,
oracle.sql.ARRAY b,
oracle.sql.ARRAY c)
String[] bb = (String[])b.getArray();
String[] cc = (String[])c.getArray();
doStuff(a,bb,cc);
public static void doStuff(String a,
String[] b,
String[] c)
// process the input
In the database I added the type:
create or replace type STR_ARRAY as table of varchar2(20);
and the procedure:
create or replace procedure CALL_DOSTUFF(a varchar2,
b STR_ARRAY,
c STR_ARRAY)
as
language java
name 'MyClass.CALL_DOSTUFF(java.lang.String,
oracle.sql.ARRAY,
oracle.sql.ARRAY)';
I then used jpub to publish a STR_ARRAY.java file. I compiled this and used it with my SQLJ client to call to the stored procedure. The STR_ARRAY constructor takes a String[], so you do something like this in the SQLJ client:
String x = "X";
String y = {"y1","y2"};
String z = {"z1","z2"};
STR_ARRAY y1 = new STR_ARRAY(y);
STR_ARRAY z1 = new STR_ARRAY(z);
#sql {CALL CALL_DOSTUFF(:x,:y1,:z1)};
Hope this helps.

Similar Messages

  • How to pass values to Oracle store procedure in Crystal Report

    Hi all,
    I am newbie on passing values to stored procedure parameters. I created a Crystal Report using the Crystal Report wiward with PULL method and data come from Oracle stored procedure. In an ASP.NET page, I have stored two values in Session and need to pass them as input parameters to Oracle stored procedure to print the report. In Crystal reports 2010 once you connect to a stored-procedure as data source, it automatically creates the parameter fields with Crytal Report Viewer. Please show me how I pass values to store procedure at runtime automatically.
            'Set the parametter value
            myReport.SetParameterValue("@P_COURSE", "CoursetNo")
            myReport.SetParameterValue("@P_CLASS", "ClassNo")
        End Sub
    I tried to apply above codes from Brian Bischof book but display the error from the following lines:
            myReport.SetParameterValue("@P_COURSE", "CoursetNo")
            myReport.SetParameterValue("@P_CLASS", "ClassNo")
    I also enclosed my code. Any experts, please let me know anything wrongs on my code . I tried several methods that searching via google, but did not solve my issues. Thanks.
    Edited by: avt2K7 on Mar 15, 2011 7:02 AM

    Hi,
    Thank you for your response. Here are the detailed code and error as following:
    Please show what I am missing in my below VB.NET codes:
    ===========================================================================================
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            LogonToTables("username", "password", "servername", "")
        End Sub
        Private Sub LogonToTables(ByVal myUserId As String, ByVal myPassword As String, ByVal myServerName As String, ByVal myDataBaseName As String)
            Dim Course, Class As String
            Course = Session.Item("CourseNumber"))
            Class = Session.Item("ClassNumber"))
            Dim myReport As New CrystalDecisions.CrystalReports.Engine.ReportDocument
            myReport.Load(Server.MapPath("CrystalReport1.rpt"))
            Dim myTableLogonInfo As CrystalDecisions.Shared.TableLogOnInfo
            'Set the database properties and security credentials
            Dim myConnectionInfo As New CrystalDecisions.Shared.ConnectionInfo
            myConnectionInfo.ServerName = "servername"
            myConnectionInfo.DatabaseName = ""
            myConnectionInfo.UserID = "username"
            myConnectionInfo.Password = "password"
            'Apply the ConnectionInfo to the report tables
            Dim myTables = myReport.Database.Tables
            For Each myTable As CrystalDecisions.CrystalReports.Engine.Table In myTables
                myTableLogonInfo = myTable.LogOnInfo
                myTableLogonInfo.ConnectionInfo = myConnectionInfo
                myTable.ApplyLogOnInfo(myTableLogonInfo)
            Next
            'Set the parametter value to Crystal Report parameter named P_COURSE and P_CLASS
            myReport.SetParameterValue("@P_COURSE", "Course")
            myReport.SetParameterValue("@P_CLASS", "Class")
        End Sub
    =================================================================================
    I put a break point to debug but display the error at the following lines:
            myReport.SetParameterValue("@P_COURSE", "Course")
            myReport.SetParameterValue("@P_CLASS", "Class")
    Eventhough, if I set a specific value to Course=1000 and Class = math and still receive the error:
    Invalid index. (Exception from HRESULT: 0x8002000B (DISP_E_BADINDEX))
    I tried several sources from Google search but it is not working. I really appreciate any detailed code either in C# or VB.NET to solve my issues. Thanks in advance.

  • 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.

  • 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?

  • How to get resultset from oracle procedure use ejb3

    how to get resultset from oracle procedure use ejb3
    i know oracle procedure should like this
    Create or replace PROCEDURE resultset_test(
    aaa IN NUMBER,
    bbb OUT sys_refcursor) ....
    but what s the ejb3 scripts looks like? please give me an example or link~
    ths

    - there are no EJB3 scripts, only compiled application code
    - the part of the EJB spec that deals with databases is called the Java Persistence API, but likely you are just looking for the JDBC API.
    Now you should know what to Google to get your "example script": "java jdbc oracle procedure"

  • How to pass an array in Oracle Procedure

    If I have to pass an array as an argument in Oracle Procedure/function. How to do that ??
    For example, I have to pass the names of employess and then for these employess I have to do something in Oracle Procedure.
    Thanks & Regards,
    Vinay

    Hi!
    Here is an example:
    create or replace procedure test
    is
    type v2_itt is table of varchar2(2000) index by binary_integer;
    l_v2 v2_itt;
    procedure test2( pi_v2 v2_itt ) is
    begin
    for i in 1 .. pi_v2.count loop
    dbms_output.put_line( pi_v2(i) );
    end loop;
    end;
    begin
    l_v2(1) := 'name1';
    l_v2(2) := 'name2';
    test2( l_v2 );
    end;
    Regards,
    Andrew Velitchko
    BrainBench MVP for Developer/2000
    http://www.brainbench.com

  • How to pass array of Object in A Procedure using OCCI.......

    I m also trying for How to pass Object to a procedureb using OCCI...
    Steps....
    1. I created A type.....
    2. Then I created a VARRAY using that Type.
    3.After that I have written An Procedure with object as a parameter..
    now using OCCI how do u bind the parameter with this . plz note that using OTT
    i have already created the class representation of above object type i.e class
    four Files Created 1> demo.h 2>registermapping.h
    3> demo.cpp 2>registermapping.cpp
    After I want to Pass the Values in A Vector...
    vctor<full_name *> vect;
    stmt=con->createStatement("BEGIN Add_Object(:1); END;");
    full_name *name1 = new full_name; //Giving the Error here Given below....
    name1->
    name1->
    Through name1 Which Function I will call in which I will Pass a String....
    like
    name1->readSQL("Sanjay"); Or I have to add a function......
    vect.push_back(name1);
    setVector(stmt,1,vect,"FULL_NAME");
    error C2259: 'FullName' : cannot instantiate abstract class
    can u plz suggest me Why this Error is Giving......?
    How to pass the data?
    setFirst_name() and setLast_name() this two function I will add in Demo.cpp which one created automativcally by Using OTT command.....or other way plz tell me Boss ....
    Can u lz Suggest me ASAP....

    hi Nishant ,
    What u have done Now I mm trying ....
    can u Plz Suggest me......
    How to pass and Array of Object in Procedure using OCCI... Doing....
    90% finished Two Error's Are Coming...
    1> If I create the Class then Data Not Inserting table......
    2> If I will create the Class through OTT command.......
    then U can't Instantiate Object It is DIsplying ,this is Abstract Class(PObject)...
    Beco'z the below Method is Not adding Automatically by OTT command which is Pure Virtual Function.....
    But I added this Function Still SAme Error Giving..
    getSQLTypeName(oracle::occi::Environment env, void *schName,
    unsigned int &schNameLen, void **typeName,
         unsigned int &typeNameLen) const
    Plz Suggest me....
    regard's
    sanjay

  • 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

  • How to pass arry in stored procedure

    I want to pass an array thru a JDBC to a stored procedure
    how can i pass a java variable string array to the store procedure using JDBC.
    here is my package for array:
    CREATE OR REPLACE PACKAGE TABLE_TYPES
    AS
    TYPE tString IS TABLE OF VARCHAR2(10) INDEX BY BINARY_INTEGER;
    END;
    here is my store procedure:
    CREATE OR REPLACE PROCEDURE Declassification
    (P_COMPANY_ID IN SECURITY.COMPANY_ID%TYPE,
    P_SECURITY_NAME IN SECURITY.SECURITY_NAME%TYPE,
    P_SECURITY_SYMBOL IN SECURITY.SECURITY_SYMBOL%TYPE,
    P_CURRENCY IN SECURITY.CURRENCY%TYPE,
    P_ISIN IN SECURITY.ISIN%TYPE,
    P_LISTING_DATE IN VARCHAR2,
    P_SECTOR IN SECURITY.SECTOR%TYPE,
    P_INDUSTRY IN SECURITY.INDUSTRY%TYPE,
    P_PAR_VALUE IN VARCHAR2,
    P_PAR_VALUE_AS_OF IN VARCHAR2,
    P_BOARDLOT IN VARCHAR2,
    P_BOARDLOT_AS_OF IN VARCHAR2,
    P_MARKET_PRICE IN VARCHAR2,
    P_REQD_PUBLIC_OWN_PERC IN VARCHAR2,
    P_STATUS IN SECURITY.STATUS%TYPE,
    P_SECURITIES IN Table_Types.tString,
    P_ID OUT SECURITY.SECURITY_ID%TYPE)
    AS
    P_SECURITY_ID SECURITY.SECURITY_ID%TYPE;
         rec_count NUMBER;
    BEGIN
         SELECT COUNT(*)
         INTO rec_count
         FROM SECURITY;
         IF rec_count > 0 THEN
              SELECT MAX(TO_NUMBER(security_id)) + 1
              INTO P_SECURITY_ID
              FROM SECURITY;
         ELSE
              P_SECURITY_ID:=1;
         END IF;
              INSERT INTO SECURITY
              VALUES(P_SECURITY_ID, P_COMPANY_ID, P_SECURITY_NAME, P_SECURITY_SYMBOL, 'COMMON',
                        P_CURRENCY, P_ISIN, TO_DATE(P_LISTING_DATE,'mm/dd/yyyy'), P_SECTOR, P_INDUSTRY, TO_NUMBER(P_PAR_VALUE),
                        TO_DATE(P_PAR_VALUE_AS_OF,'MM/DD/YYYY'), TO_NUMBER(P_BOARDLOT), TO_DATE(P_BOARDLOT_AS_OF,'MM/DD/YYYY'),
                        TO_NUMBER(P_MARKET_PRICE), TO_NUMBER(P_REQD_PUBLIC_OWN_PERC), P_STATUS);
              INSERT INTO SECURITY_FINANCIAL(SECURITY_ID)
              VALUES (P_SECURITY_ID);               
              INSERT INTO SECURITY_TOTAL(SECURITY_ID)
                        VALUES (P_SECURITY_ID);
         COMMIT;
    END Declassification;

    I want to pass an array thru a JDBC to a stored
    procedure
    how can i pass a java variable string array to the
    store procedure using JDBC.
    here is my package for array:
    CREATE OR REPLACE PACKAGE TABLE_TYPES
    AS
    TYPE tString IS TABLE OF VARCHAR2(10) INDEX BY
    Y BINARY_INTEGER;
    END;
    There are two ways to pass in Arrays to stored procedures in Oracle:
    1. Define an Oracle TYPE outside a package and then use oracle.sql.ARRAY and oracle.sql.ArrayDescriptor to explain to the driver how the array is structured. This is what Avi has shown how to do.
    2. You can also pass in INDEX BY arrays of VARCHAR2 or NUMBER, provided they are indexed by BINARY_INTEGER. This is what you appear to want. In order to do this you'll probably need the 10g JDBC driver and code that uses the 'setPlsqlIndexTable' method of 'OraclePreparedStatement' to bind your array.
    Be careful about the values you pass into the 'setPlsqlIndexTable' method. You have to specify in advance how much data you expect to get back and how long each row is. The driver allocates memory based on these numbers. You code also needs to cope with arrays that have null elements.
    I work for a company that makes a JDBC code generator. A list of common situations we've encountered when working with Index By tables can be found here:
    http://www.orindasoft.com/public/PL-SQL%20Recordstwo.php4?siteloc=PL-SQL%20Recordstwo#probix
    David Rolfe
    Orinda Software
    Dublin, Ireland
    www.orindasoft.com
    Orinda Software makes OrindaBuild, which writes JDBC calls for PL/SQL and SQL.

  • Unable to pass parameter in oracle procedure through unix shell script

    Hi Experts,
    I have oracle procedure where in I have to pass the value of procedure parameter through unix script.
    Follwoing is the sample procedure which i tried to exceute from the unix.
    Procedure:
    create or replace procedure OWNER.PRC_TESTING_OWNER(OWNER IN VARCHAR2) AS
    sql_stmt varchar2(1000) := NULL;
    v_count number := 0;
    v_owner varchar2(100) := owner;
    begin
    sql_stmt:='select count(1) from '||v_owner||'.EMP@infodb where rownum<=10';
    execute immediate sql_stmt into v_count;
    DBMS_OUTPUT.PUT_LINE(sql_stmt);
    DBMS_OUTPUT.PUT_LINE(v_count);
    END;The script which I used is:
    Unix
    #!/bin/ksh
    parm=$1
    echo start
    sqlplus -s scott@DEV/tiger <<EOF >>result_1.txt
    set serveroutput on;
    select '$parm' from dual;
    exec owner.PRC_TESTING_OWNER('$parm');
    EOFThe script is working fine that is i am able to pass to parameter value through unix shell script. :)
    But if I want to pass the value of the owner in cursor , I am unable to pass this value through unix.
    Following the procedure which i am trying to implement.
    create or replace procedure OWNER.PRC_TESTING_OWNER(OWNER IN VARCHAR2) IS
    v_owner varchar2(100) := owner;
    CURSOR main_cur IS 
      select
      i.ROWID  rid ,
      emp_name,
      deptid
      from v_owner.employee;
    CURSOR subset_cur(c_deptid NUMBER ) IS
        SELECT *
          FROM v_owner.DEPT d
          where  d.dept_id=c_deptid;
    --##main loop     
    FOR i IN main_cur LOOP
          FOR j IN subset_cur(i.deptid) LOOP     
    BEGIN
    insert into v_owner.RESULT_TABLE
    END;
    END LOOP;
    END LOOP;How can i pass parameter value of the stored procedure through unix script(that is "owner" in this case), when these parameter value is
    used in cursor? :(
    Can anybody help me regarding the same?
    Thanks in Advance !! :D

    It's not the parameter in the cursor that is the problem, it's that you are trying to use static SQL for something that won't be known until run time (the owner of the table).
    You would need to use something like ...
    declare
       l_owner        varchar2(30) := 'SCOTT';
       l_ref_cursor   sys_refcursor;  
       type l_ename_tab is table of scott.emp.ename%type;
       l_ename_array  l_ename_tab;
    begin
       open l_ref_cursor for
          'select ename
          from ' || l_owner || '.emp';
       loop
          fetch l_ref_cursor bulk collect into l_ename_array limit 10;
          exit when l_ename_array.COUNT = 0;
          for x in 1 .. l_ename_array.count
          loop
             dbms_output.put_line(l_ename_array(x));
          end loop;
       end loop;
       close l_ref_cursor;
    end;
    SMITH
    ALLEN
    WARD
    JONES
    MARTIN
    BLAKE
    CLARK
    SCOTT
    KING
    TURNER
    ADAMS
    JAMES
    FORD
    MILLER
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:00.01

  • Passing array to the procedure in parameter

    Hi
    I tried the following code,
    Where my aim is to split the comma separated values and insert into an array, and then pass that array to another procedure in a package
    CREATE OR REPLACE PACKAGE PAK_SPLIT_TEST AS
    PROCEDURE PROC_SPLIT(IN_LIST  VARCHAR2) ;
    END;
    CREATE OR REPLACE PACKAGE PAK_SPLIT_TEST AS
    PROCEDURE PROC_SPLIT(IN_LIST  VARCHAR2) ;
    END;
    CREATE OR REPLACE PACKAGE PAK_SPLIT_TEST
    AS
       PROCEDURE PROC_SPLIT (IN_LIST VARCHAR2);
    END;
    CREATE OR REPLACE PACKAGE BODY PAK_SPLIT_TEST
    AS
       PROCEDURE PROC_REM_LIST (p_array l_data)
       IS
       BEGIN
          FOR i IN 1 .. p_array.COUNT
          LOOP
             DBMS_OUTPUT.put_line (p_array (i));
          END LOOP;
       END;
       PROCEDURE PROC_SPLIT (IN_LIST VARCHAR2)
       IS
          TYPE SPLIT_array IS TABLE OF VARCHAR2 (4000)
                                 INDEX BY BINARY_INTEGER;
          l_data   SPLIT_array;
          l_txt    LONG := '100,200,300,400,500,600';
          l_str    LONG := IN_LIST || ',';
          l_n      NUMBER;
       BEGIN
          BEGIN
             l_data.delete;
             LOOP
                l_n := INSTR (l_str, ',');
                EXIT WHEN NVL (l_n, 0) = 0;
                l_data (l_data.COUNT + 1) := SUBSTR (l_str, 1, l_n - 1);
                l_str := SUBSTR (l_str, l_n + 1);
             END LOOP;
             PROC_REM_LIST (l_data);
          END;
       END;
    SELECT *FROM USER_ERRORSI'm getting the following error at line no. 30
    PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following:
       begin end function package pragma procedure formCould you please help me in this
    Thanks,
    Smile

    Give this a shot:
    CREATE OR REPLACE PACKAGE BODY PAK_SPLIT_TEST
    AS
          TYPE SPLIT_array IS TABLE OF VARCHAR2 (4000)
                                 INDEX BY BINARY_INTEGER;
       PROCEDURE PROC_REM_LIST (p_array SPLIT_array)
       IS
       BEGIN
          FOR i IN 1 .. p_array.COUNT
          LOOP
             DBMS_OUTPUT.put_line (p_array (i));
          END LOOP;
       END;
       PROCEDURE PROC_SPLIT (IN_LIST VARCHAR2)
       IS
          l_data   SPLIT_array;
          l_txt    LONG := '100,200,300,400,500,600';
          l_str    LONG := IN_LIST || ',';
          l_n      NUMBER;
       BEGIN
          BEGIN
             l_data.delete;
             LOOP
                l_n := INSTR (l_str, ',');
                EXIT WHEN NVL (l_n, 0) = 0;
                l_data (l_data.COUNT + 1) := SUBSTR (l_str, 1, l_n - 1);
                l_str := SUBSTR (l_str, l_n + 1);
             END LOOP;
             PROC_REM_LIST (l_data);
          END;
       END;
    END pak_split_test;
    /PROC_REM_LIST was expecting a PL/SQL type of L_DATA. You have not defined that type anywhere (e.g. in your package spec, body, or in SQL). I move the declaration from PROC_SPLIT to your package body and it compiles.
    Hope this helps!

  • How to pass array into xslt from java

    i have a xslt in which i am passing some parameter from java there is one parameter which is a array in java which i need to pass becouse array length is not defined so that xslt will work dynakically according to the parameter.
    right now i am passing parameter but not able to send the array parameter that's why my code is not fully dynamic
    please give suggestion.
    anagh

    it is not possible to pass array by using XSLT, you can wirite all values into a String with certain delim symbol, pass this string, then use xsl.substring() to get different values.

  • How to use Arrays in Oracle

    Can any one help me to use an Array in oracle.Also i want to search whether an element is already existing in the array

    One possible approach
    SQL> create or replace type array as table of number;
      2  /
    Type created.
    SQL> select case when count(*) = 1 then 'found' else 'not found' end
      2  from dual
      3  where exists (
      4    select null from table(array(1,2,3,4,5))
      5    where column_value = 3);
    CASEWHENC
    found
    SQL> edi
    Wrote file afiedt.sql
      1  select case when count(*) = 1 then 'found' else 'not found' end
      2  from dual
      3  where exists (
      4    select null from table(array(1,2,3,4,5))
      5*   where column_value = 1)
    SQL> /
    CASEWHENC
    found
    SQL> edi
    Wrote file afiedt.sql
      1  select case when count(*) = 1 then 'found' else 'not found' end
      2  from dual
      3  where exists (
      4    select null from table(array(1,2,3,4,5))
      5*   where column_value = 6)
    SQL> /
    CASEWHENC
    not found

  • How to passing array as parameter to oracle stored procedure from JPA

    Hi All,
    I need to call a stored proc in Oracle that accepts an array as input parameter.
    Pls let me know how should i call it from my JPA. Is this even possible without using JDBC directly?
    i keep getting the ff error:
    wrong number or types of arguments in call to ....
    my code is something like this:
    String[] myArr...
    Query query = em.createNativeQuery("BEGIN myStoredProc(:arr); END;");
    query.setParameter("arr", myArr);
    Thanks in advance.

    I also fail to get this done my code till now is:
    PLSQL Function:
    function getHtml(pWhere VARCHAR2 DEFAULT NULL,
    pColSort HTP.STRINGARRAY) return clob is
    begin
    errorhndl.Log(pMessage => 'called');
    htp.prn('das ist der test
    for i in 1 .. pColSort.count loop
    htp.p('
    pColSort['||i||']: '||pColSort(i));
    end loop;
    htp.prn('
    <table> <tr> <td> max1.0 </td> <td> max2.0 </td> </tr>');
    htp.prn('<tr> <td> max1.1 </td> <td> max2.1 </td> </tr> </table>');
    htp.prn('test ende');
    return htp.gHtpPClob;
    exception
    when others then
    null;
    end getHtml;
    PLSQL TYPE: (in HTP package - self created - but could be anywhere else too)
    type STRINGARRAY is table of varchar2(256) index by binary_integer;
    JAVA DOA:
    public class ShowReportDOAImpl implements ShowReportDOA {
         private JdbcTemplate jdbcTemplate;
         private SimpleJdbcCall procShowReport;
         public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
              this.jdbcTemplate = jdbcTemplate;
              procShowReport = new SimpleJdbcCall(this.jdbcTemplate)
              .withCatalogName("Show_Report")
              .withFunctionName("getHtml")
              .withoutProcedureColumnMetaDataAccess()
              .declareParameters(
                   new SqlParameter("pWhere", Types.VARCHAR),
                   new SqlParameter("pColSort", Types.ARRAY, "HTP.STRINGARRAY"),
                   new SqlOutParameter("RETURN", Types.CLOB)
         public String readReport(Long id, ParameterHelper ph) {
              String[] sortCol = {"max", "michi", "stefan"};
              String pWhere = "fritz";
              MapSqlParameterSource parms = new MapSqlParameterSource();
              parms.addValue("pWhere", pWhere);
              parms.addValue("pColSort", sortCol, Types.ARRAY, "HTP.STRINGARRAY");
    parms.addValue("pColSort", Arrays.asList(sortCol), Types.ARRAY, "HTP.STRINGARRAY");
    Clob clob = procShowReport.executeFunction(Clob.class, parms);
    String clobString = "";
    try {
         System.out.println("length: "+new Long(clob.length()).intValue());
                   clobString = clob.getSubString(1, new Long(clob.length()).intValue());
              } catch (SQLException e) {
                   e.printStackTrace();
    return clobString;
    EXCEPTION IS:
    org.springframework.jdbc.UncategorizedSQLException: CallableStatementCallback; uncategorized SQLException for SQL [{? = call SHOW_REPORT.GETHTML(?, ?)}]; SQL state [null]; error code [17059]; Konvertierung zu interner Darstellung nicht erfolgreich: [max, michi, stefan]; nested exception is java.sql.SQLException: Konvertierung zu interner Darstellung nicht erfolgreich: [max, michi, stefan]
         org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:83)
         org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
         org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
         org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:969)
         org.springframework.jdbc.core.JdbcTemplate.call(JdbcTemplate.java:1003)
         org.springframework.jdbc.core.simple.AbstractJdbcCall.executeCallInternal(AbstractJdbcCall.java:391)
         org.springframework.jdbc.core.simple.AbstractJdbcCall.doExecute(AbstractJdbcCall.java:354)
         org.springframework.jdbc.core.simple.SimpleJdbcCall.executeFunction(SimpleJdbcCall.java:154)
         at.ontec.cat.config.doa.ShowReportDOAImpl.readReport(ShowReportDOAImpl.java:47)
         at.ontec.cat.http.ShowReport.doGet(ShowReport.java:80)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
         org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:113)
         org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
    root cause
    java.sql.SQLException: Konvertierung zu interner Darstellung nicht erfolgreich: [max, michi, stefan]
         oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:124)
         oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:161)
         oracle.jdbc.driver.DatabaseError.check_error(DatabaseError.java:860)
         oracle.sql.ARRAY.toARRAY(ARRAY.java:209)
         oracle.jdbc.driver.OraclePreparedStatement.setObjectCritical(OraclePreparedStatement.java:7767)
         oracle.jdbc.driver.OraclePreparedStatement.setObjectInternal(OraclePreparedStatement.java:7448)
         oracle.jdbc.driver.OraclePreparedStatement.setObjectInternal(OraclePreparedStatement.java:7836)
         oracle.jdbc.driver.OracleCallableStatement.setObject(OracleCallableStatement.java:4586)
         org.apache.commons.dbcp.DelegatingPreparedStatement.setObject(DelegatingPreparedStatement.java:166)
         org.apache.commons.dbcp.DelegatingPreparedStatement.setObject(DelegatingPreparedStatement.java:166)
         org.springframework.jdbc.core.StatementCreatorUtils.setValue(StatementCreatorUtils.java:356)
         org.springframework.jdbc.core.StatementCreatorUtils.setParameterValueInternal(StatementCreatorUtils.java:216)
         org.springframework.jdbc.core.StatementCreatorUtils.setParameterValue(StatementCreatorUtils.java:127)
         org.springframework.jdbc.core.CallableStatementCreatorFactory$CallableStatementCreatorImpl.createCallableStatement(CallableStatementCreatorFactory.java:212)
         org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:947)
         org.springframework.jdbc.core.JdbcTemplate.call(JdbcTemplate.java:1003)
         org.springframework.jdbc.core.simple.AbstractJdbcCall.executeCallInternal(AbstractJdbcCall.java:391)
         org.springframework.jdbc.core.simple.AbstractJdbcCall.doExecute(AbstractJdbcCall.java:354)
         org.springframework.jdbc.core.simple.SimpleJdbcCall.executeFunction(SimpleJdbcCall.java:154)
         at.ontec.cat.config.doa.ShowReportDOAImpl.readReport(ShowReportDOAImpl.java:47)
         at.ontec.cat.http.ShowReport.doGet(ShowReport.java:80)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
         org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:113)
         org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
    Please help!!
    Please help!!

  • 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

Maybe you are looking for

  • Replacing GET by a SELECT query

    hi all. i have a get+check options syntax in a report. i want to replace the code with a select query.. i want to replace GET + CHECKby SELECT+WHERE... but when does this GET statement end? like if i replace it with select, then i would have to put E

  • Track the changes to the batch jobs in the PRD system.

    Hello Basis Guru's, Need your help in a Query. --> Is there any best practice that can be implemented to trace all the changes done to batch jobs in the past 3 months and going forward. Be it in its scheduling or its variant changes etc, i would like

  • Microsoft Lync Server 2013 Control Panel "Navigation to the webpage was canceled"

    i'm facing this issue on the last 2 days.My Lync server 2013 was seted up a month ago and everything went fine on the installation. Lync server 2013 on Windows 2008R2 SP1. I could login to the Control Panel (using domain administrator credentials), c

  • Text layout problem

    I apologize for the plethora of stupid questions I am about to ask - I am brand new to dreamweaver and atempting to design a very simple website layout for myself. My most glaring problem is this: I wish for text to be in the centre of the webpage an

  • Adobe Reader Update 11.0.09

    What is the difference between AdbeRdrUpd11009.msp and AdbeRdrUpd11009_incr.msp from the Adobe FTP? 33MB  of data?