Need help with Bulk Collect ForAll Update

Hi - I'm trying to do a Bulk Collect/ForAll Update but am having issues.
My declarations look like this:
     CURSOR cur_hhlds_for_update is
        SELECT hsh.household_id, hsh.special_handling_type_id
          FROM compas.household_special_handling hsh
             , scr_id_lookup s
         WHERE hsh.household_id = s.id
           AND s.scr = v_scr
           AND s.run_date = TRUNC (SYSDATE)
           AND effective_date IS NULL
           AND special_handling_type_id = 1
           AND created_by != v_user;
     TYPE rec_hhlds_for_update IS RECORD (
          household_id  HOUSEHOLD_SPECIAL_HANDLING.household_id%type,
          spec_handl_type_id HOUSEHOLD_SPECIAL_HANDLING.SPECIAL_HANDLING_TYPE_ID%type
     TYPE spec_handling_update_array IS TABLE OF rec_hhlds_for_update;
     l_spec_handling_update_array  spec_handling_update_array;And then the Bulk Collect/ForAll looks like this:
       OPEN cur_hhlds_for_update;
       LOOP
        FETCH cur_hhlds_for_update BULK COLLECT INTO l_spec_handling_update_array LIMIT 1000;
        EXIT WHEN l_spec_handling_update_array.count = 0;
        FORALL i IN 1..l_spec_handling_update_array.COUNT
        UPDATE compas.household_special_handling
           SET effective_date =  TRUNC(SYSDATE)
             , last_modified_by = v_user
             , last_modified_date = SYSDATE
         WHERE household_id = l_spec_handling_update_array(i).household_id
           AND special_handling_type_id = l_spec_handling_update_array(i).spec_handl_type_id;
          l_special_handling_update_cnt := l_special_handling_update_cnt + SQL%ROWCOUNT;         
      END LOOP;And this is the error I'm receiving:
ORA-06550: line 262, column 31:
PLS-00436: implementation restriction: cannot reference fields of BULK In-BIND table of records
ORA-06550: line 262, column 31:
PLS-00382: expression is of wrong type
ORA-06550: line 263, column 43:
PL/SQL: ORA-22806: not an object or REF
ORA-06550: line 258, column 9:
PL/SQL: SQMy problem is that the table being updated has a composite primary key so I have two conditions in my where clause. This the the first time I'm even attempting the Bulk Collect/ForAll Update and it seems like it would be straight forward if I was only dealing with a single-column primary key. Can anyone please help advise me as to what I'm missing here or how I can accomplish this?
Thanks!
Christine

You cannot reference a column inside a record when doin a for all. You need to refer as a whole collection . So you will need two collections.
Try like this,
DECLARE
   CURSOR cur_hhlds_for_update
   IS
      SELECT hsh.household_id, hsh.special_handling_type_id
        FROM compas.household_special_handling hsh, scr_id_lookup s
       WHERE hsh.household_id = s.ID
         AND s.scr = v_scr
         AND s.run_date = TRUNC (SYSDATE)
         AND effective_date IS NULL
         AND special_handling_type_id = 1
         AND created_by != v_user;
   TYPE arr_household_id IS TABLE OF HOUSEHOLD_SPECIAL_HANDLING.household_id%TYPE
                               INDEX BY BINARY_INTEGER;
   TYPE arr_spec_handl_type_id IS TABLE OF HOUSEHOLD_SPECIAL_HANDLING.SPECIAL_HANDLING_TYPE_ID%TYPE
                                     INDEX BY BINARY_INTEGER;
   l_household_id_col         arr_household_id;
   l_spec_handl_type_id_col   arr_spec_handl_type_id;
BEGIN
   OPEN cur_hhlds_for_update;
   LOOP
      FETCH cur_hhlds_for_update
        BULK COLLECT INTO l_household_id_col, l_spec_handl_type_id_col
      LIMIT 1000;
      EXIT WHEN cur_hhlds_for_update%NOTFOUND;
      FORALL i IN l_household_id_col.FIRST .. l_household_id_col.LAST
         UPDATE compas.household_special_handling
            SET effective_date = TRUNC (SYSDATE),
                last_modified_by = v_user,
                last_modified_date = SYSDATE
          WHERE household_id = l_household_id_col(i)
            AND special_handling_type_id = l_spec_handl_type_id_col(i);
   --l_special_handling_update_cnt := l_special_handling_update_cnt + SQL%ROWCOUNT; -- Not sure what this does.
   END LOOP;
END;G.

Similar Messages

  • Need help in Bulk collect

    Hi All,
    I need a help to create a bulk statement. Please find the scenario below
    I would like to copy a table A from table B using bulk collect also the table A has more records (1Million). Before doing this I need to either truncate the table B or drop the table to load the data from table A.
    Please provide me the correct statement to achieve this request. Thanks in advance!!
    Regards,
    Boovan.

    disabling any indexes on the target should be looked at first. If there are none then look at the above.
    When you do a direct path load the indexes are build after loading.The point is that the direct path load does not avoid the undo due to the indexes.
    In this example on a table with no indexes the undo used goes from 216kb to 16kb using append.
    When an index is added the undo used goes up from 216kb to 704kb an increase of 488kb for a standard insert.
    For the direct path insert the undo goes up from 16kb to 440kb so almost the full amount of undo due to the index.
    So the presence of a single index can have a much greater impact on the amount of undo required than the use of a direct path load and that undo may not be avoided by the use of a direct path load unless the index is disabled beforehand.
    Also note the tiny amounts of undo we are talking about for 50k rows.
    SQL> create table t as select * from all_objects where 0 = 1;
    Table created.
    SQL> insert into t select * from all_objects;
    56108 rows created.
    SQL> select
      2      used_ublk undo_used_blk,
      3      used_ublk * blk_size_kb undo_used_kb,
      4      log_io logical_io,
      5      cr_get consistent_gets
      6  from
      7      v$transaction, v$session s,
      8      (select distinct sid from v$mystat) m,
      9      (select to_number(value)/1024 blk_size_kb
    10          from v$parameter where name='db_block_size')
    11  where
    12      m.sid       =   s.sid
    13  and ses_addr    =   saddr;
    UNDO_USED_BLK UNDO_USED_KB LOGICAL_IO CONSISTENT_GETS
               27          216      13893         1042736
    SQL> rollback;
    Rollback complete.
    SQL> insert /*+ append */ into t select * from all_objects;
    56108 rows created.
    SQL> select
      2      used_ublk undo_used_blk,
      3      used_ublk * blk_size_kb undo_used_kb,
      4      log_io logical_io,
      5      cr_get consistent_gets
      6  from
      7      v$transaction, v$session s,
      8      (select distinct sid from v$mystat) m,
      9      (select to_number(value)/1024 blk_size_kb
    10          from v$parameter where name='db_block_size')
    11  where
    12      m.sid       =   s.sid
    13  and ses_addr    =   saddr;
    UNDO_USED_BLK UNDO_USED_KB LOGICAL_IO CONSISTENT_GETS
                2           16       1307         1041151
    SQL> rollback;
    Rollback complete.
    SQL> create unique index t_idx on t (object_id);
    Index created.
    SQL> insert into t select * from all_objects;
    56109 rows created.
    SQL> select
      2      used_ublk undo_used_blk,
      3      used_ublk * blk_size_kb undo_used_kb,
      4      log_io logical_io,
      5      cr_get consistent_gets
      6  from
      7      v$transaction, v$session s,
      8      (select distinct sid from v$mystat) m,
      9      (select to_number(value)/1024 blk_size_kb
    10          from v$parameter where name='db_block_size')
    11  where
    12      m.sid       =   s.sid
    13  and ses_addr    =   saddr;
    UNDO_USED_BLK UNDO_USED_KB LOGICAL_IO CONSISTENT_GETS
               88          704      20908         1043193
    SQL> rollback;
    Rollback complete.
    SQL> insert /*+ append */ into t select * from all_objects;
    56109 rows created.
    SQL> select
      2      used_ublk undo_used_blk,
      3      used_ublk * blk_size_kb undo_used_kb,
      4      log_io logical_io,
      5      cr_get consistent_gets
      6  from
      7      v$transaction, v$session s,
      8      (select distinct sid from v$mystat) m,
      9      (select to_number(value)/1024 blk_size_kb
    10          from v$parameter where name='db_block_size')
    11  where
    12      m.sid       =   s.sid
    13  and ses_addr    =   saddr;
    UNDO_USED_BLK UNDO_USED_KB LOGICAL_IO CONSISTENT_GETS
               57          456       2310         1041047

  • I need help with my Nokia 5800 update to v40.0.005

    Hey im having trouble with updating my Nokia 5800 to v40.0.005.
    The version on my phone at the moment is v21.0.025 and when i try to update it on my phone it says no update available.
    I tried downloading Nokia Update Software and getting it from there but the program wouldnt work either.
    Is there any other way i can get the v40.0.005 were it should work? or even getting the knetic scrolling and applications without needing to get v40.0.005?
    Please need help!
    Thanks
    Solved!
    Go to Solution.

    Under your battery, there's a product code on a sticker (X: 0586707). Go here: http://europe.nokia.com/support/download-software/device-software-update/can-i-update and type in your productcode to see if there should be an update for your productcode. If there's not, you could take your phone to a Nokia Carepoint and ask if they could do it - no promises. Or else you have to wait untill your productcode gets it.

  • Needed help in bulk collect using collections

    Hi,
    I have created a schema level collection like "CREATE OR REPLACE TYPE T_EMP_NO IS TABLE OF NUMBER ;
    will i able to use this in a where clause which involves bulk collect?
    Please share ur thoughts.
    My oracle version is 10g

    user13710379 wrote:
    Will i be able to do a bulk collect into a table using this collection of my sql type?Bulk fetches collects into an array like structure - not into a SQL table like structure. So calling a collection variable in PL/SQL a "+PL/SQL table+" does not make much sense as this array structure is nothing like a table. For the same reason, one needs to question running SQL select statements against PL/SQL arrays.
    As for your SQL type defined - it is a collection (array) of numbers. Thus it can be used to bulk fetch a numeric column.

  • HT4623 Need HELP with this ..since updating my 4S iphone today

    After updating my 4s phone, I suddenly have every facebook friends contact info in my contact list on my phone...all 1000 of them... NOT GOOd... some of them I only play games with.  Where did that come from and how do I get rid of that feature?

    I figured it out...   there is a place on the main contact page where you can actually uncheck Facebook...or check it

  • Need Help With Smart Collections (Lightroom 2.7)

    I am trying to set up a smart collection to list files that are blank in the Location field.  Some fields such as Caption allow you to check if the field "is empty".  Location does not allow the "is empty" option.  What can I do to check if Location is empty or blank?

    Does not contain a e i o u.
    Yes, it's stupid that you need such workarounds.

  • I need help with java Time Zone Updater for Venezuela Time Zone

    Hi,
    I've run the latest Time Zone Updater (1.3.5) on JRE 1.4.2. It is supposed to support the time zone changes for Venezuela. The problem is that when I set my Windows time zone and run java.util.TimeZone.getDefault() it says that I am on GMT instead of GMT-04:30.
    Am I doing something wrong?
    Thanks in advance for your help.

    I have found the solution for cases in which you cannot update your JRE to anything further than 1.5. You will have to create an extra entry in the Java tzmappings file as follows:
    Venezuela Standard Time:90,90::America/Caracas:After doing this, you will have to create a new String Value in your Windows registry for the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones\Venezuela Standard Time Key as follows:
    Name: MapID
    Value: 90,90
    Best regards.

  • Z68-GD65 G3 Need help with half bricked BIOS update

    Sorry if this should be in the BIOS forum, wasn't 100% sure.  Long story short...
    i2600k
    16GB Corsair Ram
    Crucial M 128GB
    GTX460
    I was trying to update the board to the latest BIOS.  I didn't realize the file/method from the MSI website was so problematic.  I ran E7681vP8.exe from within windows, the BIOS was updated and it then rebooted the system to update to ME8.  It never got to the ME update and I was stuck in an infinite reboot loop.  Power on for 10 seconds, then off, then back on again.  Tried everything I could think of to get the system back.  Cleared CMOS via button and battery, no change.  Rotates ram sticks in slot 2, disconnected everything but USB keyboard and plugged the monitor into the DVI port on the board, no change.  This was last night and I had already setup my RMA when I decided to try one more CMOS clear this morning before packaging everything up.  Well the Gremlins decided to let it power on and POST this morning!  I hit F1 to enter setup and here is the problem...
    It's now asking me to insert my USB key I'm assuming to now do the ME8 update... Well I formatted the USB drive I was using with the forum tool last night in an attempt to revive the board, so I don't have the extracted files from the MSI EXE from the website.
    I downloaded the EXE again, but I can't get it to run/extract the files since it's only set to run on this board (I'm on a Lenovo laptop).  I tried  WinRAR, 7-Zip, and Universal Extractor on the EXE to try and just get the files back on the USB.  None of those work.
    So the system is on and I'm stuck at the screen asking for the USB key.  I don't want to power it off/cycle it in case that screws up the update somehow.
    Can someone else with this board download the EXE directly from MSI, run it on a USB key (you don't have to update the BIOS to get the files to extract) and maybe upload the contents?  Or Mods do you have another suggestion on how to continue?
    Thanks!

    Quote from: jmunchies1 on 02-April-13, 07:23:05
    Well I'm REALLY regretting upgrading to this BIOS as it's killed my overclock :(
    Before I was stable with a 2600k @ 4.5Ghz with just 1.325 vcore.  Now I'm up to 1.35 vcore and I'm still not stable :(  Keep getting this BSOD:
    "A clock interrupt was not received on a secondary processor within the allocated interval".
    IBT and prime95 keep causing that BSOD.  I don't understand why the BIOS update is requiring such a huge increase in vcore.
    Because it is a 'compromise' UEFI/BIOS designed to allow function of both Sandy and Ivy CPUs on a mainboard originally designed on the Sandy Bridge platform. It's a shame that the GD65(G3) Ivy update does not function as well as the GD80(G3) vJ21 version does.

  • New to ABAP -- Need help with any BAPI to update the vendor master record

    I have a requirement to update the vendor master record ( ie purchasing block data inlfa1 and lfm1 table )directly. i have created the report but my problem is i am updating tables directly by using modify which is not correct according to SAP hence i want to use bapi whereby i can change the fields of the table. does anyone know any bapi which can modify the lfa1-sprem field and lfm1-sperm field. Plz hep me. They have specifically asked me to do it using BAPI's.

    MAP2e_lfa1_to_bapivendor_04
    MAP2e_lfa1_to_bapivendor_05
    will be helpful

  • Need help with DVD model/Firmware update info

    I am sorry to post here but have found no other way to try and get help or information about a Toshiba, (supposedly) slim style internal DVDRW unit, TS-632H, for our computer.  The label on the unit says Toshiba Samsung, and the complete number on the label is Tsst corp CDDVDW TS-632-H. (This is what is also shows in Device Manager/Properties for the unit.  We are trying to find the (real) model of this unit so we can determine the firmware version to make sure we have the latest version on the unit and to see if there are any specific drivers for the unit.  Thank you for your help and again, sorry if this may be the wrong forum and maybe directing us to an appropriate forum would be appreciated if there is such one.  Thank you.
    Message Edited by Cmptrguy on 04-12-2009 04:11 PM

    The information you see in the Device Manager is correct. If you can furnish the full model# be of great assistance.  There, try this-- Free Download TSST DVD Drive Firmware for Toshiba Notebooks  You should be concerned that the driver is up to date as it more of an asset to you.

  • Need help with APEX Collection - C

    Hi
    I have values in 2 fields on my page that I use to build a collection - "On Submit - After Computations and Validations"
    I want to delete collection using HTMLDB_COLLECTION.DELETE_COLLECTION ; and recreate if user changes a value in any of the above 2 fileds ( field 1 is LOV and field 2 is DATE )
    I know I have to use AJAX but could not figure out how to code it . Can someone please direct me to any similar peice of code or suggest the steps?
    Thanks
    Aali

    You can find it here:
    http://apex.oracle.com/pls/otn/f?p=31517:246
    Denes Kubicek
    http://deneskubicek.blogspot.com/
    http://www.opal-consulting.de/training
    http://apex.oracle.com/pls/otn/f?p=31517:1
    http://www.amazon.de/Oracle-APEX-XE-Praxis/dp/3826655494
    -------------------------------------------------------------------

  • HT4528 need help with i phone 4 update and restore

    When i was at dinner tpnight my i phone lockrd up and now it says activate and i cannot get to settings menu

    so what have you done to troubleshoot?

  • DBMS_OUTPUT within BULK COLLECT FORALL

    Hi,
    I am trying to figure out how I can output using DBMS_OUTPUT.PUT_LINE within a BULK COLLECT/ FORALL Update?
    Example:
    FETCH REF_CURSOR BULK COLLECT INTO l_productid,l_qty
    forall indx in l_productid.first..l_productid.last
    Update products aa
    Set aa.LastInventorySent = l_qty(indx)
    Where aa.productid = l_productid(indx);
    DBMS_OUTPUT.PUT_LINE('ProductID: ' || l_productid(indx)|| ' QTY: ' || l_qty(indx);
    Is this possible? If so how can I accomlish this?
    Thanks,
    S

    FETCH REF_CURSOR BULK COLLECT INTO l_productid,l_qty
    forall indx in l_productid.first..l_productid.last
    Update products aa
    Set aa.LastInventorySent = l_qty(indx)
    Where aa.productid = l_productid(indx);
    for indx in 1..l_qty.count loop
    DBMS_OUTPUT.PUT_LINE('ProductID: ' || l_productid(indx)|| ' QTY: ' || l_qty(indx);
    end loop;SY.

  • HT4061 need help with my iphone 4 i try to update last five  days but after updating to 6.1.2  it says that    We're sorry, we are unable to continue with your activation at this time. Please try again later, or c

    need help with my iphone 4 i try to update last five  days but after updating to 6.1.2  it says that
    We're sorry, we are unable to continue with your activation at this time. Please try again later, or c

    If the iPhone was hacked and unlocked via unofficial means, it has become locked again. Insert original SIM in the phone to activate with iTunes.

  • Please help! I am trying to change my Apple Id that used to be my mother to Mine- Every time i have it changed and i go and try and do an update it continues to ask for her old password. I really need help with this!

    Please help! I am trying to change my Apple Id that used to be my mother to Mine- Every time i have it changed and i go and try and do an update it continues to ask for her old password. I really need help with this!

    Phil0124 wrote:
    Apps downloaded with an Apple ID are forever tied to that Apple ID and will always require it to update.
    The only way around this is to delete the apps that require the other Apple ID and download them again with yours.
    Or simply log out of iTunes & App stores then log in with updated AppleID.

Maybe you are looking for

  • Sntax error when creating a temp table

    Hi All, I get a syntax error when I try to create a  temporary table using the below sql statement. create global temporary column table prc as table precipitation; The  table precipitation exists in the database under my ID. Could anyone please let

  • Reconfiguring Hyperion after DB move from Solaris to Linux

    Our Hyperion Databases are moving from Solaris to Linux. We need to reconfigure Hyperion EPM to point to the new Linux DB. We have 4 Hyperion servers A,B, C, D. Server A : Foundation Services, Workspace ,Reporting & Analysis, Planning, Calc Manager,

  • TS1398 why can,t my ipad  set my location

    why can,t my ipad find my location at home with wifi only i need it  to use other apps 

  • Re: Subscription no available in my region

    Hi I am also having similar problem. Please share withme if you get a soution. Kind regards KA

  • ICal won't sync with Entourage anymore

    I started having trouble with this right after 10.5.2--duplicate events that needed conflict reconciliation. Today I noticed a number of meetings were being duplicated. Sync asked me to resolve conflicts, which I did globally in favor of Entourage. I