Question about VALIDATION and EXCEPTION loop

DB version: 11.2

I believe the gurus here despise is committed inside loops. Due to budgetary constraints our java colleagues write code PL/SQL here. Below is an excerpt from a stored procedure that does some archive stuff.


Question on COMMIT
=====================
I know is committed to the inside of the loops is bad, but I just want to know if the path that they have implemented COMMIT frequency is correct (using the number of iterations). Their intention was to commit all 200,000 records.


Question on EXCEPTION
======================
LMD like that, isn't better to have the exception block in the loop?




 
 
select po.txn_id, po.po_id BULK COLLECT into v_txn_id, v_po_id 
from purchase_orders po inner join txn_pkt_common tc 
on tc.txn_id = po.txn_id
and tc.created_date < po.last_mod_date;


v_rec_count := 0;


IF v_txn_id IS NOT NULL AND v_txn_id.COUNT > 0 THEN


     FOR i IN v_txn_id.FIRST .. v_txn_id.LAST LOOP

          v_rec_count := v_rec_count + 1;

          INSERT INTO purchase_orders_archive SELECT * FROM purchase_orders WHERE po_id = v_po_id(i);

          DELETE FROM purchase_orders WHERE po_id = v_po_id(i);


          IF v_rec_count >= 200000 THEN
          COMMIT;
          v_rec_count := 0;
          END IF;

      END LOOP;
     COMMIT; 

end if;

ExpansiveMind wrote:
DB version: 11.2

I believe the gurus here despise is committed inside loops.

Cursor inside the lines, Yes, but this isn't a case of contemptuous, it's more to do this is to knowingly introduce a bug in your code, resulting in a possible "snapshot too old" error So, good programmers do not.

Question on COMMIT
=====================
I know is committed to the inside of the loops is bad, but I just want to know if the path that they have implemented COMMIT frequency is correct (using the number of iterations). Their intention was to commit all 200,000 records.

Q: Why is there the intention to commit all 200,000 records? What is the issue they're trying to move?

In your example code, it is the data block collection. Is it really in collector block + 200,000 records? If so you may have a serious impact on the resources of database data are collected in the memory of the PGA, which is expensive.

Question on EXCEPTION
======================
LMD like that, isn't better to have the exception block in the loop?

That depends on what you want to do when an exception occurs. If the exception can be 'managed' and you want to continue processing the rest of the data, then Yes, you would want an exception around the DML inside the loop block. If an exception should cause processing to stop completely, then you want the exception handler (if you really need one) out of the loop... but then you wonder again why you make inside the loop, because it is not supposed transaction.

All of this procedure looks like this could be done with a single INSERT statement followed a single DELETE statement, followed by a unique validation. Oracle can easily handle millions of records, so it shouldn't be a problem.

The other problem with frequent postings is that each commit tells oracle to write the data to the data blocks, and these 'write' get statements go in the database for the writer to manage processes. By default, there are X number of writer running process (depends on version and other parameters) when the database starts, but if a large number of postings is published then Oracle begins to generate additional editor on the server processes to manage the extra workload, which can then cause a lot of writer running process (using the resources of the server) all trying to access the same load of blocks of data in terms of physical i/o and therefore all the other slows down. This is why frequent postings are not a good thing, and you must book to engage in logical business transactions.

Tags: Database

Similar Questions

  • About a month ago I posted a question about iMovie and not being able to "share". I solved the problem thanks, so no more emails!

    About a month ago I posted a question about iMovie and not being able to "share". I solved the problem thanks, so no more emails!

    Hi Michael,

    If you want to stop receiving notifications by electronic mail, in the thread, that you have created, then I suggest that you follow the steps below:

    One time connected to the Apple Support communities, visit your mini profile and select manage subscriptions.

    Content

    To manage this content, you are currently subscribed and changing your preferences, select the content.

    Select next to see what content you are currently following.  Note that any thread you are responding you subscribe you automatically to this thread.

    You can select to terminate a subscription to a thread.

    Learn how to manage your subscriptions

    Take care.

  • Question about business and Service of Proxy

    Hi friends,
    I have a question about services and proxy services business IE I need to find the time it takes to call an operation on multipoint business of proxy service, how can I do in oracle service bus (OSB)? You can help quickly

    If your question is only about the performance analysis,
    try to activate the 'monitoring' on the 'operational' of the Service Proxy Service/Company tab.
    For the Proxy Services, if you activate at the level of the 'Action' you get a lot of information about each individual action in a power of attorney.

    See http://www.javamonamour.org/2011/06/osb-profiling-your-proxy-service.html

  • A question about ROLLBACK and in stored subprograms unhandled Exceptions

    Hello

    Oracle version:  Enterprise Edition Release 11.2.0.1.0 - 64 bit

    OS :   Linux Fedora Core 17 (X86_64)

    In Chapter 11 of the PL/SQL online, here's what oracle says about The unhandled Exceptions :

    If a stored subprogram stops with an unhandled exception, PL/SQL does not restore of database changes made by the subprogramme.

    I tried the following code:

    code

    HOST clear;

    SET SQLBLANKLINES

    ALTER SESSION SET PLSQL_WARNINGS = ' ENABLE: ALL ';



    DROP TABLE tmptab;

    CREATE TABLE tmptab (n NUMBER);



    CREATE or REPLACE PACKAGE pkg1_pkg

    DEFINE AUTHID

    AS

    EXCEPTION MYEXCEPTION.

    PRAGMA EXCEPTION_INIT (MYEXCEPTION,-20001);

    END;

    /

    DISPLAY ERRORS;



    -It is a subroutine that exists

    -with an exception unhandled

    CREATE OR REPLACE PROCEDURE mytestProc

    DEFINE AUTHID

    IS

    BEGIN

    INSERT INTO tmptab (n) VALUES (100);


    -Unhandled exception does a ROLLBACK
    -which annuls the previous INSERT statement

    RAISE pkg1_pkg. MYEXCEPTION;

    END mytestProc;

    /

    DISPLAY ERRORS;



    BEGIN

    mytestProc();

    END;

    /



    SELECT * FROM tmptab;

    And here is the result

    BEGIN

    *

    ERROR on line 1:

    ORA-20001:

    ORA-06512: at "TRAINING. MYTESTPROC', line 6

    ORA-06512: at line 2


    no selected line

    The fact that SELECT * FROM tmptab gives: no selected line indicates that the exception unhandled in the stored routine myTestProc is doing a ROLLBACK for the INSERT statement in the tmptab table.

    So I do not understand why in the documentation noted that no ROLLBACK is not done.

    Could someone kindly do some clarification on this?

    Thanks in advance,

    Kind regards

    Dariyoosh

    Hello

    If a stored subprogram exits with an unhandled exception, PL/SQL does not restore changes to the database made by the subprogramme.

    What is happening here, it is an anonymous block (which is not stored) stops with an unhandled exception, and who restores the uncommitted transactions.

    I created a procedure to see how many lines is in tmptab:

    CREATE OR REPLACE PROCEDURE tmptab_cnt (in_txt IN VARCHAR2)
    DEFINE AUTHID
    AS
    n PLS_INTEGER;
    BEGIN
    SELECT COUNT (*)
    N
    OF tmptab;

    dbms_output.put_line (n
    || "lines of tmptab in.
    || in_txt
    );
    END tmptab_cnt;
    /

    and called it of your procedure with your anonymous block:

    CREATE OR REPLACE PROCEDURE mytestProc
    DEFINE AUTHID
    IS
    BEGIN
    INSERT INTO tmptab (n) VALUES (100);
    tmptab_cnt ("mytestProc");

    RAISE pkg1_pkg. MYEXCEPTION;
    END mytestProc;
    /
    DISPLAY ERRORS;

    BEGIN
    mytestProc();
    EXCEPTION
    WHILE OTHERS THEN
    tmptab_cnt (anonymous"block" ");
    LIFT;
    END;
    /

    The result of this is:

    ...

    Created procedure.

    No errors.
    1 lines in tmptab in mytestProc


    1 lines in block anonymous tmptab
    BEGIN
    *
    ERROR on line 1:
    ORA-20001:
    ORA-06512: at line 6

    no selected line

    As you can see, there is 1 row in the table after that the procedure back to the anonymous block.

    Thanks for posting such a complete and clear test script; that really helps.

    How put you in the form code, with green background and title?

  • Windows 7 starts questions about mac and office 2010 following an installation

    It's a long cut as short as vent. I've been miss sold a record of upgrade of windows 8 full disk-shaped, with norton and office 2010. My goal of creating windows on my mac for a course I'm taking. After that know I need windows 7, I bought it online. I created a partition of 80g on my mac charge windows 7, then norton. Until I loaded the office that I was invited to perform the update from apple in the windows software 7. Note before I installed norton, I load boot camp mac utilities according to the instructions. So, followed by all as should be. The prompt update from apple was quick time, iTunes and airport, I checked all and then updated. Then I loaded office 2010 and obtained throughout the process from the Microsoft site. On the last part of the installation, the installation failed due to a mistake of hanging iTunes. I tried again and again, I fixed the update to iTunes to add and remove the section of windows. Then, I got different errors. I decided to remove the whole score without uninstalling all programs again. When I get to the windows live, that this falls priming. I get various error messages whenever I try to start the process. As a header of Bank pool, fatal error and so on. Can anyone help? What is the damage?

    Hello

    Thanks for posting your query in Microsoft Community.

    Because the question is limited to Windows 7 on your Mac with Boot Camp, I suggest you contact Apple Boot Camp support for assistance.

    http://www.Apple.com/support/Bootcamp/

    I hope it helps. If you have any questions about Windows in the future, please let us know. We will be happy to help you.

  • Question about snapshots and virtual machines

    Hi all

    I have a small question about snapshots. I use VMware for about 6 months and I read about snapshots and how they work but still have a question to make sure that I understand how it works and it will work the way I think it works.

    I have a Windows 2003 server, which is a virtual machine. I have an application that uses MSDE database. I want to upgrade the database to MS SQL 2005, but to do this I need to back up the MSDE database, uninstall MSDE, and then install SQL 2005 and move the SQL database. This happens on the same VM.

    What I was thinking if I well Snapshots correctly is to snap turned the virtual machine before doing anything. Then do my upgrade steps and see if everything works. If its all messed up so I should be able to return to my shot and everything should be the way he had. What is the good? One of the main reasons I moved the server VM was because of this upgrade.

    After reading the documentation for the snapshots, it's how I undestood it. Pretty much any change could be reversed with snapshots. I wish just they had put in a few examples in the PDF file. Also it would be the same for all type of grades of the OS? Could I snapshot a Windows 2000 Server, and then "in the upgrade of the square" to Windows 2003? I've cloned a VM to do this but was curious about whether snapshots would be just as easy.

    Thanks for your help.

    Hello.

    What I was thinking if I well Snapshots correctly is to snap turned the virtual machine before doing anything. Then do my upgrade steps and see if everything works. If its all messed up so I should be able to return to my shot and everything should be the way he had. What is the good?

    That is right.

    After reading the documentation for the snapshots, it's how I undestood it. Pretty much any change could be reversed with snapshots. I wish just they had put in a few examples in the PDF file. Also it would be the same for all type of grades of the OS? Could I snapshot a Windows 2000 Server, and then "in the upgrade of the square" to Windows 2003? I've cloned a VM to do this but was curious about whether snapshots would be just as easy.

    Exactly the same thing for the upgrades of the OS.

    Perhaps the most important thing with the snapshots is to keep an eye on them and don't let them sit too long or become too big.  You have described the use cases are very good uses for snapshots.  Just make sure you have a solid plan with a schedule set, so that you can come back or validate changes before the snapshot becomes too large.

    Good luck!

  • Question about CR and LF

    Hey guys,.

    Quick question on LF and CR. As you can see I'm LF and CR of writing to a text file and because directly.

    However, I don't get the CR at the time where I read it. Why is this? Is it because Windows ignores the CR?

    Thank you

    Hi dora,

    read the Help for the WriteText function.

    There is an option for handling of CR/LF characters and explained mentioned in the "Advanced" section of the article for help!

  • Question about validations (XACT_COMMITS and XACT_D_COMMITS)

    How it is possible that the values of the XACT_COMMITS and XACT_D_COMMITS parameters have different numbers than 0 when all my groups cache are read only? What else can increment these measures?

    And subsidiary question... What are the parameters that you are proposing to implement sys.odbc.ini for TimesTen will mainly be with reading only cachegroups?

    Published by: lesak on March 9, 2011 12:36

    XACT_COMMITS counst the total number of validations of database wide while XACT_D_COMMITS counts the total number of validations sustainable broad databas. Even for a workload query only there is committed, especially if you have validation. Even if validation doesn't really do anything, it is always counted in these measures. In addition, if you have replkciation or connection cache configured, then agents who manage these functions will assign commits, potentially very frequently.

    This is perfectly normal and nothing to worry about.

    Chris

  • Question about layers and loops!

    Hey guys,.

    I am a newbie and I hope I can explain this scenario properly.

    Basically, I create a banner in Flash 8 Pro, graphic designs previous.     It consists of a backdrop, a 4 frame logo and the text I want to sweep in on the left hand side on 20% of the banner.

    Now! ... is there a way to create a layer to have this text appear on and stop at a desired position, while the main logo covers the 4 frames continuously?   (I had a go, but everything seems to work, in other words, the same steam - no separate command)

    Hope that is more clear as mud?

    All the best,

    CAL

    Hi Cal,

    Or you can create a movieclip (F8) and place your 4 images of logo in this movieclip.

    Then in Scene1 you can place the movieclip on layer logo and on a separate layer have your text flying in animation.

    One thing to remember to do this way is to make sure that your film has enough frames to account for multiples of four, other wise your logo will look like its onece jump the playhead in loop at the beginning.

    Hope that makes sense

  • Question about printing and resolution

    Hello

    I have a trial version of PE13 tries and tries to reconcile with printing and resolution.

    I also read this informative tutorial here:

    How Image resolution affects printing - Photoshop tutorial

    This is the image I want to print:

    PhotoshopQ.jpg

    In the above tutorial, the author states that when printing, resolution 300 is the best and not the 79.3 px/inch I. When I change this 79.3 to 300, the image of Marilyn becomes tiny, so my question is how can I have a picture that would fit perfectly on photo paper A4 with a white 1 "border around itself (which means that the size of the image would be 8" x 6 ") while maintaining a 300 resolution?

    I go about it the right way, am I not?

    Thank you very much.

    Steve

    While the recommended resolution to see images from a short distance is 300 dpi, the normal resolution for screens, which was 72 PPI doe not exceed 90 ppi, except for the new screens hidpi. Which explains the "extended" effect that you see when you look at the 100% view (an impression pixel corresponds to a pixel on the screen). The print size will be what you chose: 6 * 9 inches.

  • Question about native and web-visible content

    Hi all, I am working on an implementation of the ODC/ODDC and AAU, but my question is about native files and web files on the content server. When I send batches analysed using my profile of validation of the ODC to the AAU, the file is automatically converted to pdf format, the content is checked and then this file is copied from the safe to weblayout file folder.

    Is this really necessary? I m request this because if my file size is 1 MB instead of use only 1 MB ucm uses 2 MB for the same content. The original file and the web image file is the same PDF file.

    Is it possible to disable the web visible version just for the PDF files?

    Thanks in advance.

    Hello

    Yes, you can use file store provider and assign webless storage. With this, you can set up a rule and say what pdf archived (using the rule of form of consignment) such as the pdf files is sent to the PSA which does not store / create weblayout files.

    Thank you
    Srinath

  • question about pl/sql exception

    Hi all. the following text is an excerpt from the documentation of the language reference PL/SQL Oracle® database oracle 11g Release 1 (11.1):

    Unhandled exceptions can also affect subroutines. If you exit a subprogram successfully, PL/SQL assigns values to parameters. However, if you come out with an unhandled exception, PL/SQL does not assign values for THE parameters (except if they are NOCOPY parameters). In addition, if a stored subprogram fails with an unhandled exception, PL/SQL does not restore database work carried out by the subprogramme of.

    Note the bold text, is this true? I'm curious about it, so I wrote the following example to test.

    -create a test table
    CREATE TABLE e AS SELECT * FROM HR. EMPLOYEES;

    -create p1 that will update a row in the table e
    CREATE OR REPLACE PROCEDURE p1
    IS
    ex EXCEPTION;
    e line % ROWTYPE;
    BEGIN
    Select * online e where employee_id = 100;

    Row.employee_id: = 100;
    Row.first_name: = 'yang ';

    -updated
    E UPDATE choose the LINE = line where employee_id = 100;
    - and trigger an error
    INVOKE;
    END;

    BEGIN
    -call the above procedure
    P1;
    END;

    -test update if successful
    Select * e where employee_id = 100;

    -the above query gives me
    Steven

    so my question is: am I right?

    Yang,

    This only was not always true... ?

    If a subpraogram fails and generates an unhandled exception, then it is up to the calling program decide what to do with it.

    If none of the programs in the hierarchy above manipulate... then the changes are cancelled because oracle a pseudo code around the entire block similar to:

    savepoint sp1;
      p1;
    if error then rollback to sp1;
    

    -Check this example...

    SQL> create table temp(
      2  id number);
    
    Table created.
    
    SQL> create unique index unq_id on temp(id);
    
    Index created.
    

    -If the program calling nt don't handle the error that the subprgram returns the error returned to Oracle and it cancels the entire transaction.
    -because it's the oracle of how works the transaction...

      1  create or replace procedure p1(i_number in number) as
      2  begin
      3    insert into temp values (i_number);
      4* end;
    SQL> /
    
    Procedure created.
    
    SQL> begin
      2     p1(1);
      3     p1(1);
      4  end;
      5  /
    begin
    *
    ERROR at line 1:
    ORA-00001: unique constraint (SCOTT.UNQ_ID) violated
    ORA-06512: at "SCOTT.P1", line 3
    ORA-06512: at line 3
    
    SQL> select * from temp;
    
    no rows selected
    

    -If the calling program catches the exception... it will speak to the future course of action... commit / rollback...
    In the code below, the error is ignored... and just pinted...

    SQL> ed
    Wrote file afiedt.buf
    
      1  begin
      2    p1(1);
      3    p1(1);
      4  exception
      5    when dup_val_on_index then
      6       dbms_output.put_line('duplicate value inserted...');
      7* end;
    SQL> /
    
    PL/SQL procedure successfully completed.
    
    SQL>  select * from temp;
    
            ID
    ----------
             1
    

    Hope that answers your question...

    -Renon.

    Published by: Rajesh Chamarthi 18 November 2009 22:57 (added for example).

  • Question about warranty and upgrade RAM

    Hello

    I have a new laptop and my question is:

    I lose the warranty if I add a new module of ram to make bigger it?

    Thank you and best regards.

    Upgrade of RAM can be done by the owner of the laptop and it will not void the warranty valid. If you check user s manuals document you will find teaching how that's possible.

    I put t know which model of laptop you have, but make sure that you are using the high quality and 100% compatible modules.

    If you need assistance with this post please exact model laptop.

    Good luck

  • Tecra A2: Question about DVI and external monitor

    Hello
    I am trying to get a DVI Signal of the Tecra A2 using the Advanced Port Replicator III but without success. The A2 does support DVI anyway?
    Another question: is it possible to set up the main display to the external monitor using "extended Desktop"?

    Thank you
    Ralph Menon

    Hello Ralph

    Your unit doesn t support DVI port and you can't use it. As far as I know just the ports that you can find on the device, you can use in Port Replicator because the signal is just loop through.

    The problem with the screen is that mobile has the main value and it cannot be changed (on my Tecra M1 nor). The windows will be implemented on an external but password box will always be displayed on the screen of the laptop.

    Good bye

  • M30-832: Questions about memory and DVD player

    Hi all, new to laptops up to have a few questions! First of all, I have a Satellite M30-832.
    1. He has on the dvd player on the side of the Compact disk with re-writable below image and sign dvd R/RW under. That means it is a DVD burner as well? It does not sem to recognize blank DVDs and I was under the impression that it should be possible to write about them!

    2. can I upgrade the memory with memory DDR - RAM modules or does take a special type? And how to change them!

    Thank you very much

    Hi Richard,

    From what I can find your M30 832 is equipped with a DVD burner so you should be able to burn DVDs (the specification says you can only burn at X 1 speed for DVDs).

    You should be able to update your RAM to a maximum of 2 GB and I recommend you buy a quality mark to avoid any problems. Your user manual should have details on how to change the RAM modules, but generally it will be to remove a panel of access (usually on the bottom of the unit) and then releasing it two clips (one on each side of the RAM modules) plastic spring-loaded and gently raising the output modules.

    Please make sure that you either wear a wristband anti-statuc dirt or this earth you yourself before accessing RAM modules. They are very sensitive to electrostatic.

    You can find suppliers of RAM suitable if you GOOGLE 'M30 832 RAM.

    HTH)

Maybe you are looking for