The commit statement

Please can someone explain the purpose of issuing a commit in a batch processing script - and when this should be performed?
I am processing 50 million rows of data, from one table to another (with some rows excluded on the insert into table 2, from table 1).
I am not using a direct load into table 2, but using pl/sql with bulk fetches and FORALL loads (I am doing this as I need to examine each row individually and perform additional processing). Currently I am committing after each 100 rows - but I am wondering whether I need to do this, and whether I need to commit at all. Table 2 is a global temporary table so the data is only required in the specific session.
Am I incorrectly committing?
Thanks

Every commit runs LGWR process to write data to physical REDO LOGS files. So it can have great impact on your performacne. I think commiting after every 100 rows is too often. On the other hand you need to commit your work after inserting some amount of data. How often? It depends. For example it depends on your SGA size.

Similar Messages

  • Comment after the commit statement.

    Hi Everyone,
    Please do have a look at this.
    Commenting on COMMIT: Example The following statement commits the current transaction and associates a comment with it:
    COMMIT COMMENT 'In-doubt transaction Code 36, Call (415) 555-2637';
    Now where can I see that comment? What is the data dictionary, which will have this detail?
    Regards,
    BS2012.

    If you look into the document for the COMMIT statement you will see this.
    COMMENT Clause
    Specify a comment to be associated with the current transaction. The 'text' is a quoted literal of up to 255 bytes that Oracle Database stores in the data dictionary view DBA_2PC_PENDING along with the transaction ID if a distributed transaction becomes in doubt. This comment can help you diagnose the failure of a distributed transaction.

  • Commit statement in badi method

    hi all,
    i am using commit statement in badi method save_data, it is put after function module,
    in function module i have used insert and update statement, if i do like that then the commit statement refresh the global data but update the table,
    if i create one perform inside function module and put commit statement in that perform, then it shows message update was terminated,
    i also want the global data for processing thats why i can't use commit statement after FM in method, please give Suggestion,
    Points will be awarded.

    Hi,
    sounds as if you call that FM in update task. Update function modules do not allow all actions. They should only include the neccessary SQL statements and must include any COMMIT.
    For more information read SAPDOCU of COMMIT WORK and everything of SAPS update concept (start immed. V1, start delayed V2 and so on).
    ATTENTION. Most BADIs designed to save customers data may be used several times and standard data may be saved after them. To avoid inconsistent data inside those BADIs normally no COMMIT should be done.
    Kind regards,
    HP

  • How can i undo the commit

    Hi,
    can any1 plz help me.........
    Can we undo/rollback the data after using the commit statement 2-3 times and want to retrieve the data that i do the commit first time
    Regards
    M. Laeeque A.

    SQL> create undo tablespace abhishek datafile '/oradata/rtrs/a.dbf' size 5M ;
    Tablespace created.
    SQL> !ls -lrt /oradata/rtrs/a.dbf
    -rw-r----- 1 oracle dba 5251072 Mar 6 13:59 /oradata/rtrs/a.dbf
    SQL> select (5251072/1024/1024) from dual;
    (5251072/1024/1024)
    5.0078125
    SQL> alter system set undo_tablespace=abhishek scope=memory;
    System altered.
    Check for the undo usage
    1 SELECT a.name,b.status
    2 FROM v$rollname a, v$rollstat b
    3 WHERE a.name IN ( SELECT segment_name
    4 FROM dba_segments
    5 WHERE tablespace_name = 'abhishek' )
    6* AND a.usn = b.usn
    SQL> /
    no rows selected
    if no usage is there try to resize
    SQL> alter database datafile '/oradata/rtrs/a.dbf' resize 2M;
    Database altered.
    SQL> !ls -lrt /oradata/rtrs/a.dbf
    -rw-r----- 1 oracle dba 2105344 Mar 6 13:57 /oradata/rtrs/a.dbf
    SQL> select (2105344/1024/1024) from dual;
    (2105344/1024/1024)
    2.0078125
    for future resize ur undo_retention by alter system
    HTH
    Abhishek Gera

  • How to count " How many times the ' commit work ' Statement is executed.

    Hi all sap Champions,
    One of the client requirement, That is
    How to count " How many times the ' commit work ' Statement is executed.
    It's urgent.
    Please can anybody help me for this.
    Thanks
    Basu

    hi,
    when report try like this.
    declare a variable as
    data: counter type i value 0.
    COMMIT.
    counter = counter + 1.
    write:/10 counter 'NO. OF TIMES COMMIT WORKED'.

  • Issue while using SUBPARTITION clause in the MERGE statement in PLSQL Code

    Hello All,
    I am using the below code to update specific sub-partition data using oracle merge statements.
    I am getting the sub-partition name and passing this as a string to the sub-partition clause.
    The Merge statement is failing stating that the specified sub-partition does not exist. But the sub-partition do exists for the table.
    We are using Oracle 11gr2 database.
    Below is the code which I am using to populate the data.
    declare
    ln_min_batchkey PLS_INTEGER;
    ln_max_batchkey PLS_INTEGER;
    lv_partition_name VARCHAR2 (32767);
    lv_subpartition_name VARCHAR2 (32767);
    begin
    FOR m1 IN ( SELECT (year_val + 1) AS year_val, year_val AS orig_year_val
    FROM ( SELECT DISTINCT
    TO_CHAR (batch_create_dt, 'YYYY') year_val
    FROM stores_comm_mob_sub_temp
    ORDER BY 1)
    ORDER BY year_val)
    LOOP
    lv_partition_name :=
    scmsa_handset_mobility_data_build.fn_get_partition_name (
    p_table_name => 'STORES_COMM_MOB_SUB_INFO',
    p_search_string => m1.year_val);
    FOR m2
    IN (SELECT DISTINCT
    'M' || TO_CHAR (batch_create_dt, 'MM') AS month_val
    FROM stores_comm_mob_sub_temp
    WHERE TO_CHAR (batch_create_dt, 'YYYY') = m1.orig_year_val)
    LOOP
    lv_subpartition_name :=
    scmsa_handset_mobility_data_build.fn_get_subpartition_name (
    p_table_name => 'STORES_COMM_MOB_SUB_INFO',
    p_partition_name => lv_partition_name,
    p_search_string => m2.month_val);
                        DBMS_OUTPUT.PUT_LINE('The lv_subpartition_name => '||lv_subpartition_name||' and lv_partition_name=> '||lv_partition_name);
    IF lv_subpartition_name IS NULL
    THEN
                             DBMS_OUTPUT.PUT_LINE('INSIDE IF => '||m2.month_val);
    INSERT INTO STORES_COMM_MOB_SUB_INFO T1 (
    t1.ntlogin,
    t1.first_name,
    t1.last_name,
    t1.job_title,
    t1.store_id,
    t1.batch_create_dt)
    SELECT t2.ntlogin,
    t2.first_name,
    t2.last_name,
    t2.job_title,
    t2.store_id,
    t2.batch_create_dt
    FROM stores_comm_mob_sub_temp t2
    WHERE TO_CHAR (batch_create_dt, 'YYYY') = m1.orig_year_val
    AND 'M' || TO_CHAR (batch_create_dt, 'MM') =
    m2.month_val;
    ELSIF lv_subpartition_name IS NOT NULL
    THEN
                        DBMS_OUTPUT.PUT_LINE('INSIDE ELSIF => '||m2.month_val);
    MERGE INTO (SELECT *
    FROM stores_comm_mob_sub_info
    SUBPARTITION (lv_subpartition_name)) T1 --> Issue Here
    USING (SELECT *
    FROM stores_comm_mob_sub_temp
    WHERE TO_CHAR (batch_create_dt, 'YYYY') =
    m1.orig_year_val
    AND 'M' || TO_CHAR (batch_create_dt, 'MM') =
    m2.month_val) T2
    ON (T1.store_id = T2.store_id
    AND T1.ntlogin = T2.ntlogin)
    WHEN MATCHED
    THEN
    UPDATE SET
    t1.postpaid_totalqty =
    (NVL (t1.postpaid_totalqty, 0)
    + NVL (t2.postpaid_totalqty, 0)),
    t1.sales_transaction_dt =
    GREATEST (
    NVL (t1.sales_transaction_dt,
    t2.sales_transaction_dt),
    NVL (t2.sales_transaction_dt,
    t1.sales_transaction_dt)),
    t1.batch_create_dt =
    GREATEST (
    NVL (t1.batch_create_dt, t2.batch_create_dt),
    NVL (t2.batch_create_dt, t1.batch_create_dt))
    WHEN NOT MATCHED
    THEN
    INSERT (t1.ntlogin,
    t1.first_name,
    t1.last_name,
    t1.job_title,
    t1.store_id,
    t1.batch_create_dt)
    VALUES (t2.ntlogin,
    t2.first_name,
    t2.last_name,
    t2.job_title,
    t2.store_id,
    t2.batch_create_dt);
    END IF;
    END LOOP;
    END LOOP;
    COMMIT;
    end;
    Much appreciate your inputs here.
    Thanks,
    MK.
    (SORRY TO POST THE SAME QUESTION TWICE).
    Edited by: Maddy on May 23, 2013 10:20 PM

    Duplicate question

  • How to execute commit statement in a procedure optionally?

    We have a procedure which has DML operations and at the end there is a commit statement.
    I want to execute commit statement optionally.
    Like, when procedure runs directly it must execute commit statement, but when this procedure is called from a trigger don't run commit.
    As you know commit operation is not allowed in triggers.
    How can I understant the code is triggered from a trigger or any other (manuel exec or from another procedure).
    I am looking for the reserved word that solve my problem. Like INSERTING, DELETING ....
    Serkan
    Thanks.

    Hi oraserkan,
    You do of course know it's dangerous to have a commit inside a procedure?
    Consider this:
    SQL> create table t (text varchar2(25))
    Table created.
    SQL> create or replace procedure p
    as
    begin
       insert into t(text)
           values ('Insert PROCEDURE');
       commit;
    end p;
    Procedure created.
    SQL> insert into t(text)
        values ('Insert SQL')
    1 row created.
    SQL> exec p
    PL/SQL procedure successfully completed.
    SQL> rollback
    Rollback complete.
    SQL> select * from t
    TEXT                    
    Insert SQL              
    Insert PROCEDURE        
    2 rows selected.You should instead clearly state the procedure has a commit by making it autonomous, and then have two procedures, one that commits, and one that don't
    SQL> drop procedure p
    Procedure dropped.
    SQL> drop table t purge
    Table dropped.
    SQL> create table t (text varchar2(25))
    Table created.
    SQL> create or replace procedure p_transactional
    as
    begin
       insert into t(text)
           values ('Insert PROCEDURE');
    end p_transactional;
    Procedure created.
    SQL> create or replace procedure p_autonomous
    as
       pragma autonomous_transaction;
    begin
       p_transactional;
       commit;
    end p_autonomous;
    Procedure created.
    SQL> insert into t(text)
        values ('Insert SQL')
    1 row created.
    SQL> exec p_autonomous
    PL/SQL procedure successfully completed.
    SQL> rollback
    Rollback complete.
    SQL> select * from t
    TEXT                    
    Insert PROCEDURE        
    1 row selected.
    SQL> drop procedure p_transactional
    Procedure dropped.
    SQL> drop procedure p_autonomous
    Procedure dropped.
    SQL> drop table t purge
    Table dropped.Regards
    Peter

  • How to get the previous state of my data after issuing coomit method

    How to get the previous state of some date after issuing commit method in entity bean (It should not use any offline storage )

    >
    Is there any way to get the state apart from using
    offline storage ?As I said the caller keeps a copy in memory.
    Naturally if it is no longer in memory then that is a problem.
    >
    and also what do you mean by auditlog?
    You keep track of every change to the database by keeping the old data. There are three ways:
    1. Each table has a version number/delete flag for each record. A record is never updated nor deleted. Instead a new record is created with a new version number and with the new data.
    2. Each table has a duplicate table which has all of the same columns. When the first table is modified the old data is moved to the duplicate table.
    3. A single table is used which has columns for 'table', 'field', 'data' and 'activity' (update, delete). When a change is made in any table then this table is updated. This is generally of limited useability due to the difficulty in recovering the data.
    All of the above can have a user id, timestamp, and/or additional information which is relevant to the data being changed.
    Note that ALL of this is persisted storage.
    I am not sure what this really has to do with "offline storage" unless you are using that term to refer to backed up data which is not readily available.

  • 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

  • COMMIT statement

    Hi Guys,
    I have a RFC function module which updates a field on the Portal side and no updates are done on the R/3 side. I pass parameters to the FM and it updates the field on the portal side.So do we need a COMMIT statement in this situation.
    IS COMMIT statement necessary for every BAPI or RFC function module. What are the situation under which a COMMIT statement is used.

    Hi,
    IF you are exporting a data from SAP to other system you doesn't need this but if you are importing a data from others systems to SAP you need to use the statement COMMIT WORK.
    COMMIT WORK is required for transactions developed externally to the R/3 System that change data in the R/3 System via BAPI calls.
    When you call BAPIs in your program that change data in the R/3 System, afterwards you must call this the FM "BAPI_TRANSACTION_COMMIT" to write the changes to the SAP database.                                                                 
    <b>Use function module BAPI_TRANSACTION_COMMIT to do this.</b>
    Regards.
    Marcelo Ramos

  • Can call a function in the select statement?

    Is there any ways to call a function in the select statement?
    what I like to do is this:
    select deptno, totalEmployees(deptno), TotalSalary(deptno)
    from emp;
    I know it can be done by count(*) and join tables, but my case
    is much more complex and the where clauses are different from
    one function to another, and have many tables to join and many
    combinations
    Thanks

    Functions can be used in a select statement subject to certain
    restrictions, see
    http://otn.oracle.com/docs/products/oracle8i/doc_library/817_doc/
    server.817/a85397/statem9b.htm#2062024
    It's under "CREATE FUNCTION> Keywords and Parameters> function>
    Restrictions on User-Defined Functions"
    Here is an except...
    When a function is called from within a query or DML statement,
    the function cannot:
    a) Have OUT or IN OUT parameters
    b) Commit or roll back the current transaction, create or roll
    back to a savepoint, or alter the session or the system. DDL
    statements implicitly commit the current transaction, so a user-
    defined function cannot execute any DDL statements.
    c) Write to the database, if the function is being called from a
    SELECT statement. However, a function called from a subquery in
    a DML statement can write to the database.
    d) Write to the same table that is being modified by the
    statement from which the function is called, if the function is
    called from a DML statement.
    Except for the restriction on OUT and IN OUT parameters, Oracle
    enforces these restrictions not only for the function called
    directly from the SQL statement, but also for any functions that
    function calls, and on any functions called from the SQL
    statements executed by that function or any function it calls.

  • Commit statement in user exit

    Hi All,
    We found that while doing PGI , it takes some time to COMMIT the table VBUK. Due to which we are getting old values of VBUK-KOSTK field while executing select query at later point of time in the flow.
    My question --
    Can I use COMMIT WORK statement in user exit MV50AFZ1 --> FORM USEREXIT_SAVE_DOCUMENT so that all the related tables
    get committed immediately.
    Thanks
    Saurabh

    Hi Saurabh ,
    Normally , you shoud not specify COMMIT stmt in any user exit , badi etc..
    SAP has its own COMMIT statement while execuiting the standard transactions .
    Addition of a COMMIT might lead to problems elsewhere .
    Thanks
    Supriya

  • Stateless Release mode and the Commit issue

    What are the implications of setting all the application modules to Stateless Release mode rather than Stateful?
    I’ve read the documentation about this, but I need hands on expert’s opinions
    Specially for a Web Application that a lot of public users will use?
    We have an issue of the way commit work, if we edit a page and then navigate without saving to another page and then save at this second page, the commit will save all changes that have been done in both pages, even of the two pages are bound to two different VOs and two different Application modules, it is really strange, it seems that I need to know that the user is leaving the page so I can rollback, I do not understand this default behavior of ADF/BC ..
    Any work around? Any opinions?

    Hi,
    the behavior is correct as it commits all pending changes. The release mode tells ADF BC how the application module is released to the pool if no longer needed by the user session. If release mode is stateful then the state of the current AM is passivated so it can be recovered. This has nothing to do with the page to page navigation.
    If you want to undo changes performed on a page when navigation off the page, you call refresh(Row.DB_ROW...) on the current row
    Frank

  • WCF Service update UPS. Operation is not valid due to the current state of the object.

    I try import custom data to custom user properties from my own wcf service (on sharepoint server machine), but i got
    Message "Operation is not valid due to the current state of the object. "
    on line
    userProfile[PropertyConstants.Department].Value = "SDDDD";
    Why i cant modify property value?
    SPSecurity.RunWithElevatedPrivileges(delegate()
    using (SPSite site = new SPSite("http://portal.local"))
    SPServiceContext serviceContext = SPServiceContext.GetContext(site);
    using (var web = site.OpenWeb())
    Debug.WriteLine(web.CurrentUser); //Here AppPoolAccount user of current wcf service
    Debug.WriteLine(WindowsIdentity.GetCurrent().Name); //Here too AppPoolAccount user of current wcf service
    UserProfileManager userProfileMgr = new UserProfileManager(serviceContext);
    ProfilePropertyManager profilePropMgr = new UserProfileConfigManager(serviceContext).ProfilePropertyManager;
    ProfileSubtypePropertyManager subtypePropMgr = profilePropMgr.GetProfileSubtypeProperties("UserProfile");
    UserProfile userProfile = userProfileMgr.GetUserProfile(accountName);
    userProfile[PropertyConstants.Department].Value = "SDDDD";
    userProfile.Commit();
    My service running under domain\SPSvcAcc what have full permissions on UPS service, it's management account and UPS admin with full rights.
    If i create console app with identical code and run it under SPSvcAcc account it working without problems
    What i do wrong?

    Hi,
    pls seee if you can add threading like this below to solve the pbm
    https://social.technet.microsoft.com/Forums/office/en-US/b6d6f85c-e12b-4540-a821-690e296b7b56/operation-is-not-valid-due-to-the-current-state-of-the-object-exception-when-activating-a?forum=sharepointdevelopmentprevious
    Please remember to click 'Mark as Answer' on the answer if it helps you

  • Each procedure have commit statement

    I call five procedure individually, and each procedure have commit statement from .net environment i.e. click event of submitt button call five procedure
    but now i want only one commit statement for all five proceduce if all procedure successfully
    executed.
    suppose first two procedure successfully execute then third procedure raise some exception, in that case previously execute procedure data successfully comitted, but i want them rollback because all five procedure does not successfully execute.

    What does this have to do with OCI? Sounds like a transaction control question...
    The answer is to commit at the end of the transaction from the client code, and not at the end of each procedure call.

Maybe you are looking for

  • How do i transfer photos from camera roll to photostream on my iPad2?

    I have 100s of pics on my iPad2 and set up Photostream ages ago, but only 2 pics are on it. I want to transfer all of my photos to Photostream so they appear in iCloud and so I can delete them from iPad2 and free up storage space. How do I do this?

  • Plot a Chart from sql query

    Hi I am trying a plot a graph using the values from one of my table. I am filtering the data using timestamps. When I use direct SQL against the database it is retrieving all the data. However When I am using the same SQL query to plot a 2D line Grap

  • Logical & Physical Standby

    1) Is Logical Standby built up on Log Miner? 2) Is it not possible to use Logical Standby without turning on supplemental logging? 3) Is there any relationship between LGWR & LNS in Log Transport Mode?

  • About the Classic scenario,ERP PO number didn't return go Shopping card

    About the Classic scenario,We create a shopping card,And approved,the follow document purchaser order create the ERP system,But the Purchaser order number didn't return to the shopping card follow document tab page.How can help me?

  • Can't activate a old phone, help!

    My aunt was on my plan but she switched to Cox yesterday. She gave me her old phone because mine barely works. I tried to activate it yesterday, online and by phone, and they both told me it couldn't be done because the phone must be deactivated firs