Using array binding to perform multiple rowupdates in one pass

For the first time I am attempting to use array binding in VB.NET to update multiple rows via a single execution of a stored procedure. My subroutine is:
Friend Sub UpdateSolutionStatusUsingArrays(ByVal intNumBeingUpdated As Integer, ByVal arrScenarioID() As Integer, ByVal arrSolutionID() As Integer, ByVal arrInOrOut() As Integer, ByVal arrTimePeriod() As Integer)
Try
'Set up the Command object
Dim cmdUpdateSolutionStatus As OracleCommand
cmdUpdateSolutionStatus = New OracleCommand
cmdUpdateSolutionStatus.CommandType = CommandType.StoredProcedure
cmdUpdateSolutionStatus.CommandText = "ProcUpdateSolutionStatus"
cmdUpdateSolutionStatus.Connection = cnnORACLE
cmdUpdateSolutionStatus.ArrayBindCount = intNumBeingUpdated - 1
cmdUpdateSolutionStatus.CommandTimeout = CInt(tblOptions.Rows(intDatabaseIndex).Item("ConnectionTimeout"))
'Add ScenarioID array as parameter
Dim p_ScenarioID As New OracleParameter("ScenarioID", OracleDbType.Int32)
p_ScenarioID.Direction = ParameterDirection.Input
p_ScenarioID.Value = arrScenarioID
cmdUpdateSolutionStatus.Parameters.Add(p_ScenarioID)
'Add SolutionID array as parameter
Dim p_SolutionID As New OracleParameter("SolutionID", OracleDbType.Int32)
p_SolutionID.Direction = ParameterDirection.Input
p_SolutionID.Value = arrSolutionID
cmdUpdateSolutionStatus.Parameters.Add(p_SolutionID)
'Add InOrOut array as parameter
Dim p_InOrOut As New OracleParameter("InOrOut", OracleDbType.Int32)
p_InOrOut.Direction = ParameterDirection.Input
p_InOrOut.Value = arrInOrOut
cmdUpdateSolutionStatus.Parameters.Add(p_InOrOut)
'Add TimePeriod array as parameter
Dim p_TimePeriod As New OracleParameter("TimePeriod", OracleDbType.Int32)
p_TimePeriod.Direction = ParameterDirection.Input
p_TimePeriod.Value = arrTimePeriod
cmdUpdateSolutionStatus.Parameters.Add(p_TimePeriod)
'Open connection
cnnORACLE.Open()
'Run stored procedure
cmdUpdateSolutionStatus.ExecuteNonQuery()
'Tidy up
cmdUpdateSolutionStatus = Nothing
cnnORACLE.Close()
Catch ex As Exception
WriteLog("Subroutine UpdateSolutionStatusUsingArrays:" & ex.Message.ToString)
strState = "Error"
'Update Run Status to show error has occurred
cnnORACLE.Close()
UpdateRunStatusORACLE(7)
End Try
End Sub
When the routine tries to run cmdUpdateSolutionStatus.ExecuteNonQuery() I get the error message:
Unable to cast object of type 'System.Int32[]' to type 'System.IConvertible'.
I have tried all sorts of variants of the code but with no success. The arrays are being set up correctly. Anyoneone know what I'm missing?
Stewart

Try declaring the arrays as OracleNumber datatype instead of Integer. I've had this issue before, and I believe this is what I did to solve the problem.

Similar Messages

  • Insert SDO_GEOMETRY using array binding

    Hi,
    does anyone know howto insert the elem_info array and the ordinates array of a SDO_GEOMETRY object using array binding and ODP or if there is a way to insert the SDO_GEOMETRY object using the same technique.
    /Anders

    The current releases of ODP.NET do not support object types, hence no "proper" SDO_GEOMETRY support. You can retrieve the data as an XML-type as illustrated here:
    Re: ODP.Net + Spatial
    I know of no way to insert an SDO_GEOMETRY object using array binding at this time.
    If someone else has a solution, please do post!
    - Mark

  • Can I use Array Binding with a ExecuteDataSet or ExecuteReader methods?

    I want to use Array binding with selects. From the examples that I see so far it seems like everyone is showing the ExecuteNonQuery method. I wonder if I can use this functionality with a regular query that returns ref cursoros.
    Andrzej

    what is the error you recieve?

  • Associative  array binding - poor performance

    Dear All
    i have very very low performence when i am inserting a binary array using associative array bind. i mean when i insert huge jagged binary array.
    the jagged array has
    BinarryArray[0][0]........BinarryArray[0][8000]
    BinarryArray[1][0]........BinarryArray[1][8000]
    BinarryArray[3600][0]........BinarryArray[3600][8000]
    BinarryArray[0] - i have 8000 byte end so on. total is 3600 X 8000
    that means 28,800KB hence to ~28MB.
    the C# code is as follows
    string strInsert "Insert Into T Values(t.SEQUENCE.currval, :paramArr);
    OracleCommand objCommand = new OracleCommand;
    OracleParameter objParam = new OracleParameter(paramArr, OracleDbtype.blob, 8000, system.data.ParameterDirection.Input,true,0,0,"ColumnName", system.data.DataRowVersion.Curren, BinarryArray);
    objCommandtext = strInsert;
    objCommand.ArrayBindCount = BinarryArray.Length;
    objCommand.Parameters.Clear();
    objCommand.Parameters.Add(paramArr);
    objCommand.ExecuteNonQuery();
    In generall the Insertion is good for each row in the array i get separate row in the DB but it works so slow.
    why??????
    see the code below

    well??

  • Perform multiple actions with one button

    Is it possible to do 2 things when clicking a single button?
    Like this:
    A button adds an item to a collection and after adding the button must be disabled.

    Yes - you can chain multiple commands together with a ;
    In this example, add a button control (Button1) and an Input Text (Text1) control.
    Set the OnClick property for Button1 to:
    Collect(myCollection, {FirstName: Text1!Text}); UpdateContext({ButtonDisabled: false}); UpdateContext({ButtonDisabled: true})
    Set the Disabled property for Button1 to:
    ButtonDisabled
    FYI - The UpdateContext is used twice to change the state of a context variable.
    Let us know if this answers your question -
    Thor

  • Using "All Calls" button for multiple lines on one phone

    I have several executive assistants that have multiple lines for executives that they answer calls for. We have added the "All Calls" button so they don't accidentally make outbound call using one of the executives lines. When the All Calls button is selected, all outbound calls are made using line 1. However, when a call comes in on one of the executives lines it doesn't show the name and number of the calling party unless you select the line.
    How can we make it so the name and number show on the inbound call while having the "All Calls" button selected?

    Little confused still by this, just want to make sure I'm clear.  My current set up with Asterisk is you make users which are extensions, and then enable voicemail on them, so for example:
    Extension 300 - Voicemail enabled
    Extension 301 - Voicemail enabled
    Extension 302 - No Voicemail
    Etc.  And it's there that you set the username/password for each extension.  So on a SIP phone, under Line 1 registration I'd have it register Extension 300, and line 2 could register Extension 301 and so on.  If someone calls extension 300, line 1 rings and if no answer goes to the voicemail box for 300.  If someone calls Extension 301, then line 2 on the phone rings and if no answer goes to voicemail for Line 2.
    I do understand what you mean how each phone is it's own "User", and so the way I have it set up now is my 7970 is my user, and it has Extension 300 with voicemail assigned to Button 1 which works fine.
    I just simply need a way so that Extension 301 shows up on Button 2 on the phone, so that I can select that line to make an outbound call (with a different caller ID), and if someone calls Extension 301, then that line on my phone with also ring, BUT will go to the voicemail box for 301.  I don't need my 7970 to light up that there's a vm or anything like that, it just needs to capture the vm.
    If I make a floating extension or extension mobility for a new user with extension 301 and enable voicemail, then calling 301 does go to its voicemail box, but I'm just not sure how I would have that show up on my 7970 as line 2 and ring on there and make outbound calls on there as well.  Thank you so much!

  • SQL performance - multiple tables or one bigger one?

    One product will have 5 different types of media that need to
    be
    associated with it.
    Some products will have, perhaps many items in one column
    while none in
    other columns
    For Example
    Product ID | ###
    images | photoID1, PhotoID2
    multimedia |
    testimonials |
    Pdfs | pdfid1
    INserts | insertid1, insertid2 insertid3
    Anyways, I am wondering if creating one table with multiple
    columns is
    better than many tables with just one of each of these
    categories?
    In other words, would it be better to have a table for
    multi-media, a
    table for pdfs and so on or one table for all of them. Some
    rows will be
    empty.
    does the server take a bigger hit accessing multiple tables
    win
    individual items or one table with more columns that are,
    perhaps empty?

    .oO(Lee)
    >One product will have 5 different types of media that
    need to be
    >associated with it.
    >
    >Some products will have, perhaps many items in one column
    while none in
    >other columns
    >
    >For Example
    >
    >Product ID | ###
    >images | photoID1, PhotoID2
    >multimedia |
    >testimonials |
    >Pdfs | pdfid1
    >INserts | insertid1, insertid2 insertid3
    >
    >Anyways, I am wondering if creating one table with
    multiple columns is
    >better than many tables with just one of each of these
    categories?
    >
    >In other words, would it be better to have a table for
    multi-media, a
    >table for pdfs and so on
    That would be one possible way.
    >or one table for all of them. Some rows will be
    >empty.
    Don't do that, at least not in the way you described above.
    But you
    could do it with a single table if you would add a column
    that describes
    the media type:
    productId
    mediaType
    mediaId
    There would be a record for every single associated media. A
    product
    with 3 PDFs and 5 images would have 8 records in the media
    table.
    Micha

  • Multiple Droplets in one pass?

    Hello,
    I've been using Photoshop for a while now, since v.5.5. I'm not new to Actions, batches, droplets and the like. However, I've run into the need to process mulitple files, in a multitude of ways and seem to be hitting a roadblock.
    The current workflow is to take a folder of JPEGs and drop them onto a droplet that turns them into "Antique" look, I repeat the dragging-dropping process again with a Black & White Droplet, then again with a Sepia droplet. Ultimately I'd LOVE to combine the 3 steps into one: dropping the images onto a single droplet (or whatever it takes) and return to have 3 folders full of my derivative images.
    My colleaugues idea was to add a "revert" step into the original action, do the next steps, revert, etc. This works fine on a SINGLE image—when run solely as Action—but fails when batching because of the saving as a jpeg step.
    Any solutions come to mind to make this ENTIRE thing work?
    Thanks!

    An example of actions for the droplet using a snapshot instead of revert and a flatten step in each action.
    (my example actions are short so they fit in a screenshot)

  • Exception Handling for Array Binding

    Hi
    1)
    I am using a Stored Procedure.
    I am using array binding and if i am sending an array of count 10 to be inserted in a table and only 9 got inserted,i deliberatly inserted one errorneous record in array, the count returned by ExecuteNonQuery() is 10.Why ?
    How can i come to know exact number of rows inserted in table, how can i use Output variables, because the array bind count is 10 so if i add an output parameter it gives error ArrayBind count is wrong....
    2)
    Is it possible to roll back all the inserts if error occurs in any of the insert by Oracle engine.What it does is it inserts all correct records and leaves the errorneous record and doesn't even throw any exception or any message.
    Answer - This can be achieved by using OracleTransaction and don't use Exception handling in procedure otherwise there wont be any exception thrown by procedure which is necessary to detect if an error occured during insert.If you use exception handling OracleEngine will insert correct rows and leave errorneous record and return count of inserted + non inserted records which is wrong.
    Please help.
    Message was edited by:
    user556446
    Message was edited by:
    user556446

    You'll need to encapsulate your validation within it's own block as described below:
    -- this will die on the first exception
    declare
      TYPE T_BADDATA_TEST IS TABLE OF VARCHAR2(1000) INDEX BY binary_integer ;
      tbt T_BADDATA_TEST ;
      aBadTypeFound exception ;
    begin
       tbt(0) := 'a';
       tbt(1) := 'b';
       tbt(2) := 'c';
        for idx in tbt.first..tbt.last loop
          if tbt(idx) =  'b' then
              raise aBadTypeFound ;     
          else
              dbms_output.put_line(tbt(idx));     
          end if  ;
        end loop ;
    end ;--encapsulate the exception area in a begin/end block to handle the exception but continue on
    declare
      TYPE T_BADDATA_TEST IS TABLE OF VARCHAR2(1000) INDEX BY binary_integer ;
      tbt T_BADDATA_TEST ;
      aBadTypeFound exception ;
    begin
       tbt(0) := 'a';
       tbt(1) := 'b';
       tbt(2) := 'c';
        for idx in tbt.first..tbt.last loop
          BEGIN
          if tbt(idx) =  'b' then
              raise aBadTypeFound ;     
          else
              dbms_output.put_line(tbt(idx));     
          end if  ;
          EXCEPTION
            WHEN aBadTypeFound THEN
                dbms_output.put_line(tbt(idx) || ' is bad data');       
            WHEN OTHERS THEN
                dbms_output.put_line('exception');       
          END ;
        end loop ;
    end ;
    output:
    a
    b is bad data
    c
    ***/

  • Support for Array Binding and PL/SQL tables (IN, INOUT, or OUT)

    I have attempted, unsuccessfully, to use array binding in stored procedure/function calls where the sp/sf has parameters that are PL/SQL tables. I have seen the topic floating around in this forum, but I have not seen the explicit questions:
    - Does ODP.NET support PL/SQL tables as IN, INOUT or OUT parameters to stored procedures/functions?
    - Will any planned ODP.NET release support PL/SQL tables as IN, INOUT or OUT parameters to stored procedures/functions?
    I am aware that I can use REF CURSORS to handle the OUT situation, but I need to make a design decision concerning supporting parameters of IN and INOUT PL/SQL tables.
    Thanks.
    James

    You really MUST do this!! - i.e. include support for PL/SQL table parameters (IN INOUT and OUT) in a future release of ODP.NET.
    PL/SQL tables are a fundamental type in Oracle stored procedures and you will be preventing a huge number of existing projects from migrating to .NET if you don't acknowledge them as part and parcel of Oracle programming.
    I sincerely hope support for PL/SQL table parameters is treated as a serious issue.
    Think what a coup it would be for you over Microsoft (who don't currently support PL/SQL tables with their .NET native provider for Oracle and don't look as if they will at least in the short term)!
    Please, please, please!

  • Array Bind: nbr of updated rows?

    Hello,
    when using array binding with UPDATE statements, how to look up the number of updated rows?
    I couldn't find any parameter property such as ArrayBindAffectedRows.
    Is it possible to use array bind with SQL statements which return values, e.g.:
    UPDATE emp SET salary = salary + :increase
    WHERE mgr = :mgrNo
    RETURNING salary INTO :newSalary;
    Hm, arrays :increase and :newSalary might have different lengths.
    Thanks,
    Armin

    Ok this is genuinly tricky.
    The only way I can think of to get this is to use FORALL and BULK COLLECT. This does an array-bound insert from PL/SQL. But you need to pass Associative Arrays from ODP.NET to PL/SQL to get this started.
    Any other solution I could think of would require running some PL/SQL code for each update statement, for instance in a trigger. But avoiding the context switches from PL/SQL to SQL is a main reason to use array binding in the first place.
    Here's a complete sample program:
    I used inline PL/SQL for compactness, but you might want to save the block as a procedure.
    using System;
    using System.Data;
    using Oracle.DataAccess.Client;
    using Oracle.DataAccess.Types;
         public class Test
          static OracleConnection connect()
            string constr = "data source=oracle;user id=scott;password=tiger";
            OracleConnection con = new OracleConnection(constr);
            con.Open();
            return con;
        const string sql = @"
    declare
      type NumTable is table of Number index by binary_integer;
      l_managers NumTable := :mgr;
      l_increase NumTable := :inc;
      l_newSals NumTable;
      l_records int;
    begin
      forall idx in l_managers.first .. l_managers.last
        update emp
        SET
        sal = sal + l_increase(idx)
        WHERE mgr = l_managers(idx)
        RETURNING sal BULK COLLECT INTO l_newSals;
      :records_affected := l_newSals.count;
    end;
        [STAThread]
        static void Main(string[] args)
          try
            using (OracleConnection con = connect())
              string cr = new String(new char[] {(char)13});
              OracleCommand cmd = new OracleCommand(sql.Replace(cr,""),con);
              OracleDecimal[] increases = new OracleDecimal[] {10,20,30};
              int[] managers = new int[] { 7698,7839,7782};
             OracleParameter pMgr = cmd.Parameters.Add("manager",
                 OracleDbType.Int32,
                 ParameterDirection.Input);
              pMgr.CollectionType = OracleCollectionType.PLSQLAssociativeArray;
              pMgr.Size = managers.Length;
              pMgr.Value = managers;
              OracleParameter pInc = cmd.Parameters.Add("increase",
                 OracleDbType.Decimal,
                 ParameterDirection.Input);
              pInc.CollectionType = OracleCollectionType.PLSQLAssociativeArray;
              pInc.Size = increases.Length;
              pInc.Value = increases;
              OracleParameter pRecs = cmd.Parameters.Add("records",
                 OracleDbType.Int32 ,
                 ParameterDirection.Output);
              pRecs.CollectionType = OracleCollectionType.None;
              cmd.ExecuteNonQuery();
              int recs = (int)pRecs.Value;
              Console.WriteLine("{0} records affected",recs );
          catch (Exception ex)
            Console.WriteLine(ex);
    }

  • HT204053 I am using my apple ID on multiple devices

    I am using my apple ID on multiple devices, i.e. 3 iPhones, 4 iPads, MacAir, MacPro etc....Up until today we have been able to use FaceTime on any device to contact each other. Today for some reason we can no longer faceTime each other from any of our devices. For the iPhones the only 2 selections we have chosen are the cell number for the iPhone and our Apple ID. This is the same for our iPads. We are able to iMessage with no problem. These settings have been working for the last several years. Anyone have any suggestions?

    I'm experiencing the exact same issue. I was able to use FaceTime perfectly fine across multiple devices on one Apple ID, but as of the 15th or 16th can't get it to work on any device.
    Help!

  • Time machine backup of multiple drive of one computer?

    Can I use Time Machine to backup multiple drives of one computer?

    Yes, assuming they're in a format Time Machine can back up. This doesn't include formats such as FAT32.
    (66627)

  • Perform multiplication, division n get remainder without using arithmetic o

    hello,
    perform multiplication, division n get remainder without using arithmetic operators
    thanks in advance
    manasi

    ram.manasi wrote:
    i can program myself however i am new to programming and have no clue how to perform arithmmetic operations without using arithmetic operators n would like to know how to go about itwell, we're not your private code-monkeys nor are we tutors. We are usually best at answering specific questions but many of us get our hackles up when someone simply demands an answer. I suggest that you find out what your teacher is expecting of you here. I would guess that this involves some recursion, but it is up to you to find out. Do some work. Then if you have a specific question, please feel free to come back and ask for help. nicely.

  • Problems with Array-Parameters when using Document-Binding

    Hi,
    I use the following environment:
    JDeveloper 11.1.1.3.0
    WLS 10.3.3.0
    I created a small EJB (2.1), containing a simple method, which is using arrays as parameters:
    public String doTestArray(String[] aStringArray, int[] aIntArray)
    throws RemoteException;
    I exposed this EJB as a Webservice using JDev's Webservice wizard. I choosed Document/Wrapped-Binding. WSDL and mapping file are being generated. Made an EAR-Deployment-Profile and deployed the application to Integrated-WLS.
    I tried to test the Webservice with the WLS integrated test client, which is generating the following request:
    <doTestArrayElement xmlns="http://model/types/">
    <!--Zero or more repetitions:-->
    <arrayOfString_1>string</arrayOfString_1>
    <!--Zero or more repetitions:-->
    <arrayOfint_2>3</arrayOfint_2>
    </doTestArrayElement>
    Unfortunately, the invokation fails. WLS returns
    weblogic.wsee.codec.CodecException: Failed to decode message
    at weblogic.wsee.codec.soap11.SoapCodec.decode(SoapCodec.java:188)
    at weblogic.wsee.ws.dispatch.server.CodecHandler.decode(CodecHandler.java:139)
    That only happens in methods, which use array-parameters. Simple parameters are no problem.
    However, when I use RPC/Encoded as Webservice-Binding, everything seems to be fine.
    Does WLS have problems in general using array-parameters and Document-Binding?
    Any help would be appreciated.
    Thanks,
    Stefan

    Hi Josko,
    Where do you have this problem 3.5 or 7.0 BexAnalyzer.
    When ever heirarchy icons are created in BEx, respective hyperlink is assigned to each of them, Make sure that you dont manipulate with them,,
    If you still have problem then create OSS message.
    Regards,
    Vinay

Maybe you are looking for

  • Cannot Send Mail

    I just tried sending a email from my iphone this morning and I get the message "Cannot Send Mail, the sender address was invalid" For the past 3 months everything has been fine and mail has been working perfectly. I haven't changed any of the setting

  • My dream- an iphone 3g car adapter and charger WHICH

    Lets me decide on whether or not to charge while playing music or not to charge... Why I want this? because if I charge my iphone for 30 min every day it wil kill the already weak battery. So I rather have a car adapter that could be used as a charge

  • Reg LPA Delivery schedules - MRP

    Hi Delivery schedules got created via MRP - LPA document type We haven't released to vendor [JIT or Forecast] When i manually change quantity in generated delivery schedule, Firmed indicator is ticked as expected i am unable to uncheck this indicator

  • Getting ipod info back onto a pc

    I am in a pickle! I had to get a worm out of my computer, and I got a new hard drive. It erased my iTunes! I still have it on my ipod, but not on my computer, so I can't download anything without deleting everything else, since I never backed it up o

  • Ipad not delivered

    where on the delivery status or website can i report that my ipad has not been delivered. cant find it anywhwere, asks for an update for online assistance but no idea where to update, i just want to send and e-mail with reference number so they can c