How to create Array type parameter of Oracle 10.2.0.1.0 in java

I create a collection type with:
CREATE OR REPLACE
type TEST_User.T_ARRAY AS TABLE OF VARCHAR2(100);
and in java code, I use following code to create a parameter of this type, and set it for a procdure
String[] userMakeArray = new String[]{"V", "N", "A"};
oracle.sql.ArrayDescriptor descriptor = oracle.sql.ArrayDescriptor.createDescriptor("TEST_User.T_ARRAY", cn); // cn is connection instance to database
oracle.sql.ARRAY array = new oracle.sql.ARRAY(descriptor, cn, userMakeArray);
((oracle.jdbc.OracleCallableStatement)call).setArray(8, array);
when i use this to call procedure in Oracle 10.1, it work well.
In Oracle 10.2, it does not work well.
For test, I can execute procedure well in sql plus, but in java client, I found that array contains three items "Null", while array is correct when conect to 10.1 enviroment.
does anybody know what's the reason for this.
thanks a lot.

Hi,
Too long to copy/paste here but i have a simpler working example of Nested Table of VARCHAR2 type against 10.2.0.x, in chapter 3 and 8 of my book:
create or replace type NTab_Vc2 as TABLE of varchar2(30)
create table NSTableTab (id int, numnt NTab_Num, vc2nt NTab_Vc2, datnt
NTab_Dat)
nested table numnt store as NSTabNum,
nested table vc2nt store as NSTabVc2,
nested table datnt store as NSTabDat;
insert into NSTableTab values (1,
NTab_Num(1, 2, 3, 4, 5, 6, 7, 8, 9, 10),
NTab_Vc2 ('One', 'Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight', 'Nine', 'Ten'),NTab_Dat('01-JAN-2003', '02-JAN-2003', '03-JAN-2003', '04-JAN-2003',
'05-JAN-2003', '06-JAN-2003', '07-JAN-2003', '08-JAN-2003',
'09-JAN-2003', '10-JAN-2003')
// The following code snippet retrieves and returns a
// NTab_Vc2 as a java.sql.Array
OraclePreparedStatement ps = (OraclePreparedStatement)
conn.prepareStatement ("SELECT VC2NT FROM NSTableTab
WHERE ID = ?");
ps.setNUMBER (1, id[0]);
OracleResultSet rs = (OracleResultSet) ps.executeQuery();
Array a = null;
while (rs.next())
a = (Array) rs.getObject(1);
ps.close();
return a;
Kuassi, http://db360.blogspot.com/2006/08/oracle-database-programming-using-java_01.html

Similar Messages

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

  • How to use array as parameter in procedure

    Hello,
    I am using Oracle SQL Developer 1.5.5
    I wanted to write a procedure which does insert into table.
    It should take 2 parameters.How to take array as parameter?
    One is a array of strings ('abc','def','erg') and another is a varchar ('abc').
    How to do this?
    Can somebody pls give a small example?
    Thanks
    Edited by: user13305573 on Aug 5, 2010 11:27 PM

    Hello,
    I am sorry if u didnt get my point.
    My req is i am using Orcale SQL Developer.
    Db is Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
    I want to write a procedure which will be called from a java file.
    The parameter to that procedure will be a arr(array of strings) and username(varchar).
    I want to insert that data into a tableA.
    like if parameters are
    (abc01,edfg02,efg03) as arr and honey as username
    then it should insert 3 rows to the tableA
    abc01 honey
    edfg02 honey
    efg03 honey
    Thanks
    Edited by: user13305573 on Aug 5, 2010 11:54 PM

  • How to create a system  parameter in Apex

    Hi friends,
    I am new to Oracle Apex and need to know how to create a System Parameter in Apex. Kindly let me know how to add one.
    Regards,
    Pradeep

    bluerose wrote:
    I am new to Oracle Apex and need to know how to create a System Parameter in Apex. Kindly let me know how to add one.
    using the privileges we can achieve this.Although I am not new to APEX I have no idea what you are talking about.
    What is "a System Parameter in Apex"? What "privileges" are used to create one?
    You'll find it easier to get help if you use terminology that is familiar to everyone...

  • How to create ''from to '' parameter in XL reporter for templates

    Hi,
    How to create ''from to '' parameter in XL reporter for templates
    Can anyone help me in this regard
    thanks,
    Suresh Kannan

    Suresh,
    1. Goto Report Designer
    2. there u can find "Advanced Report Builder" on left side of the window
    3. At the below u can find three buttons like "Parameters", "Properties","Apply"
    4. Click on "Parameters"
    5. then Parameters window will populate
    6. Click the new Button
    7. Name: give as u like
    Category: Literal
    Type: Date
    Attribute: Leave blank
    Default Vale: Leave Blank
    Prompt: From Date
    This is the process to create the parameters.

  • How to create a type

    hi,
    can anybody tell me how to create a type where in we can execute a procedure, every time we call it.

    Hello,
    What is your exact product version ?
    Are you sure there is any relation woith the Oracle Forms product ?
    Francois

  • How to create a custom plugin in Oracle Access Manager to create a cookie

    How to create a custom plugin in Oracle Access Manager to create a cookie or Header Variable..
    Vipin

    Its has more steps which you need to consider in addition to Note:101048.1 which is mentioned by Prashant_Pathak. Both notes have enough information. If not, let's know what else you need to set

  • How we create new data base in oracle 10g express edition

    hello every body.. i student of B tech n new user of oracle so please help me how we creat new data base in oracle 10g express edition

    Hello, Oracle XE can not create more than one instance, the other editions yes, but like other editions XE allows you to create database schemas, schemas logically grouped objects like tables, views, indexes created by a user. By creating an Oracle user is associated with a schema of the same name.
    Using SYS or system accounts for creating user accounts.
    Syntax to create a user:
    create user Your_user
    IDENTIFIED BY password
    default tablespace users;
    grant connect, resources to your_user;
    Edited by: rober584812 on Jun 25, 2010 9:03 PM

  • How to create a learning  certification in oracle learning management

    Hi all,
    can any body know how to create a lerning certification in oracle learning management.
    thank you.

    Hi,
    Please refer to [Oracle Learning Management User Guide |http://download-uk.oracle.com/docs/cd/B25516_14/current/acrobat/115olmug.pdf], Page 2-13 Learning Certications.
    Regards,
    Hussein

  • How To Creating A Object Libraries In Oracle Forms 6i

    hi
    All
    I Not No How To Creating a Object Libraries In Oracle Forms 6i
    How To Add Your Pl/sql Block In a Lib
    But What Is Use it is i Know , So I Want To Creating a Object Libraries.
    So Any One Have A Idea Plz Help Me.

    Hi,
    there is a good paper:
    http://www.quovera.com/whitepapers/downloads/102_doc.zip
    http://www.quovera.com/whitepapers/downloads/102_ppt.zip
    Best,
    Friedhold

  • How to create SCD2 type manually in informatica?

    Please Can you describe with example how to create SCD2 type manually in infromatica?

    Hi Manoj,
    You should not delete the auto generated orchestration even do not modify it, as it is stated in msdn.
    The BizTalk WCF Service Consuming Wizard creates in your BizTalk project the BizTalk schemas and types necessary to consume WCF services. The BizTalk types such as port types and multipart message types are created in an orchestration. We recommend
    that you do not modify the orchestration that the wizard creates. Instead, you can add new orchestrations in the BizTalk project for your purposes.
    --------- MSDN
    For Refernce
    In your solution, if you are seperating your schemas project from orchestration project, in that case i personally advise to generate wcf endpoint in your schema project and after adding schema reference in orchestration
    project you manually create the multipart message and a request response port as it will not display in existing port.
    Regards

  • How to create Activity type

    How to create Activity type
    below are the details
    x sales MnF Expenses
    y FMS MnF Expenses

    dear sudhir
    KA01 - Create Primary Cost Element for the new activities type.
    KL01 - Create Activity Type tied to the primary cost element.
    regards
    rohit

  • How to create output type for GR,GI?

    Can any one explain,How to create output type for Goods Receipt,Goods Issue.?
    and How to take print out for both?

    Hi, jayant in standard u have output type for picking list, delivery doc complete, theres no output type seperately for PGI or PGR
    I am sure u need the help of tech guy to create the new output type for ur requirement
    regards
    giri

  • How to create a hidden parameter in a 11.1.1.6 BI Publisher Report

    We are in the process of migrating from BI Publisher 10g to 11.1.1.6. We used the Upgrade Assistant to migrate a couple thousand reports to the new 11g server. Most of the reports seem to be working fine, but some need some adjusting.
    In 10g, there was an option to make a parameter with a type of "Hidden". Most of our reports have at least one parameter that is hidden. The hidden parameters are functional in the converted reports on the 11g server. But, when I want to modify a parameters on 11g or create a new parameter, there is no option to make the parameter hidden. I performed several web searches on the topic, but came up with nothing. I searched the report developer's guide. Nothing.
    So, how does one create a hidden parameter in BI Publisher 11g?

    Our team is researching the same thing, we have review all the documentation and not found anything helpful. Have you made any progress?

  • How to create SSWA plsql function in Oracle Apps of HTML call .html

    Hello Team,
    I am working on Oracle Apps 11i (11.5.10.2)
    I want to know , what is the process to create a , "SSWA plsql function" in Oracle Apps of type "HTML" and html call tab.
    How to create that Function and how to attach the PL/SQL code to these functions.
    How it works.
    Please help me to understand this concept from basics.
    Kind Regards

    Hi;
    Please review:
    how to setup a forms function in R12 to launch an URL?
    http://www.trutek.com/serendipity/index.php?/archives/15-An-Example-of-How-to-Create-Custom-Functions,-Menus,-and-Responsibilities.html
    Regard
    Helios

Maybe you are looking for