Retriving an Array from an Oracle Procedure in Java

I have a procedure in Oracle which returns an VARRAY of VARCHAR2
I am Unable to get the Array back in the Servlet in my Application.....
I have tried this using normal thin driver and couldn't succed....
So I have tried with OCI driver then also i was unble to get the Array.
I have used ojdbc14.jar for OCI connection

thanks for the reply.
That is What I ma doing exactly.....
I am also placing the code here check it out......
My Oracle PL/SQL Code is here
===========================
CREATE OR REPLACE package types
as
type varray is VARRAY(10) OF VARCHAR2(100);
end;
CREATE OR REPLACE PROCEDURE getArray(userid IN VARCHAR2, arrayList OUT types.array)
IS
BEGIN
     arrayList(0) := 'Hello';
     arrayList(1) := 'Welcome';
END;
===========================
My Java Code is this
===========================
Class.forName("oracle.jdbc.driver.OracleDriver");
con=DriverManager.getConnection("jdbc:oracle:oci:lcms/lcms@GDBN");
stmt = (OracleCallableStatement) conn.prepareCall("begin :1 := getArray(?,?); end;");
stmt.setString(1,"abcd");
stmt.registerOutParameter(2, OracleTypes.ARRAY);
stmt.executeUpdate();
ARRAY simpleArray = stmt.getARRAY(1);
System.out.println("Array is of type " + simpleArray.getSQLTypeName());
System.out.println("Array element is of type code "+simpleArray.getBaseType());
System.out.println("Array is of length " + simpleArray.length());
System.out.println("======================================");
String[] values = (String[])simpleArray.getArray();
for( int i = 0; i < values.length; i++ )
     System.out.println( "row " + i + " = '" + values[i] +"'" );
This is what I am doing in My JAVA Code....
================================================
When I execute this I get an Error Message at Line
--->>>>stmt.registerOutParameter(2, OracleTypes.ARRAY);
Error Message is As follows....
javax.servlet.ServletException: Parameter Type Conflict: sqlType=2003
     org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:825)
     org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)
     org.apache.jsp.jsp.gpreports.FunctionPageWiseGPAllCasesCompleteHistory_jsp._jspService(FunctionPageWiseGPAllCasesCompleteHistory_jsp.java:159)
     org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
     javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
     org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
     org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
     org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
     javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause
java.sql.SQLException: Parameter Type Conflict: sqlType=2003
     oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
     oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
     oracle.jdbc.driver.OracleCallableStatement.registerOutParameterBytes(OracleCallableStatement.java:239)
     oracle.jdbc.driver.OracleCallableStatement.registerOutParameter(OracleCallableStatement.java:393)
     oracle.jdbc.driver.OracleCallableStatement.registerOutParameter(OracleCallableStatement.java:462)
     org.apache.jsp.jsp.gpreports.FunctionPageWiseGPAllCasesCompleteHistory_jsp._jspService(FunctionPageWiseGPAllCasesCompleteHistory_jsp.java:94)
     org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
     javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
     org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
     org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
     org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
     javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

Similar Messages

  • Returing array from PL/SQL procedure

    Hi,
    I am trying to return array from PL/SQL procedure. Heres is the code. I am getting an error "OracleParameter.ArrayBindSize is invalid ".
    Will anybody let me know what is wrong in following code. or does anybody have code to return PL/SQL array using VB.NET.
    oCommand.CommandText = "MyPack.TestVarchar2"
    oCommand.CommandType = CommandType.StoredProcedure
    Dim id As Integer = 10
    Dim deptname As String()
    Dim oParam1 As Oracle.DataAccess.Client.OracleParameter = New Oracle.DataAccess.Client.OracleParameter("id", Oracle.DataAccess.Client.OracleDbType.Int32)
    Dim oParam2 As Oracle.DataAccess.Client.OracleParameter = New Oracle.DataAccess.Client.OracleParameter("deptname", Oracle.DataAccess.Client.OracleDbType.Varchar2)
    oParam1.Direction = ParameterDirection.Input
    oParam2.Direction = ParameterDirection.Output
    oParam1.CollectionType = Oracle.DataAccess.Client.OracleCollectionType.None
    oParam2.CollectionType = Oracle.DataAccess.Client.OracleCollectionType.PLSQLAssociativeArray
    oParam1.Value = id
    oParam2.Value = ""
    oParam1.Size = 10
    oParam2.Size = 20
    oCommand.Parameters.Add(oParam1)
    oCommand.Parameters.Add(oParam2)
    oCommand.ExecuteNonQuery()
    Thanks
    Sameer

    Thanks Arnold for the reply..
    Yes, I am trying to get result set in array which is unknow to me (No of rows return by the query). For the test I will pre-define the result set so that I will able to set ArrayBindSize.
    I have read C# example but when I try to write it in VB.NET it gives me syntax error when I try to set the ArrayBindSize.
    oParam.ArrayBindSize = new int[3]{15,23,13} // individual max size of 3 outputsWill you please let me know how to set ArrayBindSize (VB.NET) because I am new to this..
    There is an example at otn "How to: Bind an Array to an ODP.NET Database Command" which does multiple INSERTs in one trip to database. This works fine. I need to do same for the SELECT statement which will return me multiple rows. I do not mean refCursor. If I use refCursor, it will make soft parse which I am trying to avoid using this Array techniq.
    Thanks
    Sameer

  • DBMS_OUTPUT.PUT_LINE multi records from PL/SQL procedure to Java web page.

    Hello
    I will explain the scenario:
    In our java web page, we are using three text boxes to enter "Part number,Description and Aircraft type". Every time the user no need to enter all these data. The person can enter any combination of data or only one text box. Actually the output data corresponding to this input entries is from five Oracle table. If we are using a single query to take data from all the five tables, the database will hang. So I written a procedure "SEARCH1",this will accept any combination of values (for empty values we need to pass NULL to this procedure) and output data from all the five tables. When I executing this procedure in SQL editor, the execution is very fast and giving exact result. I used "dbms_output.put_line" clause for outputing multiple records in my procedure. The output variables are "Serial No, part Number, Description, Aircraft type,Part No1,Part No2,Part No3,Part No4". I want to use the same procedure "SEARCH1" for outputing data in java web page.The passing argument I can take from the text box provided in java web page. I am using jdbc thin driver to connect our java web page to Oracle 9i database.
    Note1 : If any combination of search item not available, in procedure itself I am outputing a message like "Part Number not found". Here I am using four words ("Part" is the first word,"Number" is the second,"Not" s the third, and "found" is the fourth) for outputing this message.Is it necessary to equalise number of words I am using here to the record outputing eight variable?
    Our current development work is stopped because of this issue. So any one familier in this field,plese help me to solve our issue by giving the sample code for the same scenario.
    My Email-id is : [email protected]
    I will expect yor early mail.
    With thanks
    Pramod kumar.

    Hello Avi,
    I am trying to solve this issue by using objects. But the following part of code also throwing some warning like "PLS-00302: component must be declared". Plese cross check my code and help me to solve this issue.
    drop type rectab;
    create or replace type rectype as object(PartNo varchar2(30),Description varchar2(150),AIrcraft_type varchar2(15),status_IPC varchar2(30),status_ELOG varchar2(30),status_SUPCAT varchar2(30),status_AIRODWH varchar2(30));
    create or replace type rectab as table of rectype;
    create or replace package ioStructArray as
    procedure testsch2(pno in varchar2,pdes in varchar2,air in varchar2,orec in out rectab);
    end ioStructArray;
    create or replace package body ioStructArray as
    procedure testsch2(pno in varchar2,pdes in varchar2,air in varchar2,orec in out rectab) is
    mdescription varchar2(150);
    mpartnum varchar2(30);
    mpno varchar2(30);
    mdes varchar2(150);
    mair varchar2(15);
    mstat varchar2(1);
    cursor c1 is select partnum,description,aircraft_type from master_catalog where partnum=mpno and aircraft_type=mair and description like ltrim(rtrim(mdes))||'%';
    cursor c2 is select partnum from ipc_master where partnum=mpartnum;
    cursor c3 is select partnum from fedlog_data where partnum=mpartnum;
    cursor c4 is select partnum from superparts where partnum=mpartnum;
    cursor c5 is select part_no from supplier_catalog where part_no=mpartnum;
    mpno1 varchar2(30);
    mpno2 varchar2(30);
    mpno3 varchar2(30);
    mpno4 varchar2(30);
    mpno5 varchar2(30);
    maircraft_type varchar2(15);
    mstat1 varchar2(30);
    mstat2 varchar2(30);
    mstat3 varchar2(30);
    mstat4 varchar2(30);
    begin
    mstat:='N';
    mpno:=pno;
    mdes:=pdes;
    mair:=air;
    if mpno is not null and mdes is not null and mair is not null then
    begin
    mstat:='N';
    mpno:=pno;
    mdes:=pdes;
    mair:=air;
    for i in c1 loop
    mstat:='N';
    mstat1:='N';
    mstat2:='N';
    mstat3:='N';
    mstat4:='N';
    mpno1:=i.partnum;
    mpartnum:=i.partnum;
    mdescription:=i.description;
    maircraft_type:=i.aircraft_type;
    for j in c2 loop
    mpno2:=j.partnum;
    end loop;
    for k in c3 loop
    mpno3:=k.partnum;
    end loop;
    for l in c4 loop
    mpno4:=l.partnum;
    end loop;
    for m in c5 loop
    mpno5:=m.part_no;
    end loop;
    if mpno2=mpartnum then
    mstat1:=mpno2;
    end if;
    if mpno3=mpartnum then
    mstat2:=mpno3;
    end if;
    if mpno4=mpartnum then
    mstat3:=mpno4;
    end if;
    if mpno5=mpartnum then
    mstat4:=mpno5;
    end if;
    if mpno1=mpartnum then
    mstat:='Y';
    orec.PartNo:=mpno1;
    orec.Description:=mdescription;
    orec.AIrcraft_type:=maircraft_type;
    orec.status_IPC:=mstat1;
    orec.status_ELOG:=mstat2;
    orec.status_SUPCAT:=mstat3;
    orec.STATUS_AIRODWH:=status_AIRODWH;
    end if;
    end loop;
    end;
    end if;
    end testsch2;
    end ioStructArray;
    Expecting your early reply.
    With thanks
    Pramod kumar.

  • Returning 2D array from a stored procedure

    hi,
    i'm trying to return a nested table from a procedure.can any one help me out i'm getting the fallowing error.
    SQL> ed
    Wrote file afiedt.buf
    1 declare
    2 TYPE data_t IS TABLE OF NUMBER
    3 INDEX BY PLS_INTEGER;
    4 TYPE array_t IS TABLE OF data_t
    5 INDEX BY PLS_INTEGER;
    6 array array_t;
    7 begin
    8 Sp_test(123,'12-jan-08',array);
    9 dbms_output.put_line(array (10) (1));
    10* end;
    11 /
    Sp_test(123,'12-jan-08',array);
    ERROR at line 8:
    ORA-06550: line 8, column 1:
    PLS-00306: wrong number or types of arguments in call to
    'SP_TEST
    ORA-06550: line 8, column 1:
    PL/SQL: Statement ignored
    The procedure is
    CREATE OR REPLACE PROCEDURE Sp_test(S_KEY NUMBER,V_DATE DATE, array_out OUT array_t) as....

    Below is the error i got when using the above suggestion.
    SQL> ED
    Wrote file afiedt.buf
    1 DECLARE
    2 TYPE data_t IS TABLE OF NUMBER
    3 INDEX BY PLS_INTEGER;
    4 TYPE array_t IS TABLE OF data_t
    5 INDEX BY PLS_INTEGER;
    6 begin
    7 Sp_test(123,'12-jan-08',array REPORT.ARRAY_T);
    8 dbms_output.put_line(array (10) (1));
    9* end;
    10 /
    Sp_test(123,'12-jan-08',array REPORT.ARRAY_T);
    ERROR at line 7:
    ORA-06550: line 7, column 32:
    PLS-00103: Encountered the symbol "REPORT" when expecting one of the
    following:
    . ( ) , * @ % & | = - + < / > at in is mod not range rem =>
    .. <an exponent (**)> <> or != or ~= >= <= <> and or like
    between ||
    The symbol "." was substituted for "REPORT" to continue.

  • Returning collection-associative array from pl-sql procedure

    CREATE OR REPLACE procedure test_ganesh( p_deptno IN number,gana out PARTIES_RESULT)
    is
    query varchar2(200);
    PARTY_ID varchar2(200);
    PARTY_CODE varchar2(200);
    PARTY_NAME varchar2(200);
    PARTY_SEQ VARCHAR2(200);
    counter number;
    TYPE PARTIES IS TABLE OF varchar2(2000) index by binary_integer;
    txn_parties PARTIES;
    type PARTIES_RESULT IS TABLE OF PARTIES index by binary_integer;
    total_result PARTIES_RESULT;
    TYPE EmpTyp IS REF CURSOR;
    p_du EmpTyp;
    p_cursor EmpTyp;
    global_counter number;
    begin
    global_counter:=1;
    counter:=1;
    open p_cursor FOR
    select A.ref_no
    from ot_lc_txn_details A
    where rownum <12;
    LOOP
    FETCH p_cursor INTO query;
    EXIT WHEN p_cursor%NOTFOUND;
    counter:=1;
    open p_du FOR
         select party_id,party_code,seq_no,party_name from ot_txn_party where ref_no=query;
         LOOP
         FETCH p_du INTO PARTY_ID,PARTY_CODE,PARTY_SEQ,PARTY_NAME;
         EXIT WHEN p_du%NOTFOUND;
         txn_parties(counter):=PARTY_ID || '&&&' || PARTY_CODE || '&&&'||PARTY_SEQ || '&&&' || PARTY_NAME;
              counter:=counter+1;
         END LOOP;
         CLOSE p_du;
    total_result(global_counter):=txn_parties;
    global_counter:=global_counter+1;
    END LOOP;
    CLOSE p_cursor;
    --open gana FOR SELECT * FROM table(cast(total_result as PARTIES_RESULT)) ;
    end;
    The error comes at line one, PLS-00905- object PARTIES_RESULT is invalid.
    i have used the create type thing to create this type.
    if i remove the out parameter it works, no compilation error.
    Questions i) How to return the associative array as out parameter?
    ii)Am i doing aynthing qrong here?
    iii) Can i open a ref cursor to this associative array and then return that ref_cursor?
    Please anyone reply back, Thanks in advance
    Message was edited by:
    user649602

    As an example:
    SQL> create type PARTIES is table of varchar2(2000);
      2  /
    Type created.
    SQL> create or replace procedure proc1(p_deptno number,gana out parties) as
      2  begin
      3   select ename
      4   bulk collect into gana
      5   from emp
      6   where deptno = p_deptno;
      7  end;
      8  /
    Procedure created.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Associative Array problem in Oracle Procedure

    Hi,
    I've searched through the internet and this forum and haven't been able to resolve a problem using associative array values within an IN clause. Everything I've read states that I can't use the associative array directly in the SQL statement. I have to convert it to a table and then I can use it. Unfortunately, I'm receiving an "ORA-21700: object does not exist or is marked for delete" error when trying to access the table I've populated from the array. Please note that I have verified the table is actually being populated during the loop. I'm catching the error when referencing it in the SELECT statement.
    I've declared the following in the ARCHIVE package specification:
    TYPE RSType IS REF CURSOR;
    TYPE integer_aat IS TABLE OF INTEGER INDEX BY PLS_INTEGER;
    TYPE integer_table IS TABLE OF INTEGER;
    The procedure is as follows:
    PROCEDURE SEL_SEARCH_RESULTS (v_term IN VARCHAR2,
    v_categories IN ARCHIVE.integer_aat,
    rs OUT RSType)
    AS
    /* PURPOSE: Return Search Results for the Category and Keyword Provided
    VARIABLES:
    v_categories = Document Categories array
    v_term = Keyword entered
    rs = Result Set
    tbl_cat ARCHIVE.integer_table := ARCHIVE.integer_table();
    BEGIN
    FOR i IN 1 .. v_categories.COUNT
    LOOP
    tbl_cat.EXTEND(1);
    tbl_cat(i) := v_categories(i);
    END LOOP;
    OPEN rs FOR
    SELECT A.ID,
    B.CATEGORY,
    A.FILENAME,
    A.DISPLAY_NAME,
    A.COMMENTS
    FROM TBL_ARCHIVE_DOCUMENTS A,
    TBL_ARCHIVE_DOC_CAT B,
    TBL_ARCHIVE_DOC_KEYWORDS C
    WHERE A.ID = B.ID
    AND A.ID = C.ID
    AND B.CATEGORY IN (SELECT * FROM TABLE(tbl_cat))
    AND C.KEYWORD = v_term
    ORDER BY A.ID;
    END SEL_SEARCH_RESULTS;
    Any help would be greatly appreciated and thanks in advance,
    Matt

    Thank you for the quick response. I looked at the example you suggested and made the following changes. Now I'm receiving an "Invalid datatype" error on the "SELECT column_value FROM TABLE(CAST(tbl_cat AS tbl_integer))" statement. I must be missing something simple and I just can't put my finger on it.
    PROCEDURE SEL_SEARCH_RESULTS (v_term IN VARCHAR2,
    v_categories IN ARCHIVE.integer_aat,
    rs OUT RSType)
    AS
    /* PURPOSE: Return Search Results for the Category and Keyword Provided
    VARIABLES:
    v_categories = Document Categories array entered
    v_term = Keyword entered
    rs = Result Set
    TYPE tbl_integer IS TABLE OF INTEGER;
    tbl_cat tbl_integer;
    BEGIN
    FOR i IN 1 .. v_categories.COUNT
    LOOP
    tbl_cat.EXTEND(1);
    tbl_cat(i) := v_categories(i);
    END LOOP;
    OPEN rs FOR
    SELECT A.ID,
    B.CATEGORY,
    A.FILENAME,
    A.DISPLAY_NAME,
    A.COMMENTS
    FROM TBL_ARCHIVE_DOCUMENTS A,
    TBL_ARCHIVE_DOC_CAT B,
    TBL_ARCHIVE_DOC_KEYWORDS C
    WHERE A.ID = B.ID
    AND A.ID = C.ID
    AND B.CATEGORY IN (SELECT column_value FROM TABLE(CAST(tbl_cat AS tbl_integer)))
    AND C.KEYWORD = v_term
    ORDER BY A.ID;
    END SEL_SEARCH_RESULTS;

  • How to pass a multidimensional array to an Oracle procedure?

    How can I pass a multidimensional array to oracle array?
    Thanx in anticipation,

    Look in to passing user defined type back and forth to Oracle. Any type that oracle supports, you can constract on the java side and send it across. Look into the SQLData class.

  • Calling Oracle 10g Stored Proc with Assoc Array from C# VS 2008

    I have the following PL/SQL procedure:
    CREATE OR REPLACE PROCEDURE HMA_ADM.PRC_VDM_SAVDEL_VEN_DOC
    P_OP IN VARCHAR2,
    P_USRID IN TB_VDM_MANAGE_DOCUMENTS.CREATEDBY%TYPE,
    P_DATE IN VARCHAR2, -- HAS TO BE STRING, ELSE WE GET AN ERROR
    P_DOCNAM IN TB_VDM_MANAGE_DOCUMENTS.DOCUMENT_NAME%TYPE,
    P_DOCLNK IN TB_VDM_MANAGE_DOCUMENTS.DOCUMENTLINK%TYPE,
    P_FNGUID IN TB_VDM_MANAGE_DOCUMENTS.FILENET_GUID%TYPE,
    P_DESC IN TB_VDM_MANAGE_DOCUMENTS.DESCRIPTION%TYPE,
    P_REQID IN VARR
    ) IS
    Where VARR is:
    CREATE OR REPLACE TYPE VARR IS TABLE OF INTEGER;
    In C# I have the following code:
    int64[] intReqID;
    OracleCommand cmdVDL = new OracleCommand(DBQueries.SPQRY_SAVDELVENDOC, connDB);
    cmdVDL.CommandType = CommandType.StoredProcedure;
    cmdVDL.Parameters.Add(new OracleParameter("P_OP", strOP));
    cmdVDL.Parameters.Add(new OracleParameter("P_CREATEBY", strUID));
    cmdVDL.Parameters.Add(new OracleParameter("P_CREATEDATE", strDate));
    cmdVDL.Parameters.Add(new OracleParameter("P_DOCNAM", strDocNam));
    cmdVDL.Parameters.Add(new OracleParameter("P_DOCLNK", strURL));
    cmdVDL.Parameters.Add(new OracleParameter("P_FNGUID", strGUID));
    cmdVDL.Parameters.Add(new OracleParameter("P_DESC", strDesc));
    cmdVDL.Parameters.Add(new OracleParameter("P_REQID", OracleDbType.Int64) {
    CollectionType = OracleCollectionType.PLSQLAssociativeArray,
    Size = intReqID.Count(),
    Value = intReqID,
    DbType = DbType.Int64,
    OracleDbType = OracleDbType.Int64
    OracleParameterStatus[] stat = new OracleParameterStatus[intReqID.Count()];
    for (i = 0; i < intReqID.Count(); i++) {
    stat[i] = OracleParameterStatus.Success;
    cmdVDL.Parameters["P_REQID"].ArrayBindStatus = stat;
    cmdVDL.ExecuteNonQuery();
    When I run this I get the following error:
    ORA-06550: line 1, column 7:
    PLS-00306: wrong number or types of arguments in call to 'PRC_VDM_SAVDEL_VEN_DOC'
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored
    If I remove the Associative Array from both, the procedure runs fine.
    What am I doing wrong?

    Additionally,
    1) UDT support requires 11106.20 or higher ODP (but can be used against 10g db)
    2) if the plsql is changeable, you may want to swap it to associative array instead to avoid having to create custom classes for the UDT, and here's a short sweet example.
    Greg
    CREATE or replace PACKAGE MYPACK3 AS
    TYPE numarray is table of number index by BINARY_INTEGER;
    PROCEDURE getempsinarray(thearray IN numarray, numrecs out number);
    END MYPACK3;
    CREATE or replace PACKAGE BODY MYPACK3 AS
    PROCEDURE getempsinarray(thearray IN numarray, numrecs out number)
    IS
    begin
      numrecs :=  thearray.count;
    END getempsinarray;
    END MYPACK3;
    using System;
    using System.Data;
    using Oracle.DataAccess.Client;
    public class indexby
         public static void Main()
          OracleConnection con = new OracleConnection("data source=orcl;user id=scott;password=tiger;");
          con.Open();
          OracleCommand cmd = new OracleCommand("mypack3.getempsinarray", con);
          cmd.CommandType = CommandType.StoredProcedure;
          OracleParameter Param1 = cmd.Parameters.Add("param1", OracleDbType.Int32);
          Param1.Direction = ParameterDirection.Input;
          Param1.CollectionType = OracleCollectionType.PLSQLAssociativeArray;
          Param1.Value = new int[3]{7369,7499, 7521};
          Param1.Size = 3;
          OracleParameter Param2 = cmd.Parameters.Add("param2", OracleDbType.Int32, DBNull.Value, ParameterDirection.Output );
         cmd.ExecuteNonQuery();
         Console.WriteLine("{0} records passed in",Param2.Value);               
          con.Close();
    }

  • Retrieving cursor from a stored procedure

    Hi,
    Is there any means to retrieve a cursor from a stored procedure using java.sql.* package, without using database specific type code like OracleTypes.CURSOR?
    Regards,
    Shalin.

    Hi,
    I had some across this problem some time ago. Although, there is no direct answer to this solution, there is a "kloog" that you can apply.
    Please note that the signature for registerOutParameter(int parameterIndex, int sqlType), and note that where ever sqlType is mentioned it is an int.
    Now JDBC is an interface and the implementation is given by Oracle. So to register an "out" parameter all you have to do is registerOutParameter(1, OracleTypes.CURSOR). It works!
    Or otherwise try and find out what the int value of CURSOR is and replace. This is because not all databases can support returning a "cursor" type, since ORACLE and few other databases have a concept of "STORED PROCEDURE" and PLSQL is specific to ORACLE.
    I hope this helps!
    Cheers,
    John.

  • PL/SQL Procedure and Java

    Hi All,
    I am working on a Data Warehousing Product and generating Web Reports.
    These Web Reports are JSPs.
    The basic architechture used for this is :
    1. Get the inputs required for Report Generation through a Web GUI
    2. Validate and Process (If Valid) the inputs so that it can be applied on the Data in the DB to fetch appropriate information.
    3. The Data from the DB is retreived in the form of PL/SQL Procedures, which take the Processed information from Step 2 as Input and give the Output in the form of REF CURSORS.
    Note: There are a many PL/SQL Procedures that are being executed, based on the configuration the Client has set. This configuration enables the Client to set the columns he wants to see in the Web Reports. This configuration is set before the Reports are run.
    4. A call is made from Java to Oracle, each time a PL/SQL Procedure need to be executed. The REF CURSOR received as an Output from the PL/SQL Procedure is processed.
    5. The next PL/SQL Procedure is called (if existing), else the Processed Data (from REF CURSOR Output) is displayed in the JSP as Web Reports.
    The issue with above architechture is the PERFORMANCE.
    I would like to know:
    - The various ways in which data can be EFFICIENTLY & QUICKLY retrieved from PL/SQL Procedure in Java.
    - Are there any APIs that improve the Java-Oracle Data Fetch Efficiency
    - Is there any Java Framework available that can be used to increase the spped of Web Report generation.
    - Do you suggest any changes in the above mentioned architechture, that make this work a Sweet Sixeen Year olg guy! ;)
    - In general, any input that can increase the Speed of Web Report Generation.
    Kindly let me know if I have not been clear at any point, so that I can re-explain the same more clearly.
    And the most important thing, kindly scrap down your thoughts about the same.
    Thanks a lot in advance for your VALUABLE INPUTS.
    - Vikas

    Spring
    http://www.springframework.org/
    http://static.springframework.org/spring/docs/2.0.x/reference/jdbc.html
    http://static.springframework.org/spring/docs/2.0.x/reference/jdbc.html#jdbc-StoredProcedure

  • Handling a List returned from a Stored Oracle Procedure

    I'm trying to put a PL/SQL oracle wrapper around some post code lookup
    software.
    We're planning to get the wrapper to return a List and then JDBC to handle this list.
    Has anyone already done/attempted to do this? Does anyone know if it can be done using a List and can oracle stored procedures return a List?

    It appears that Oracle does support an array type:
    In Oracle
    CREATE OR REPLACE FUNCTION getEmpArray RETURN EMPARRAY
    AS
    l_data EmpArray := EmpArray();
    CURSOR c_emp IS SELECT ename FROM EMP;
    BEGIN
    FOR emp_rec IN c_emp LOOP
    l_data.extend;
    l_data(l_data.count) := emp_rec.ename;
    END LOOP;
    RETURN l_data;
    END;
    In Java
    public static void main( ) {
      OracleCallableStatement stmt =(OracleCallableStatement)conn.prepareCall
                    ( "begin ? := getEMpArray; end;" );
        // The name we use below, EMPARRAY, has to match the name of the
        // type defined in the PL/SQL Stored Function
        stmt.registerOutParameter( 1, OracleTypes.ARRAY,"EMPARRAY" );
        stmt.executeUpdate();
        // Get the ARRAY object and print the meta data assosiated with it
        ARRAY simpleArray = stmt.getARRAY(1);
        System.out.println("Array is of type " +  simpleArray.getSQLTypeName());
        System.out.println("Array element is of type code "+simpleArray.getBaseType());
        System.out.println("Array is of length " + simpleArray.length());
        // Print the contents of the array
        String[] values = (String[])simpleArray.getArray();
        for( int i = 0; i < values.length; i++ )
          System.out.println( "row " + i + " = '" + values[i] +"'" );
    This was taken from:
    http://otn.oracle.com/sample_code/tech/java/codesnippet/jdbc/varray/index.html

  • Passing pl/sql variable to oracle procedure from java

    Dear
    Sir/madam
    From java its easy to call procedure or function to get pl/sql variables like cursor type or varray type and cast back to that equi type thro' oracle extn package.Is there any way it could be done vice versa.Can i pass Oarcles Pl/SQL datatype like collection Of type Varray/Custom Object or Cursor,Array type to a procedure or function from java program.Is it possible to pass like that.If so could you kindly give a samll eaxample or URL where same type of example could be found
    regards
    kingshuk

    Dear
    Sir/madam
    From java its easy to call procedure or function to get pl/sql variables like cursor type or varray type and cast back to that equi type thro' oracle extn package.Is there any way it could be done vice versa.Can i pass Oarcles Pl/SQL datatype like collection Of type Varray/Custom Object or Cursor,Array type to a procedure or function from java program.Is it possible to pass like that.If so could you kindly give a samll eaxample or URL where same type of example could be found
    regards
    kingshu i suggest to read JPublisher doc - it help support or convert PL/SQL types in Java
    http://otn.oracle.com/docs/products/oracle9i/doc_library/release2/java.920/a96658.pdf
    Kuassi

  • Oracle Array from J++

    I am trying to access oracle array from J++ and couldn't have any luck. Can any one help me and show me some code. i want to access array (String array) from oracle stored procedure using j++ . thanks
    [email protected]

    I'm able to send arrays from flex but to a web service
    written in ASP.Net, i dont know i this could help you.

  • Pass arrays from Java to PL/SQL procedure.

    Hi All,
    Can some body give an example, where an array of strings is passed from java to a PL/SQL procedure.
    Any help in this regard is appreciated.
    Thanks,
    Prashant

    Kiran Kumar Gunda wrote:
    I would want to use Oracle provided (Oracle Extensions) API to pass arrays to PL/SQL
    procedure from Java. I am using weblogic connection pool, but the 'createDescriptor'
    method donot allow Pooled connection. So I have taken Physical Connection by casting
    to 'WLConnection'. Now, weblogic strongly suggest NOT to use this,as pooling capabilities
    will be disabled.
    But by setting RemoveInfectedConnectionsEnabled to false, we can ask weblogic
    to return the Physical Connection to Pool. I have tested this with the attached
    code. I DON'T find any issue.Good. The only real risk to obtaining the physical connection is retaining and
    using it beyond the current thread execution. Your code looks OK. The only thing
    I'd suggest is to add to the finally block. I would put a separate try-catch-ignore
    block around every action in the finally, so if one fails, the others are still
    done.
    As long as you're writing good JDBC like that, there is no risk to telling the
    pool to trust the code, by setting RemoveInfectedConnectionsEnabled to false.
    That way you'll retain all the performance of the pools.
    Joe
    >
    I want your opinion in this, so that I will be confident in using this feature
    in our application.
    Note : Please look at the sample code that I am using. I AM NOT GOING TO USE PHYSICAL
    CONNECTIONS for normal operations. I will use Physical Connection only when I
    want to pass Arrays to Oracle.
    Thanks
    Kiran

  • BO v5.1 - creating a report from an oracle stored procedure

    Post Author: newrochelle
    CA Forum: Publishing
    hi to all,
    im using BO 5.1 and i need to create a document from an oracle stored procedure that have only one IN parameter and ten OUT parameters.
    Creating the new report I selected the database connection then I choose the stored procedure name from the list, I inserted the value for the IN parameter and finally I click on Run button.
    I got the following error message:
    ORA-06550: line 1, column 38: :PLS-00103: Encountered the symbol
    "," when expecting one of the following: : : ( - + case mod
    new not null others <an identifier> : <a double-quoted
    delimited-identifier> <a bind variable> avg : count current
    exists max min prior sql stddev sum variance : execute forall
    merge time timestamp interval date : <a string literal with
    character set specification> : <a number> <a single-quoted SQL
    string> pipe : <an alternatively-quoted string literal with
    character set specification> : <an alternatively-q :-6550
    it seems to be caused by the OUT parameters!
    i leaved them without any value.
    it's the first time that I used a stored procedure to create a BO report, but I think the OUT parameters are needed to do that, otherwise what data will be presented in the report???
    can you help me?
    please answear me ASAP.
    Thank's in advance
    Regards
    Andrea

    Post Author: synapsevampire
    CA Forum: Publishing
    Try posting in a BO forum, this is Crystal Reports.
    -k

Maybe you are looking for

  • Nokia X6 - Cannot see contact number in text messa...

    Hi all, When I am sending a text message, I cannot see the contact telephone number in the To: field. Is there a setting somewhere that I have missed ? In my previous nokia phones, you can always see the contact name and the number you are using. Tha

  • Scenario in which Conversation ID will not get generated

    Hi all, I have a requirement wherein i need to capture the conversationID for logging purpose from my BPEL processes. However i have noticed that ora:getConversationId() is giving me NULL sometimes. Could anyone tell me what are the scenarios where c

  • Does New Flash conflict with Gmail & YouTube ???

    I installed the Master CS 5 Beta today and noticed two puzzling differences in my computer. (Besides requiring over 15 gigabytes of hard drive !) First - The Advanced document attachment features in Gmail and the ability to see progress bars when att

  • Max. No. of infobjects

    Hi experts What is the maximum no. of infoobjects can we accommodate in a cube? and what is the maximum no. of characterestics can have for a dimension? Thx a lot in advance Surya

  • Pen Tool - autocreate layer?

    I've been using Photoshop for about a decade now and I have yet to experience a problem like I'm having now with the pen tool. When you place your first node, it makes a layer... but in CS4 (or at least my version) it isn't. I can create the entire s