I am getting this "ORA-24381: error(s) in array DML error" in the code

declare
TYPE RehrCD_TYP IS TABLE OF wk_rehr_entity_hierarchy.wk_rehr_cd%TYPE;
TYPE RehrParentCD_TYP IS TABLE OF wk_rehr_entity_hierarchy.wk_rehr_parent_cd%TYPE;
TYPE RehrESSPath_TYP IS TABLE OF wk_rehr_entity_hierarchy.wk_rehr_ess_path%TYPE;
L_levelRehrCD RehrCD_TYP;
L_levelParentCD RehrParentCD_TYP;
L_levelessPath RehrESSPath_TYP;
L_cItem VARCHAR2(50) := 'PRC_Update_Level :';
L_rows NUMBER DEFAULT 0;
CURSOR Update_Level_CUR
     IS
SELECT
wk_rehr_cd
,wk_rehr_parent_cd
,wk_rehr_ess_path
FROM
wk_rehr_entity_hierarchy
WHERE
wk_rehr_ess_path LIKE '/ENTITY/ACTIVITY_USD%';
BEGIN
OPEN Update_Level_CUR;
BEGIN
LOOP
FETCH Update_Level_CUR
BULK COLLECT INTO
L_levelRehrCD
,L_levelParentCD
,L_levelessPath
LIMIT 10000;
EXIT WHEN L_levelRehrCD.count = 0;
dbms_output.put_line(1);
FORALL i IN L_levelRehrCD.FIRST .. L_levelRehrCD.LAST SAVE EXCEPTIONS
UPDATE
wk_rehr_entity_hierarchy
SET
wk_rehr_ess_level = RPKG_Entity_Hierarchy.Get_Level(L_levelessPath(i))
WHERE
wk_rehr_cd = L_levelRehrCD(i)
AND wk_rehr_parent_cd = L_levelParentCD(i);
FOR j IN 1 .. L_levelRehrCD.COUNT
LOOP
L_rows := L_rows+ SQL%BULK_ROWCOUNT(j);
END LOOP;
END LOOP;
CLOSE Update_Level_CUR;
END;
end;
Please help me how to debug it?

Just get rid of the whole looping approach - it's slow, inefficient and you don't need it.
A single sql statement should always outperform looping code.
Also, try to bring the logic of RPKG_Entity_Hierarchy.Get_Level inline to the SQL.
If it's based on the column wk_rehr_ess_path then you might be able to use CONNECT BY or other methods to remove what is a bad practice and classic performance killer.
I was going to suggest a MERGE statement like this:
MERGE
INTO  wk_rehr_entity_hierarchy wk
USING (SELECT wk_rehr_cd
       ,      wk_rehr_parent_cd
       ,      RPKG_Entity_Hierarchy.Get_Level(wk_rehr_ess_path) lvl
       FROM   wk_rehr_entity_hierarchy
       WHERE  wk_rehr_ess_path LIKE '/ENTITY/ACTIVITY_USD%') xx
ON    (wk.wk_rehr_cd        = xx.wk_rehr_cd
AND    wk.wk_rehr_parent_cd = xx.wk_rehr_parent_cd)
WHEN MATCHED THEN
       UPDATE
       SET    wk_rehr_ess_level = xx.lvl;But then I realised you're selecting from and updating the same table.
Are you sure this isn't achievable in just a single update?
UPDATE wk_rehr_entity_hierarchy
SET    wk_rehr_ess_level = RPKG_Entity_Hierarchy.Get_Level(wk_rehr_ess_path)
WHERE  wk_rehr_ess_path LIKE '/ENTITY/ACTIVITY_USD%';And then you can bring that function logic inline - much more efficient.

Similar Messages

  • Getting error-ORA-24381: error(s) in array DML

    Hi i have written the following code to bulk insert into a database table.
    I am getting an error while returning the result of the bulk insert query into the collection
    I have tried to track it by using sql%bulk_exceptions.error_code.
    But the error code that it is showing is just 1.
    I trapped it using sqlerrm.
    and that is showing-error(s) in array DML
    What do i do?
    DECLARE
       CURSOR temp_rec_tap_cur
       IS
          SELECT *
            FROM temp_records_tap;
       TYPE temp_rec_tab IS TABLE OF temp_rec_tap_cur%ROWTYPE;
       v_test_tab   temp_rec_tab;
       v_rec_num    num_tab;
       v_filename   temp_records_tap.file_name%TYPE;
       v_error_code tap_reject.error_code%type;
       v_rej_value  tap_reject.field_rej%type;                      
       v_errors number;   
    BEGIN
       SELECT file_name
         INTO v_filename
         FROM table1
         WHERE ROWNUM<2;
       OPEN temp_rec_tap_cur;
       LOOP
          BEGIN
             FETCH temp_rec_tap_cur
             BULK COLLECT INTO v_test_tab LIMIT 1000;
             FORALL i IN v_test_tab.FIRST .. v_test_tab.LAST SAVE EXCEPTIONS
                INSERT INTO tapdetail_tapin
                     VALUES v_test_tab (i)
                  RETURNING record_num
                    BULK COLLECT INTO v_rec_num;
          EXCEPTION
             WHEN DUP_VAL_ON_INDEX
             THEN
                NULL;
             WHEN OTHERS
             THEN
             v_errors:=sql%bulk_exceptions.count;
             for i in 1..v_errors
             loop
             dbms_output.put_line(sql%bulk_exceptions(i).error_code);
             p3_errorlog ('TAPINDETAWARE', SQLERRM, v_filename);     
             end loop;
             END;
                --RAISE;
          EXIT WHEN temp_rec_tap_cur%NOTFOUND;
       END LOOP;
    INSERT INTO table2
    SELECT file_id, file_name, sender_pmn, recipient_pmn, call_date,
                 call_date_only, call_type, call_number, FIRST_RECORD,
                 service_type, service_code, home_bid, serve_bid,
                 chargeable_subs_type, imsi_min, msisdn_mdn, air_charges,
                 air_charges_sdr, air_time, national_call_charges,
                 national_call_charges_sdr, national_call_time,
                 international_call_charges, international_call_charges_sdr,
                 international_call_time, dir_assist_charges,
                 dir_assist_charges_sdr, dir_assist_time, other_charges,
                 other_charges_sdr, other_time, volume_charges,
                 volume_charges_sdr, volume_units, tot_charges, tot_charges_sdr,
                 tot_duration, state_tax, state_tax_sdr, local_tax,
                 local_tax_sdr, state_and_use_tax, state_and_use_tax_sdr, va_tax,
                 va_tax_sdr, other_tax, other_tax_sdr, charge_refund_indicator,
                 advised_charge_currency, advised_charge, advised_charge_sdr,
                 advised_charge_commission, advised_charge_commission_sdr,
                 exchange_rate, mcc, mnc, process_date, chargeable_units,
                 record_num, mscid,null,null,decode(call_type,0,'250',1,'251',5,'255'),null,'Duplicate Call'
                 from temp_records_tap
                 where record_num not in (select column_value from table(v_rec_num)) ;
    EXCEPTION
    WHEN OTHERS THEN
    p3_errorlog ('TAP', SQLERRM, v_filename);  
    END;Edited by: user8731258 on Sep 14, 2010 2:58 AM
    Edited by: user8731258 on Sep 14, 2010 3:01 AM

    What is the type declaration of num_tab and how is record_num defined?
    ORA-24381: error(s) in array DML
    Cause: One or more rows failed in the DML.indicates that you fail on the insert itself. Are the table definitions the same? Same primary/unique keys?
    Edited by: MBr on 14-Sep-2010 03:16

  • ORA-24381: error(s) in array DML - Reasons

    Hi all,
    Do you know when we could recieve this exceptions?
    I found one case - if we deal with FORALL and sparse collection.
    Any other cases?
    Thanks
    PS: We are talking for Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit
    :)

    Do you know when we could recieve this exceptions?e.g. all kind of constraint violations would raise this error:
    SQL> DECLARE
       TYPE emp_tab IS TABLE OF emp%ROWTYPE
          INDEX BY BINARY_INTEGER;
       e_tab   emp_tab;
    BEGIN
       e_tab (1).empno := 7900;
       FORALL i IN 1 .. 1 SAVE EXCEPTIONS
          INSERT INTO emp
               VALUES e_tab (i);
    EXCEPTION
       WHEN OTHERS
       THEN
          DBMS_OUTPUT.put_line (SQLERRM (SQLCODE));
    END;
    ORA-24381: error(s) in array DML
    ORA-00001: unique constraint (PK_EMP) violated

  • ORA-24381: error(s) in array DML

    Hi,
    I encountered error during mya testing. The script run thru several cases, until it encouter this error ORA-24381: error(s) in array DML.
    What could be the possible reason for this and can anyone give an idea to resolve this issue.
    Bulk collect was used with a limit of 1000.
    I used dblink to access database.
    Thanks in advance.

    The documentation tells you all about it: http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14261/tuning.htm#sthref2201
    Regards,
    Rob.

  • I'm trying to update to CC (2014) and keep getting this message: "Installation Failed. Installation encountered an error. Please restart your system and try again. (15) I've done the restart, same problem.

    I'm trying to update to CC (2014) and keep getting this message: "Installation Failed. Installation encountered an error. Please restart your system and try again. (15) I've done the restart, same problem.
    Help!

    Hi stijill2,
    In case you are facing issues uninstalling the app's then please try manual cleanup of Adobe from your machine by following the below mentioned steps:
    1. Navigate to Applications and trash all Adobe app's and Adobe folder.
    2. Navigate to Applications/Utilities/ and trash Adobe Application Manager,Adobe Creative Cloud, Adobe Installer folder.
    3. Go to Library/Application Support and trash Adobe.
    4.Go to ~/Library/Application Support and trash Adobe.
    Try installing the CC app's and let us know if still the error persists.
    Regards,
    Romit Sinha

  • I am getting this message from iTunes on my iMac: An error occurred while contacting the radio tuning service. Check your Internet connection, or try again later. Can't find a way to fix this. anyone hae any suggestions?

    Question: I am getting this message from iTunes on my iMac:
    An error occurred while contacting the radio tuning service. Check your Internet connection, or try again later.
    Can't find a way to fix this. Does anyone have any suggestions?

    Yeaaaah... I just powered up my G3 iMac... iTunes 7 on there... My iTunes on there can't do much. But it's still subscribed to one podcast that's still valid and working. If I try to use the radio, I get this message. I wager they changed urls and the like in the background years ago and this is just so old there's no longer any support for it.

  • HT201210 i get this messages when restoring my ipad an unknown error occurred (1602)

    i get this messages when restoring my ipad an unknown error occurred (1602)

    ok---I stopped the sync process of photos and now everything else syncs but still cannot eject my ipod.  Will try other tips on this website.  Thank you

  • HT201514 I keep getting this message "Unable to complete back up an error has occurred while creating back up folder" Why is this happening and is it time to purchase a new tim machine?

    I keep getting this message “Unable to complete back up an error has occurred while creating back up folder” Why is this happening and is it time to purchase a new tim machine?

    Check out the Apple Support Communities Time Machine expert Pondini's troubleshooting article on this exact topic. Hopefully, it will help.

  • I am really angry that I get this message every time I try to update Itunes.  "The File 'C:/documents and settings\DEAN\Local Settings\Application Data\Apple\Apple Software Update\itunes.msi' is not a valid installation package for the product itunes.  Tr

    I am really angry that I get this message every time I try to update Itunes.
    “The File ‘C:/documents and settings\DEAN\Local Settings\Application Data\Apple\Apple Software Update\itunes.msi’ is not a valid installation package for the product itunes.  Try to find the installation package ‘itunes.msi’ in a folder from which you can install itunes.
    What kind of gobbledegook is that?  Are you or Microsoft crazy.  Us computer users need simpler instructions.  Or you need to write your programs so that they work.
    Signed,
    Frustrated Apple User
    Dean Weaver

    “The File ‘C:/documents and settings\DEAN\Local Settings\Application Data\Apple\Apple Software Update\itunes.msi’ is not a valid installation package for the product itunes.  Try to find the installation package ‘itunes.msi’ in a folder from which you can install itunes.
    (1) Download the Windows Installer CleanUp utility installer file (msicuu2.exe) from the following Major Geeks page (use one of the links under the "DOWNLOAD LOCATIONS" thingy on the Major Geeks page):
    http://majorgeeks.com/download.php?det=4459
    (2) Doubleclick the msicuu2.exe file and follow the prompts to install the Windows Installer CleanUp utility. (If you're on a Windows Vista or Windows 7 system and you get a Code 800A0046 error message when doubleclicking the msicuu2.exe file, try instead right-clicking on the msicuu2.exe file and selecting "Run as administrator".)
    (3) In your Start menu click All Programs and then click Windows Install Clean Up. The Windows Installer CleanUp utility window appears, listing software that is currently installed on your computer.
    (4) In the list of programs that appears in CleanUp, select any iTunes entries and click "Remove", as per the following screenshot:
    (5) Quit out of CleanUp, restart the PC and try another iTunes install. Does it go through properly this time?

  • I'm trying to sync my iphone in IPhoto. I get this message "our MobileMe account information is not correct. The provided login or password is not valid." when I click on the "Open MobileMe Preferences" button, it doesn't take me there.  Help please.

    I'm trying to sync my iphone in IPhoto. I get this message "your MobileMe account information is not correct". "The provided login or password is not valid." when I click on the "Open MobileMe Preferences" button, it doesn't take me there.  Help please.

    Mobile me has been discontinued for over a year.  What system  and iPhoto versions are you running?
    How are you trying to sync?  With Photo Stream or thru iTunes?
    Do you have an iCloud preference pane in your System preferences?
    Do you meet the minimum requirements for iCloud and Photo Stream?
    iCloud: System requirements
    iCloud: Photo Stream FAQ
    OT

  • Getting an error 'CalendarNotify' as null or undefined in the code at SP.UI.ApplicationPages.CalendarNotify line in SharePoint 2013 after migration

    Hello,
    I am getting an error 'CalendarNotify' as null or undefined in the code at SP.UI.ApplicationPages.CalendarNotify in SharePoint 2013 after migration from SharePoint 2010.  The SharePoint calendar is customized to display the events with colors and other
    customizations. 
    It was developed in SharePoint 2010 using client side objects /jquery.  After migration to 2013 stopped working.
    The code looks like in the following url...
    http://www.westpoint.edu/news/SiteAssets/ColorCoding.txt
    Thanks in advance.

    Hi,
    According to your description, my understanding is that the CalendarNotify is null after migrating to SharePoint 2013.
    I suggest you can check if the sp.js has been loaded properly using Internet Explorer Developing Tools. We can use the following script to run function after the sp.js has been loaded.
    ExecuteOrDelayUntilScriptLoaded(somefunction(), "sp.js");
    Here is a detailed article for your reference:
    http://msdn.microsoft.com/en-us/library/jj193034.aspx
    Best Regards
    Zhengyu Guo
    TechNet Community Support

  • I am unable to axcess any adobe software since OS X YOSEMITE took over my laptop. I keep getting this message, "To open Adobe CS5" you need to install the legacy Java SE 6 runtime. Does anyone know what to do. My efforts have not worked.

    I am unable to axcess any adobe software since OS X YOSEMITE took over my laptop. I keep getting this message, "To open Adobe CS5" you need to install the legacy Java SE 6 runtime. Does anyone know what to do? My efforts have not worked.

    and - check with Adobe - would strongly suspect you need to upgrade CS. Strongly consider Creative Cloud, access to the entire TypeKit alone is amazing.
    https://www.adobe.com/creativecloud.html

  • HT203554 MacBook Pro (15-inch, Mid 2010) intermittent black screen or loss of video. Can I still get this problem resolve by Apple or I'm screwed because the MacBook Pro (15-inch, Mid 2010) intermittent black screen or loss of video Quality Program has en

    MacBook Pro (15-inch, Mid 2010) intermittent black screen or loss of video. Can I still get this problem resolve by Apple or I'm screwed because the MacBook Pro (15-inch, Mid 2010) intermittent black screen or loss of video Quality Program has ended?

    You can have Apple replace the logic board, but it will be at your expense.  The free replacement program has ended.
    As a band aid you may try the following:
    https://gfx.io/
    This will allow you to run on only the integrated GPU.
    Ciao.

  • I keep getting this message when I try to transfer a book from the library to overdrive Adept timeout license sign

    I keep getting this message when I try to transfer a book from the library to overdrive Adept timeout license sign

    I keep getting this message when I try to transfer a book from the library to overdrive Adept timeout license sign

  • TS3297 Tried to copy a movie from my iTunes account to my iPhone and keep getting this message--.  iTunes could not copy "L.A." to the iPhone "Michael's iPhone" because of a timeout occurred.

    Tried to copy a movie from my iTunes account to my iPhone and keep getting this message…….  iTunes could not copy "L.A." to the iPhone "Michael's iPhone" because of a timeout occurred.

    I completely understand what is happening. I know that you are connected to the Internet. I made the suggestion because I have seen it work in similar circumstances. The Apple iTunes servers can be a bit fussy about things and sometimes rebooting the router clears up this miscommunication between iTunes and your network.
    Have you tried signing into your account and then try to sync again. Go to Store>View Account. You will have to enter your password. Then try to sync again. Or try signing out completely in Store>Sign out. Quit iTunes, sign in again and then try to sync again.
    Sometimes refreshing settings will help clear up weird problems.

Maybe you are looking for

  • Setup as new or restore iphone to fix battery?

    my iphone 4 was having battery issues, I thought it was because the phone was old I upgraded to a 5 and the battery is lasting me about 4 hours I restored from a backup, is this why? If I setup as new anyway to backup?

  • Voting poll using PHP & MySQL TypeError: Error #2007: Parameter text must be non-null.

    I am getting this back: TypeError: Error #2007: Parameter text must be non-null. at flash.text::TextField/set text() at AS3_Flash_Poll_PHP_MySQL_fla::WholePoll_1/completeHandler() at flash.events::EventDispatcher/dispatchEventFunction() at flash.even

  • Radial Filter non existing in Camera Raw 8.7 on Photoshop CS6

    I've upgraded to Camera Raw 8.7 on my Photoshop CS6 for Mac. I do not have the Radial Filter button in the Camera Raw plugin and I can't access to Camera Raw from the Photoshop's Filter menu. While searching on google for screen shots, I see that I'm

  • ESATA HDD not recognised on cold boot, OK on reboot

    Hi, I have a HP Elitebook 8740w from which I have removed the internal HDD and connected an eSATA HDD which is powered from the USB bus (I've done this for security purposes). I'm having a problem whereby when booting at  initial power-on, a Non-Syst

  • Line items restriction in sales order

    Hi, how to restrict enduser to enter 10 line items if he enters more than 10 line items system has to restrict.What settings we have to done for this Regards Karthik.R