Where to put the commit in the FORALL BULK COLLECT LOOP

Hi,
Have the following LOOP code using FORALL and bulk collect, but didnt know where to put the
'commit' :
open f_viewed;
LOOP
fetch f_viewed bulk collect into f_viewed_rec LIMIT 2000;
forall i in 1..f_viewed_rec.count
insert into jwoodman.jw_job_history_112300
values f_viewed_rec(i);
--commit; [Can I put this 'commit' here? - Jenny]
EXIT when f_viewed%NOTFOUND;
END LOOP;
commit;
Thanks,
- Jenny

mc**** wrote:
Bulk collect normally used with large data sets. If you have less dataset such as 1000-2000 records then you canot get such a performance improvent using bulk collect.(Please see oracle documents for this)
When you update records Oracle acquire exclusive lock for that. So if you use commit inside the loop then it will process number of records defined by limit parameter at ones and then commit those changes.
That will release all locks acquired by Oracle and also teh memory used to keep those uncommited transactions.
If you use commit outside the loop,
Just assume that you insert 100,000 records, all those records will store in oracle memory and it will affect all other users performance as well.
Further more if you update 100,000 records then it will hold exclusive lock for all 100,000 records addtion to the usage of the oracle memory.
I am using this for telco application which we process over 30 million complex records (one row has 234 columns).
When we work with large data sets we do not depends with the oracle basic rollback function. because when you keep records without commit itb uses oracle memory and badly slowdown all other processes.Hi mc****,
What a load of dangerous and inaccurate rubbish to be telling a new Oracle developer. Commit processing should be driven by the logical unit of a transaction. This should hold true whether that transaction involves a few rows or millions. If, and only if, the transaction is so large that it affects the size constraints of the database resources, in particular, rollback or redo space, then you can consider breaking that transaction up to smaller transactions.
Why is frequent committing undesirable I hear you ask?
First of all it is hugely wasteful of rollback or redo space. This is because while the database is capable of locking at a row level, redo is written at a block level, which means that if you update, delete or insert a million rows and commit after each individual statement, then that is a million blocks that need to go into redo. As many of these rows will be in the same block, if you instead do these as one transaction, then the same block in redo can be transacted upon, making the operation more efficient. True, locks will be held for longer, but if this is new data being done in batches then users will rarely be inconvenienced. If locking is a problem then I would suggest that you should be looking at how you are doing your processing.
Secondly, committing brings into play one of the major serialization points in the database, log sync. When a transaction is committed, the log buffer needs to be written to disc. This occurs serially for multiple commits. Each commit has to wait until the commit before has completed. This becomes even more of a bottleneck if you are using Data Guard in SYNC mode, as the commit cycle does not complete until the remote log is notified as written.
This then brings us two rules of thumb that will always lead a developer in the right direction.
1. Commit as infrequently as possible, usually at the logical unit of a transaction
2. When building transactions, first of all seek to do it using straight SQL (CTAS, insert select, update where etc). If this can't be easily achieved, then use PL/SQL bulk operations.
Regards
Andre

Similar Messages

  • I have to guess where the comma is the @ sign is and various signals now tell what am i doing wrong on the apple usb keyboard

    I have to guess where the comma is the @ sign is and various signals now tell what am i doing wrong on the apple usb keyboard

    Hello
    This can be verry usefull
    http://support.apple.com/kb/HT2841?locale=en_US
    How to identify keyboard localizations
    HTH
    Pierre

  • I am using iPhoto 11 mail and cannot add more than one recipient in the 'to' line.  When I put a comma in, the recipient's address is deleted.  If I use ' ' with more than one recipient the save grays out.  Any thoughts?

    am using iPhoto 11 mail and cannot add more than one recipient in the 'to' line.  When I put a comma in, the recipient's address is deleted.  If I use '< >' with more than one recipient the save grays out.  Any thoughts?

    I figured it out.  I needed to fix some errors in my account information.  It works fine now.

  • How can we remove the commas from the Formula value in SAP BW BEx query

    Hi All,
    How can we remove the commas from the Formula value in SAP BW BEx query
    We are using the formula replacing with characteristic.The characteristic value needs to be display as number with out commas.
    Regards
    Venkat.

    Do you want to remove the commas when you run the query on Bex Web or in RSRT?
    Regards

  • To change the comma to the point

    I'd like to know if there is the way to change the comma to the point on the keyboard.
    thanks
    Umberto

    Hello,
    On the keyboard:
    Use this:
    http://www.microsoft.com/globaldev/tools/msklc.mspx
    or this:
    http://www.kbdedit.com/
    or this:
    http://www.klm32.com/
    or this:
    http://www.easydesksoftware.com/keyboard.htm
    On a program:
    Use replace:
    report ztest .
    data:char(25) value '5#4#2#&1#&',
    char1(9) type c ,
    char2(4) type c value 'test'.
    replace all occurrences of '#' in char with 'and' .
    replace all occurrences of '&' in char with 'num' .
    replace all occurrences of 'a' in char with char2 .
    write: char.
    Regards,
    Jorge Diogo

  • Error preventing the commit to the database??!

    hi ,
    i have this form i use to modify a record on the database
    i just want to add a date to a certain column but in the browser when i hit the commit
    it says
    JBO-26080 Error while selecting entity for <name of the table>
    i am kind of confused i check the error report site the site that give (very small explanation on the JBO errors) and it says :
    JBO-26080: DMLException
    Cause: An unexpected exception occurred while executing the SQL to fetch data for an entity instance or lock it.
    Action: Fix the cause for the SQLException in the details of this exception.
    which is VERY general so if someone could please clear me on this
    by the way i am using ADF BC and all the attributes have the updatable set to always
    thx carl

    thx for the reply
    yeah it turned out that the squeleton of the table posted on the DB was not the same as the one in jdev
    one table has been removed and it was not in jdev
    i tried the syncronise with database option but this option does not seem to check for this
    why is that?
    what exactly is this option syncronising with the DB? if it is not check for changes inside the table
    thx carl

  • How to handle the bad record while using bulk collect with limit.

    Hi
    How to handle the Bad record as part of the insertion/updation to avoid the transaction.
    Example:
    I am inserting into table with LIMIT of 1000 records and i've got error at 588th record.
    i want to commit the transaction with 588 inserted record in table and log the error into
    error logging table then i've to continue with transaction with 560th record.
    Can anyone suggest me in this case.
    Regards,
    yuva

    >
    How to handle the Bad record as part of the insertion/updation to avoid the transaction.
    >
    Use the SAVE EXCEPTIONS clause of the FORALL if you are doing bulk inserts.
    See SAVE EXCEPTIONS in the PL/SQL Language doc
    http://docs.oracle.com/cd/B28359_01/appdev.111/b28370/tuning.htm
    And then see Example 12-9 Bulk Operation that continues despite exceptions
    >
    Example 12-9 Bulk Operation that Continues Despite Exceptions
    -- Temporary table for this example:
    CREATE TABLE emp_temp AS SELECT * FROM employees;
    DECLARE
    TYPE empid_tab IS TABLE OF employees.employee_id%TYPE;
    emp_sr empid_tab;
    -- Exception handler for ORA-24381:
    errors NUMBER;
    dml_errors EXCEPTION;
    PRAGMA EXCEPTION_INIT(dml_errors, -24381);
    BEGIN
    SELECT employee_id
    BULK COLLECT INTO emp_sr FROM emp_temp
    WHERE hire_date < '30-DEC-94';
    -- Add '_SR' to job_id of most senior employees:
    FORALL i IN emp_sr.FIRST..emp_sr.LAST SAVE EXCEPTIONS
    UPDATE emp_temp SET job_id = job_id || '_SR'
    WHERE emp_sr(i) = emp_temp.employee_id;
    -- If errors occurred during FORALL SAVE EXCEPTIONS,
    -- a single exception is raised when the statement completes.
    EXCEPTION
    -- Figure out what failed and why
    WHEN dml_errors THEN
    errors := SQL%BULK_EXCEPTIONS.COUNT;
    DBMS_OUTPUT.PUT_LINE
    ('Number of statements that failed: ' || errors);
    FOR i IN 1..errors LOOP
    DBMS_OUTPUT.PUT_LINE('Error #' || i || ' occurred during '||
    'iteration #' || SQL%BULK_EXCEPTIONS(i).ERROR_INDEX);
    DBMS_OUTPUT.PUT_LINE('Error message is ' ||
    SQLERRM(-SQL%BULK_EXCEPTIONS(i).ERROR_CODE));
    END LOOP;
    END;
    DROP TABLE emp_temp;

  • My iDVD does not want to encode when I try to burn 2-part movies or series where I put 2 parts onto the disc. I was told before to use only Verbatim DVD-R, which I now do. Still having trouble.

    I was on here 11 months ago with the same encoding problem, where it would get to the encoding part of the burning and would stop, then up would pop up the "Open Finder" box, the one where it says you have put in an empty disc and would you like to eject it, ect.? I was told by the people I was in discussion  with that I should change from cheap dvds to Verbatim DVD-R only and I have, and  switch from "Magic iDVD" to "Create a New Project" and follow the directions there. I did that and for a while, it worked quite well. Now it doesn't. Once in a while there will be a newer movie that it will work on, but only a single and only a newer one that I have just downloaded. I download a lot of series from TV and used to have no problem. Is there any way to fix the encoding problem? I really need help on this and would really appreciate anyone who could give me assistance. And while I'm asking, are there any free cleaning services? I'm on a fixed income and can't afford to buy a computer cleaning service. I have gone to Disk Utility and gone through that, but that's all I can do.

    Hi
    There can be so many things that lead to this. As You download - then my first thought is
    In What Video-Codec ?
    There is no standard only out there but zillions of Codecs
    iDVD and iMovie are very selective in what they can use - sometimes they try and it looks like they manage - till the final DVD is to be tested in a standard DVD-player and fails.
    A. Open Your Movie (to be used) with QuickTime-Player (can handle so many more Codecs)
    B. If it play OK here - then Open Inspector [cmd+I] and read:
    Video Formatted (Codec) as: nnnnnnnnnnnnnnnnn
    Frames per second: YY.yy
    What does they say ?
    Else what I can think of is in this note:
    Trouble-shooting guide
    When iMovie doesn't work as intended this can be due to a lot of reasons
    • iMovie Pref files got corrupted - trash it/they and iMovie makes new and error free one's
    • Creating a new User-Account and log into this - forces iMovie to create all pref. files new and error free
    • Event or Project got corrupted - try to make a copy and repair
    • a Codec is used that doesn't work
    • problem in iMovie Cache folder - trash Cache.mov and Cache.plist
    • version miss match of QuickTime Player / iMovie / iDVD
    • preferences are wrong - Repair Preferences
    • other hard disk problem - Repair Hard Disk (Disk Util tool - but start Mac from ext HD or DVD)
    • External hard disks - MUST BE - Mac OS Extended (hfs) formatted to work with Video
    ( UNIX/DOS/FAT32/Mac OS Exchange - works for most other things - but not for Video )
    • USB-flash-memories - do not work (usually)
    • Net-work connected hard disks - do not work&#8232;(usually)
    • Run a Cleaning-DVD (no liquid - but the kind with brushes) - from time to time - I do
    • iPhoto Library got problems - let iPhoto select another one or repair it. Re-build this first then try to re-start iMovie.
    This You do by
    - close iPhoto
    - on start up of iPhoto - Keep {cmd and alt-keys down}
    - now select all five options presented
    - WAIT a long long time
    • free space on Start-Up (Mac OS) hard disk to low (<1Gb) - I never go under 25Gb free space for SD-Video (4-5 times more for HD)
    • external devices interferes - turn off Mac - disconnect all of them and - Start up again and re-try
    • GarageBand fix - start GB - play a few notes - Close it again and now try iMovie
    • Screen must be set to million-colors
    • Third-party plug-ins doesn't work OK
    • Run "Cache Out X", clear out all caches and restarts the Mac
    • Let Your Mac be turned on during one night. At about midnight there is a set of maintenance programs that runs and tidying up. This might help
    • Turn off Your Mac - and disconnect Mains - for about 20-30 minutes - at least this resets the FireWire port.
    • In QuickTime - DivX, 3ivx codec, Flip4Mac, Perian etc - might be problematic - temporarily move them out and re-try
    (I deleted the file "3ivxVideoCodec.component" located in Mac HD/Library/Quicktime and this resolved my issue.)
    buenrodri wrote
    I solved the problem by removing the file: 3ivxVideoCodec.component. after that, up-dated iMovie runs ok.
    Last resort: Trash all of iMovie and re-install it
    Yours Bengt W

  • How does the system decide where to put a file on the desktop?

    So you've just created some sort of file, and you choose to save it to the desktop.   A second later--presto!--the file icon appears on the screen.
    How does the computer decide where on the desktop to put that icon?

    I'm not 100% on this, but I think the system will save files to the last destination you nominated unless you designate another destination at the point of saving. I guess you previously saved something to the Desktop.
    Just tested it on my two Macs and that's how it behaves here.

  • Where to put Get URL on the timeline?

    Ok if i have a symbol
    and i double click it then can i put a get URL? Or where on the timeline
    should it go.

    Take your symbol, a movieclip or a button, and place it on the stage.  Don't doubleclick it or anything, just have it selected and in the Properties panel assign it an instance name (where it says "<Instance Name>")... Let's say you name it "urlBtn", ...no special reason.
    Make a new layer on the timeline and label it actions (or something to indicate it's a code layer).  In the same frame as where the button is, but on the actions layer put your getURL code using the instance name you assigned...
    urlBtn.onRelease = function(){
         getURL(http://www....etc,"_self");

  • Put comma in the amount field

    Hi Experts,
    I need to put the comma in the amount field.
    eg: 3000.00 as 3,000.00.
    Is there any FM which can do this conversion.
    Thanks In Advance
    Asish

    The best way is type casting.
    Ex:
    Data: amount(10) Type p decimals 2.
    Value = '3000'.
    WRITE VALUE TO amount.
    Write amount.  "3,000
    Close the thread once your question is answered.
    Regards,
    SaiRam

  • Commit inside the procedure..

    Hi,
    I have a 3 procedure, which conatain the INSERT, MERGE and then UPDATE.
    I need to put a COMMIT, inside the every procedure. if i leave the commit, when it will be committed.
    Please explain.
    -Sathya

    > I have a 3 procedure, which conatain the INSERT,
    MERGE and then UPDATE.
    need to put a COMMIT, inside the every procedure. if
    i leave the commit, when it will be committed.
    Generally, we can use commit at the end of the procedure and before the exception segment starts. But, since you are calling three procedures - you have to evalaute the bussiness logic of your coding. If it is stated that combination of these three procedure ultimately considered as one work. To establish that - you have to use commit inside the main block from where these three procedure is called.
    Ex:
    Procedure aaa()
       procedure x1( );  --performs some dml
       procedure x2( ); -- again perform some dml
       procedure x3( ); -- perform some final dml
      commit;   -- here you should use the commit
    exception
      when others then
         rollback;The reason is, if there is any exception between the three procedure - all the transactions will be rolled back - thus achieving it as logical unit work.
    Hope this will clear your doubt.
    Regards.
    Satyaki De.

  • Converting the comma seperator value  format

    i am getting the content of a table in a internal table with comma separator value format, dynamically by using dfies table i am getting the header of the table, and displaying it in the output, now my query is that the content of the data which i am getting in a itab having only one field of type string
    data : begin of itab occurs 0,
              data1 type string,
             end of itab.
    some where they were concatenating the content of the data and storing it inthe itab, now i want the content of the itab should be displayed corresponding to there header in the output

    Hi Santosh,
    You can remove the commas from the record by using the REPLACE command as below -
    LOOP AT itab.
      DO.
        REPLACE ',' WITH '' INTO itab-data1.
        IF sy-subrc NE 0.
          EXIT.
        ENDIF.
      ENDDO.
    ENDLOOP.
    Reward points if found useful...!
    Cheers
    Abhishek

  • How to rtrim the extra comma at the end

    Dear Gurus,
    I am trying to trim the extra comma at the end of the sentence but I am not able to trim it at all this is for cursor loop in formula column trigger. Is RTRIM a rightful command to use here! Any Suggestions.
    for c1 in (select crv.x crc
    from x table
    where crv.x = xyz)
    loop
    if     p_count >= 1 then
         v_descr := v_descr||C1.CRC||', ' ;
    end if;
    end loop;
    return rtrim(v_descr,',');
    RESULT IS = ' 010, 002, 115, '

    Dear,
    Instead of using rtrim function, you can get the desired result by adding a code line and placing the comma at the start as below:
    (the added code lines are in bold)
    if p_count >= 1 then
    if v_descr = '' then
    v_descr := C1.CRC;
    else
    v_descr := v_descr||', '||C1.CRC;
    end if;
    end if;
    end loop;

  • Sql report on item - problem with commas in the string

    I have a simple report that groups all the Job Titles entered on our database.
    I pass the job title to an apex item and then on a second page list the records that match that job title using:
    and ed.ede_job_title = :P35_JOB_TITLE
    If there is a comma in the job title the report returns the records that match the string up to the point the comma appears not the full string.
    So 'Project Manager, Operations' matches all the 'Project Manager' records.
    Also when there is a leading space in the job title the report displays the jobtitle without the leading space.
    Apologies if this is answered elsewhere, I did search.

    Check the actual URL up in the location bar. Your comma may actually be dropping out there, because it isn't encoded such that in value commas can be differentiated from delimiters, so the fields aren't lining up in the URL properly.
    When you go to a page that takes in parameters for assignment in the link, it has 2 fields. The first is the comma separated list of the item names on the page to assign, which wouldn't contain commas in their names. The other field in the URL is a comma separated list of values to be assigned to the previous list. Since these values aren't encoded, the comma in the value is picked up as delimiter and not a part of the value. I have an example I can load up to apex.oracle.com if you need.
    -Richard
    Edited by: rwendel on Aug 13, 2009 11:51 AM

Maybe you are looking for