Using arrays as type for bind variable

Hi all,
I have this stored procedures that takes an array of strings as an argument:
CREATE OR REPLACE PACKAGE mypackage AS
TYPE StringArray IS VARRAY(100) OF VARCHAR2(16);
PROCEDURE doSomething(v_strings IN StringArray);
END;
My java code looks something like:
String[] strings = ...;
CallableStatement cs = connection.prepareCall("CALL mypackage.doSomething(?)");
cs.setObject(1, strings, java.sql.Types.ARRAY);
calling the setObject method throws a SQLException: invalid column type.
I have tried to change the call to:
cs.setArray(1, new SqlStringArray(strings))
where SqlStringArray is a wrapper around String[] that implements the java.sql.Array interface. This however throws a ClassCastException in oracle.jdbc.driver.OraclePreparedStatement. The latter is assuming it is receiving a class that implements yet another interface I guess.
I also tried:
cs.setObject(1, strings, java.sql.Types.VARCHAR);
but that also throws a SqlException: invalid conversion requested
Does anybody know how to bind String[] into a PreparedStatement?
Any help is appreciated.
Rudi.

Made some progress. I am getting the OracleConnection from the WrappedConnection. This is a temporary solution for me so I would appreciate a final solution from anybody.
I am now constructing a oracle.sql.ARRAY with an appropriate oracle.sql.ArrayDescriptor. I have found out that the type must be defined on a global level rather than in the scope of the package. Would be good if an Oracle expert could confirm that but I am happy to live with that.
The IN parameter is correctly bound using the ARRAY instance but I am getting the following error when actually executing the statement:
ORA-06512: Reference to uninitialized collection: at "BLUETEST_MYPACKAGE", line 57
Now I have found quite some problem descriptions with that ORA error but all are dealing with OUT parameters that were not correctly initialized, i.e. the array constructor had not been called. In my case however, the array is initialized at by the java code and then bount to the sql statement. You would expect that the jdbc driver takes care of correctly initializing the PL/SQL collection wouldn't you.
Does anybody know if I need to do anything extra?
Many thanks,
Rudi.

Similar Messages

  • How to use a collection type of bind variable for execute dynamic statement

    Hi,
    We have a case where we copy selective data from Schema A To Schema B in one oracle database. The copy is achieved by using
    execute immediate 'insert into '||target_schema||'.tablea select * from '||from_schema||'.table a where a.id in (select test_id from '||from_schema||'.table c);';
    This works fine it takes an average of 10 seconds to copy around 14 tables. We have a requirement to bring this time to 2 seconds. One observation has been the clause
    "select test_id from '||from_schema||'.table c" in the above sql statement repeats for many inserts . Thus we were thinking to bulk fetch this set of tests ids and use a bind vatiable of collection type for the execute immediate clause. Any suggestions on how to achieve it?
    Thanks,
    Chandana

    >
    One observation has been the clause
    "select test_id from '||from_schema||'.table c" in the above sql statement repeats for many inserts
    >
    So what? Constructing a string for a table level insert and parsing it can't possibly be a performance problem. If you were creating a string in a loop to insert rows into a table by getting the data FROM a collection - that's a problem that keeps showing up in the forums.
    I'm with bravid and Nikolay on this one. First find out which side, select/insert, the problem is on.
    As they said you need to provide more information about the process.
    And using collections for your use case is definitely not the thing to do.
    1. How many rows are we talking about?
    2. Are the rows being inserted into an empty table?
    3. Are you running these queries during peak production hours or in a batch windows?
    Tune the SELECT if the problem is on that side.
    Post an execution plan for the SELECT part of a query you think should run faster.
    SET SERVEROUTPUT ON
    SET AUTOTRACE TRACEONLY
    SQL> select * from emp;
    Execution Plan
    Plan hash value: 3956160932
    | Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT  |      |    14 |   546 |     3   (0)| 00:00:01 |
    |   1 |  TABLE ACCESS FULL| EMP  |    14 |   546 |     3   (0)| 00:00:01 |
    SQL>On the INSERT side you might be able to use bulk inserts
    ALTER TABLE myTable NOLOGGING;
    INSERT /*+ append */ INTO myTable . . .
    ALTER TABLE myTable LOGGINGIf the insert tables are always reused you could just leave them as NOLOGGING. Since you can't recover bulk data you need to make sure to get a good backup after the loads if you need to recover the data from the logs rather than just reload it yourself.

  • How to use function v( ) for bind variable 30 char

    I have the following process, try to load columns from table to the page. One of the column complains about > 30 char cannot use bind variable. I change to
    V('c1.OBJ_OUT_SOURCIING_WAD_TYPE') but still not work.
    Please help;
    BEGIN
    FOR c1 in ( SELECT *
    FROM #OWNER#.OBJECT_OUT_SOURCING
    WHERE OBJ_NAME = :P503_OBJ_NAME AND
    OBJ_OWNER = :P503_OBJ_OWNER AND
              DATABASE_NAME = :P503_DATABASE_NAME)
    LOOP
    :P503_OBJ_NAME := c1.OBJ_NAME;
    :P503_OBJ_OWNER := c1.OBJ_OWNER;
    :P503_DATABASE_NAME := c1.DATABASE_NAME;
    :P503_APPL_NAME := c1.APPL_NAME;
    :P503_OBJ_TYPE := c1.OBJ_TYPE;
    :P503_OBJ_OUT_SOURCIING_WAD_TYPE := V('c1.OBJ_OUT_SOURCIING_WAD_TYPE');
    END LOOP;
    END;

    Che-Hwa,
    Change this statement:  :P503_OBJ_OUT_SOURCIING_WAD_TYPE := V('c1.OBJ_OUT_SOURCIING_WAD_TYPE'); to:  htmldb_application.update_cache_with_write(p_name=>'P503_OBJ_OUT_SOURCIING_WAD_TYPE',p_value=>c1.P503_OBJ_OUT_SOURCIING_WAD_TYPE);Scott

  • Search parameter type with bind variable

    For Search type parameter in Oracle BI Publisher, if the List of values (SQL Query) contains bind variable, then application keep on searching. Any suggestions ?.
    Thanks in advance.
    Edited by: 966132 on 17-Oct-2012 22:23

    I don't think the search-type parameter works properly. It doesn't seem to function in our OBIEE 11g (11.1.1.5 + BP3). When you use a query that retrieves both the descriptive string and the numeric ID, the search box does correctly show the descriptive string. However, after selecting one of the choices, the actual data query returns nothing.
    Furthermore, the extra steps required to search take longer than scrolling through a very long list of values, the normal way. Good idea, bad implementation, no surprise.

  • How to use List of values with bind variables on item?

    Hi
    I made a dynamic list of values with a bind variable as a provider. I tried to run the list, and it worked fine - i filled inn the bind variable when asked for, and i got a list of values to choose from.
    I would very much like to use this list of values as an attribute on a custom made item. My wish is that when creating the item you someplace write the bind variable, and the list will then turn up as wanted. (I could f.ex add the variable as an attribute on the page type)
    I tried to create a custom attribute and assign the list of values to it. It created an error when I then tried to add the attribute to the item.
    Does anyone have any idea on how to solve this?
    Any help appreciated!
    Maja R. Anjer

    Hi
    i am getting error as
    oracle.apps.fnd.framework.OAException: oracle.jbo.SQLStmtException: JBO-27122: SQL error during statement preparation. Statement: SELECT * FROM (SELECT meaning, lookup_code,lookup_type
    FROM fnd_lookup_values
    WHERE view_application_id = 200) QRSLT WHERE (lookup_type=:1 AND ( UPPER(MEANING) like :2 AND (MEANING like :3 OR MEANING like :4 OR MEANING like :5 OR MEANING like :6)))
    Thanks
    Mateti

  • Asking for bind variable where none is needed

    Good Morning,
    I am still working these regexp date_time project.
    I have a problem where oracle is asking for a bind variable where it doesn't need any as far as I can see. I am trying to capture various date times in a column and formatting them into one default format used by oracle. Here is what I got which works before I wrap it in the TO_DATE function
    There are many when then's but I am using only one here.
    select case
    when regexp_substr(date_time,'^(0?[1-9]|1[0-2])/(0?[1-9]|[1-2][0-9]|3[0-1])/9[[:digit:]]{4}') is not null
    then regexp_substr(date_time,'^(0?[1-9]|1[0-2])/(0?[1-9]|[1-2][0-9]|3[0-1])/9[[:digit:]]{4}')
    else date_time
    end as new_time
    from raw_data;
    The above statement works
    Now when I want to format the date that I found with this:
    select case
    when regexp_substr(date_time,'^(0?[1-9]|1[0-2])/(0?[1-9]|[1-2][0-9]|3[0-1])/9[[:digit:]]{4}') is not null
    then TO_DATE('regexp_substr(date_time,'^(0?[1-9]|1[0-2])/(0?[1-9]|[1-2][0-9]|3[0-1])/9[[:digit:]]{4}')','MM/DD/YYYY')
    else date_time
    end as new_time
    from raw_data;
    I get a request to insert a value for the digit as a bind variable. The digit should be populated from the when statement when it returns not null when a date is found.
    Could some one please tell me even if what I wrote here is even possible or make a suggestion to the syntax to get around this issue?
    All this is going to be incorporated into an update statement later on.
    I am running this on sql developer, oracle 11g.
    Thanks for your help in this matter in advance.
    regards,
    Al

    From looking at the code, as you have not supplied any scripts to create a table and demonstrate the error...
    Your case statement is trying to return two types
    select case
    when regexp_substr(date_time,'^(0?[1-9]|1[0-2])/(0?[1-9]|[1-2][0-9]|3[0-1])/9[[:digit:]]{4}') is not null
    then TO_DATE('regexp_substr(date_time,'^(0?[1-9]|1[0-2])/(0?[1-9]|[1-2][0-9]|3[0-1])/9[[:digit:]]{4}')','MM/DD/YYYY')
    else date_time
    end as new_time
    from raw_data;or simply
    select case when <expr>
                then <RETURN A DATE>
                else <RETURN A VARCHAR2>
            end as new_time
      from raw_data;The column cannot be both.
    Sorry I don't know your requirements.
    You could drop the else part and just return the converted date.
    You could fetch it back in two columns, the ones you can convert in one column (Which would be an oracle date type),
    the ones you cannot convert in another (which would be varchar2).
    Cheers,
    GP>

  • Simple Q about using a List in a bind variable

    Using jDev 11.1.1.3, still new to this ADF stuff
    In my UI i have a shuttle component that allows the user to move x number of items to the right pane. Each one of these items becomes part of a filter in a where clause of a query on my VO. Can I do this with a bind variable instead of constructing the where clause progromatically?
    I need to accomplish this: vo.setWhereClause(attribute = 'w' OR 'x' OR 'y' OR 'Z'), where the list of params is dynamically generated in the UI.
    Is there a way i can feed a List to a bind variable? Maybe I can use View Criteria to do this?
    Thanks a lot.

    You should use "IN" clause for this scenario:
    Take a look at this blog post that describes the usage -
    http://jobinesh.blogspot.com/2010/09/using-bind-variable-for-sql-statements.html
    Thanks,
    Navaneeth

  • How to use array or type in "IN" criteria

    Hi all,
    anybody knows how to use group of same datatype data ( array or type ) in SQL statement
    For example
    ls_dept[1] = 'abc';
    ls_dept[2] = 'xyz';
    ls_dept[10] = 'ppr';
    i want to use this group of data in "IN" criteria like
    Select * from department where dept in ('abc','xyz'.....''ppr');
    if anybody know how to use please reply me as soon as possible.
    Thanks,

    I hope you are not suggesting concatenating literals from a web front-end application ;) Is it not what he was saying.. he is getting user input info from an application.. if the user sends multiple values.. he has to build a string with concatenating literals..
    correct me if I am wrong.

  • [SOLVED]how to use a VO that has bind variables in a Tree

    Hi,
    I have 3 view objects that I have linked using ViewLinks.
    My last object - the details is based on a View Object that takes in a bind parameter for use in its where clause.
    Originally when I used this View Object I could set this where clause by creating an ExecuteWithParams action in the page on the Iterator and set an executeable to invoke this when the page loads. This worked fine in the non-tree version.
    However when you use a Tree only the master collection gets turned into an iterator in the page def. Therefore I cannot invoke an ExecuteWithParams and set my bind variable in this way.
    How can I set my bind variable on the view object declaratively ? If it is not possible and I have to do it programmatically then where should I do this - I presume it would have to be in a method that the tree has ?
    thanks in advance.
    Message was edited by:
    Dom

    Hi,
    My Employees equivalent table is actually a xref table.
    It is like this :
    Master table = Skills
    This has a self join so a skill can have a master skills (I guess a bit like MGR)
    So I have 2 views on the skills - one for the top level skills and one for all ones below it.
    Then I have my last VO which is employees_skills_xref. This is a xref to the skills table and can hold many rows - so an employee could have many entries under the Skill names "Oracle technologies" - eg "PL/SQL, SQL, Portal etc"
    the Where clause for this xref VO has to take in the employeeId so that it only returns those rows that pertain to the user.
    This empId is stored in a managed bean,
    hth

  • Using BigInteger as type for JavaFX property

    Hello,
    Why is BigInteger not a legitimate type for a JavaFX property?
    Is there a way for me to use a java.math.BigInteger as shown below:
    class HomePhone
    BigInteger landLine1 = 0
    BigInteger landLine2 = 0
    } // end class HomePhone
    Thank you very much.

    Why is BigInteger not a legitimate type for a JavaFX property?Because it does not implement the JavaFX property interface:
    http://docs.oracle.com/javafx/2/api/javafx/beans/property/Property.html
    You could fit your phone numbers in an IntegerProperty or LongProperty, which have maxvalues of 2147483647 and 9223372036854775807 respectively or you could use a SimpleStringProperty.
    One could make a high quality BigIntegerProperty with a bit of work. To do a full implementation of property management for BigIntegers which handles expressions, type conversions, etc, requires quite a few classes. For example, you can see some of the hierarchy implemented to enable rich Double properties - something similar could be created for BigInteger - a feature request could be created at http://javafx-jira.kenai.com.
    java.lang.Object
    javafx.beans.binding.NumberExpressionBase
    javafx.beans.binding.DoubleExpression
    javafx.beans.property.ReadOnlyDoubleProperty
    javafx.beans.property.DoubleProperty
    javafx.beans.property.DoublePropertyBase
    javafx.beans.property.SimpleDoubleProperty

  • Best Index type for low variability columns like Country or LastName

    Hi, 
    What would be best Index to use on Low variability columns like Country or LastName in SQL Server.
    I think BitMap index we can use only on columns where we can have two possible value like male/female.

    basically I was trying to figure out if there is any kind of Indexes in SQL Server which have special design for low variability column. 
    my example queries like :  select a,b,c from table t where country = 'USA'
    Hi Eshant,
    In your scenario, you need to know which index is the best Index to use on Low variability columns like Country or LastName in SQL Server. As per my understanding, the performance not only related to the types of index on that column, but also related
    to the records on your table.
    Here is blog which tests the performance for different types of index on variability column like lastname, please refer to the link below.
    http://www.codeproject.com/Articles/234399/Database-performance-optimization-part-Indexing
    Regards,
    Charlie Liao
    If you have any feedback on our support, please click
    here.
    Charlie Liao
    TechNet Community Support

  • Stored Outline for Bind Variable

    Hi,
    Please let me know the use of stored outline to maintain the same execution plan for a sql which contains bind variable.
    I know how to use stored outline for a sql which does not contain bind variable. But I want the use of stored outline for sql where bind variables have been used. Please provide an example.
    Thanks,
    Mrinmoy
    Edited by: user3001930 on Aug 10, 2010 11:22 PM

    Not sure as I don't use them myself, but on AskTom:
    http://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:1396058400346694178
    He says:
    >
    stored outlines are deprecated in 11g - replaced by query plan baselines.
    http://download.oracle.com/docs/cd/B28359_01/server.111/b28318/sqlplsql.htm#sthref2589

  • Using RB00 condition type for Price Adjustment

    Hi,
    I have to do a price adjustment due to some rounding issues in the pricing of my sales order.(Using standard Pricing Procedure RVAA01). I am thinking of using manual condition type RB00 at Item level that can accept both positive and negative values depending on the situation.
    If the calculated value>expected value then the user will enter negative RB00 value manually and
    if the calculated value<expected value then the user will enter positive RB00 value manually.
    The account key is however different in standard Pricing procedure for RB00 and it is ERS and for standard Base Price (PR00) it is ERL.
    So, my question is that does that make any difference if I maintain condition records in VKOA for RB00 same as PR00?

    Hi
    If you are looking for rounding then you round the decimals by not maintaining any decimals.But if it is a price adjustment then your approach is correct
    If it is VK11 then there is no need to maintain condition record for RB00 as it is a manual condition type at item level
    If you are talking to maintain revenue account determination VKOA then you have to maintain as whenever you give discount then it will hit some G/L account .So you should assign a G/L account also
    Regards
    Srinath

  • Prompt for bind variables in SQL developer

    Hi!
    Just installed the latest 3.2 version of SQL Developer, and tried to do an explain plan.
    Now the tool prompts me for values for the bind variable. It didn't do that in my previous version (version 3. something).
    Thats anoying :-)
    How do I disable that feature?
    Example:
    explain plan for
    select * from emp
    where department_id = :1;
    If i right click on the statement or press F10, I get no prompt for the bind variable...
    Regards
    Søren

    Old fashioned way, like this:
    EXPLAIN PLAN FOR
    SELECT * FROM scott.emp
    where deptno = :1;
    SELECT PLAN_TABLE_OUTPUT FROM TABLE(DBMS_XPLAN.DISPLAY());
    Executed with F5 gives me this output
    plan FOR succeeded.
    PLAN_TABLE_OUTPUT
    Plan hash value: 3956160932
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
    | 0 | SELECT STATEMENT | | 5 | 190 | 3 (0)| 00:00:01 |
    |* 1 | TABLE ACCESS FULL| EMP | 5 | 190 | 3 (0)| 00:00:01 |
    Predicate Information (identified by operation id):
    1 - filter("DEPTNO"=TO_NUMBER(:1))
    13 rows selected

  • Groovy for bind variable

    hi all
    i have a master detail detail page
    a b c
    a as form
    b as table
    c as table
    in c i have LOV with a bind variable which tack value from 'a' , and there is no relation between 'a' an 'c'.
    i tried to use groovy to get value form view 'a' like this
    adf.object.viewa.variablex
    but i always got this error
    oracle.jbo.expr.JISyntaxError: Variable SecSystemVO not recognized
    any idea ?!?!?!?

    thanx its working good and lOV get data but when i select row from LOV
    oracle.jbo.expr.JISyntaxError: Variable viewobject not recognized
    Edited by: Mohammed Abdel Aziz on May 8, 2011 4:07 AM

Maybe you are looking for

  • Can you install itunes on more than one computer?

    Hi all, I want to install the software for my first-generation ipod mini on my friend's computer, but I heard somewhere that you can only install the software on one computer and obviously I also want to be able to use it with my own computer as well

  • War files and server classpath on 6.1

    We used to have all of the jsp's and html exploded in a WebApp and the           WebApp just used the same classes and property files the server was using,           now we put all these files in a war file.           My question is do I have to take

  • Monitoring Frequency in Production system

    Hi Experts, In Production system, we can do monitoring as            Component monitoring            Message monitoring            Adapter monitoring            Monitoring  Memory Exceptions            Performance monitoring                  please l

  • Mail flow completely broken after upgrading Exchange Server 2013 CU3 (Build 775.38) to Exchange Server 2013 SP1 (Build 847.32)

    internal mail flow completely broken. external mail flow completely broken. i upgraded exchange server as follows: 1. setup.exe /PrepareSchema /IAcceptExchangeServerLicenseTerms 2. setup.exe /PrepareAD /IAcceptExchangeServerLicenseTerms 3. upgraded t

  • Network Diagnostics

    new user to this after many years of reading... my first question is why do i keep getting booted off the internet with the Network Diagnostics screen poping up, only for it to then say everything is hunky dory and that i'm connected? back on for 2 p