FOR exception management loop

Given the following code:
for x in my_cursor loop
    begin
        <<stmt_1>>
        <<stmt_2>>
    exception
        when others then
            <<log_error>>
    end;
end loop;
Say there are 5 x in my_cursor. On the element x 3, stmt_1 works fine but stmt_2 throws an exception. I would like to restore ONLY the work done on x 3 (in this case, stmt_1), then continue the loop of the next element, x 4. Can this be achieved with a combination of backup/restore point?

In this particular case, I would suggest that you follow the third example I posted where you stand on the core of your loop in a procedure such that you change only the values of a and b If your insert succeeds, that is

CREATE OR REPLACE PROCEDURE proc_name( p_x IN NUMBER, p_a IN OUT NUMBER, p_b IN OUT NUMBER )
AS
  l_tmp_a NUMBER;
  l_tmp_b NUMBER;
BEGIN
  SAVEPOINT s1;
  l_tmp_a := p_a + p_x;
  l_tmp_b := 1/(6-l_tmp_a);
  INSERT INTO test_tbl VALUES( l_tmp_a, l_tmp_b );
  p_a := l_tmp_a;
  p_b := l_tmp_b;
EXCEPTION
  WHEN <>
  THEN
    ROLLBACK TO SAVEPOINT s1;
END;

You can, of course, have the same local variables of the TMP in your original code. Or you could replicate the calculations, i.e.

for x in 1..5 loop
begin
  savepoint s;
  insert into test_tbl values(a+x,1/(6-a));
  a := a+x;
  b := 1/(6-a);
exception
  when others then
    rollback to savepoint s;
end;

Justin

Tags: Database

Similar Questions

  • How to properly code for exception management?

    Hey you wonderful people you

    I have a quesiton on how to correctly code in PL/SQL for exception management. Here is my code below, I was told that how I use in my script of exception handling is simply not true.

    Can someone please adjust the section where I use the management of exceptions and show me what is the appropriate way to deal with exceptions.

    Here is the table creation script, so you can see what how the script fills the table DYNAMIC_COUNTS.

    --------------------------------------------------------------------------------------------------------------------------

    CREATE TABLE DYNAMIC_COUNTS

    (VARCHAR2 (30 BYTE) "T_OWNER",

    VARCHAR2 (30 BYTE) "T_TABLE_NAME."

    VARCHAR2 (30 BYTE) "T_COLUMN_NAME."

    NUMBER OF 'FND_PATTERNS');

    Now, here's the script:

    ------------------------------------------------------------------------------------------------------------------------

    Set serveroutput size unlimited
    run the DBMS_OUTPUT. ACTIVATE (buffer_size = > NULL);

    DECLARE

    TYPE nt_tab IS TABLE OF dynamic_counts % ROWTYPE;

    v_nttab nt_tab: = nt_tab();

    FND_LOOK INTEGER.

    v_incr NUMBER: = 0;

    ------------------------------------------------------------------------------------------------------------------------

    BEGIN

    FOR t IN (SELECT master, table_name, column_name

    From all_tab_columns

    Owner WHERE = UPPER ('& SCHEMA_NAME'))

    ------------------------------------------------------------------------------------------------------------------------

    LOOP

    BEGIN

    EXECUTE IMMEDIATE ' with an ACE (select case when REGEXP_LIKE (' | t.column_name |))

    -This search 1 letter and 12 figures-
    ', "^ ([[: alpha:]] |) [[: alpha:]] ({3}) [0-9] {12} $")



    then "match"

    another "no matches found" end up as output of ' | t.Owner | '.' || t.table_name | ')

    Select count (*) in a where a.output = "Match Found" clause '


    IN FND_LOOK;


    ------------------------------------------------------------------------------------------------------------------------
    IF FND_LOOK > 0 THEN

    v_incr: = v_incr + 1;

    v_nttab. EXTEND;

    v_nttab (v_incr) .t_owner: = t.owner;

    v_nttab (v_incr) .t_table_name: = t.table_name;

    v_nttab (v_incr) .t_column_name: = t.column_name;

    v_nttab (v_incr) .fnd_patterns: = FND_LOOK;

    END IF;

    ------------------------------------------------------------------------------------------------------------------------
    / * This is for DBMS output, thus we have 2 different ways, one can see the results in the table dynamic_counts
    and in the dbms_output
    */


    IF FND_LOOK > 0 THEN


    Dbms_output.put_line (t.owner |) '.' || t.table_name | ' ' || t.column_name | ' ' || FND_LOOK);



    END IF;


    ------------------------------------------------------------------------------------------------------------------------

    / * Exception handling * /.



    EXCEPTION

    WHILE OTHERS

    THEN

    Dbms_output.put_line)

    "Generic error".

    || t.column_name

    || "from".

    || t.Owner

    || '.'

    || t.table_name);

    END;

    END LOOP;

    ------------------------------------------------------------------------------------------------------------------------

    FORALL i IN 1.v_nttab. COUNTY

    INSERT INTO dynamic_counts (t_owner,

    t_table_name,

    t_column_name,

    fnd_pattens)

    VALUES (v_nttab (i) .t_owner,

    v_nttab (i) .t_table_name,

    v_nttab (i) .t_column_name,

    v_nttab (i) .fnd_patterns);

    COMMIT;

    END;

    /


    Isn't there. In the statement in the EXCEPTIONS section dbms_output.

  • common code in oracle exception Manager

    Hi all

    Here is the situation where I'm stuck...
    The current code handles all errors as shown below:
    WHILE OTHERS
    THEN
    IF cur_hdr % ISOPEN
    THEN
    CLOSE Cur_hdr;
    END IF;

    IF cur_det % ISOPEN
    THEN
    CLOSE Cur_det;
    END IF;

    ECODE: = SQLCODE;
    emesg: = v_trace_str | SQLERRM;
    SM_CONTROL_PKG.
    handle_db_error (v_package_name |) '.' || v_procedure_name,
    emesg,
    v_trace_str,
    (TRUE);
    V_RETVALUE: = 1;
    ROLLBACK;
    end;


    Now, I was asked to introduce an error more, it is a user-defined error.
    so I defined
    no_detail_for_header_ex EXCEPTION;

    In my code, I say,
    Open the cursor in the header
    Open detail slider - there no line

    So I say
    v_trace_str: =' no details for header-ERROR '
    Rossanna no_detail_for_header_ex;

    But in part, exception management
    I say,

    When no_detial_for_header_ex then
    IF cur_hdr % ISOPEN
    THEN
    CLOSE Cur_hdr;
    END IF;

    IF cur_det % ISOPEN
    THEN
    CLOSE Cur_det;
    END IF;

    ECODE: = SQLCODE;
    emesg: = v_trace_str | SQLERRM;
    SM_CONTROL_PKG.
    handle_db_error (v_package_name |) '.' || v_procedure_name,
    emesg,
    v_trace_str,
    (TRUE);
    V_RETVALUE: = 1;
    ROLLBACK;


    If you can see, the code is the same.
    close cursors and call the handle_db_error.

    I don't want to code the same thing again.
    Here, errors are different, but handled the same way. only the trace_str varies.

    I want to write something like
    When no_detial_for_header_ex or other PEOPLE can
    same code.

    is this possible with others.
    or any other suggestions.

    Thnaks in advance.

    Sure. Just declare the parameters in your cursor, then move them during the call of loop.

    cursor my_cursor (my variable)
    is
    select .... from .... where column = my variable;
    
    for cursor_rec in my_cursor (my value)
    loop
       ...
    end loop;
    

    A google for cursor for loop syntax should clear up any questions. Consider reading the Oracle pl/SQL and documentation.

  • "Setup is preparing your computer for first use" loop problem

    Hello, I was hoping you guys could help out me with a big problem, I ran across when trying to install Windows 7 on a desktop computer new, custom - build. I managed to successfully install my Windows 7 64-bit, it appeared, but when I try to run it, that I will meet a black screen that says "Setup is preparing your computer for first use" and it will stay there forever, I would say. I let it run all night and didn't go anywhere.

    I tried to start in safe mode, and Windows was loading files sys32, he got to "Classpnp.sys" and it froze. After a few minutes, the screen is blacked out, and I got fired the familiar screen "Setup is preparing your computer for first use.

    I bought the copy of Windows 7 nine FRY, there will be no problem with that. My HD is a (new) 240 GB PNY Optima SSD, my mobo is a (new) Z97X-SLI Gigabyte, and I have 16 GB of RAM. All these things have been recognized by my BIOS, it seems that everything is properly connected.

    I tried to install Windows 7 on a second time and exactly the same thing happened. I also tried to repair the installation to start upward, but he finds no problems. Also a check of the memory and the disk has verified without any problem. The only things I plugged are my monitor, keyboard, and mouse.

    Does anyone know of a workaround for this screen loop "first use"? Any help would be greatly appreciated.

    Set of utilities to test for computer HARDWARE manufacturers:

    Note: If you are Overclocking or use an automatic overclocking or BIOS power saving features, start by disabling: Intel EIST, Turbo Mode, Cool and pretty and fall back to the speed of stock as a starting point.

    Disconnect any other (additional) internal hard drives and external USB devices.

    Look for any loose hard drive power or cables SATA, graphics card or other power cables.

    First run Memtest86 +:

    It runs from a floppy disk or CD and should eliminate or confirm if one or more of your memory

    sticks are bad or the values of the SPD in the BIOS are correct.

    Let it run for as long as you can: 2,4,6,8 or several hours (at least 3 full passes), if no errors at that time then your ram is OK.

    http://www.memtest.org/

    Memtest86 + Guide/How To (use the.) ISO to create a bootable CD)

    http://www.overclockers.com/forums/showthread.php?t=409152

    Test your hard drive

    Intel® drive SSD Toolbox

    https://Downloadcenter.Intel.com/Detail_Desc.aspx?AGR=Y&DwnldID=18455

    Corsair SSD Toolbox:

    http://www.Corsair.com/en-us/blog/2013/may/the-Corsair-SSD-Toolbox

    Toolbox of Kingston:

    http://www.Kingston.com/us/support/technical/sandforce_ssd_toolbox.aspx

    OCZ Toolbox: http://ocz.com/consumer/download/firmware

    Support PNY: http://www.PNY.com/support/contact-us

    Samsung: http://www.samsung.com/global/business/semiconductor/minisite/SSD/global/html/about/whitepaper07.html

    Samsung Magican review:

    http://www.TweakTown.com/articles/5638/Samsung-magician-4-2-first-look-new-SSD-Toolkit-adds-rapid-mode/index.html

    SanDisk SSD Toolkit: http://kb.sandisk.com/app/answers/detail/a_id/9328/

    Seagate: http://www.seagate.com/support/internal-hard-drives/laptop-hard-drives/laptop-600-ssd/

    Life of the SSD: http://ssd-life.com/

    = Is installed after Windows =.

    Device drivers: have you installed latest drivers from device of the manufacture of the motherboard?

    Check their support site for the latest drivers as the CD that came with the computer

    or motherboard may be older and less stable drivers.

    Visit the download of the manufacture of the graphics card:

    Download and install the most recent Windows 7 or 8 drivers for your card.

    ATI: http://support.amd.com/us/gpudownload/Pages/index.aspx

    NVIDIA: http://www.nvidia.com/Download/index.aspx?lang=en-us

    See also the test of 'Smoke box' Nvidia or other demos: http://www.nvidia.com/object/cool_stuff.html#/demos

    or equivalent ATI.

    Prime 95:

    http://www.Mersenne.org/freesoft/

    It's a stand alone .exe file contained in an archive .zip.

    Simply choose to run the 'stress test' option for 8 hours or more.

    If your PC can pass this test, your memory and CPU

    are very good (close the housing cover in order to maintain adequate ventilation)

    Core Temp:

    The temperature of each core of the processor.

    Note: For the overclockers using stock radiator and cooling fan Intel/AMD you can expect

    a range of 35 to 40 at idle and 60 to 65 C max temperature when running Prime95.

    http://www.alcpu.com/CoreTemp/

    CPU ID (CPUZ): http://www.cpuid.com/cpuz.php

    Watch the clock speed of the CPU under various conditions of loading

    (when using speed step technology Intel EIST).

    #1 Note:

    CPU - ID has two tabs - tab 'Memory' that shows the actual speed of the memory

    and the "SPD" tab shows the nominal speeds for each memory location that is filled.

    #2 Note:

    Compare the two values, the actual speed of the memory must not exceed the rated speed of your memory.

    CPUID HWMonitor: Hardware program that reads the sensors of health main PC monitoring systems.

    voltages, temperatures, fans speed.

    http://www.CPUID.com/HWMonitor.php

    Speccy:

    Advanced for your PC system information tool.

    Need to know what's inside your computer?

    No problem! Speccy will give you all the information you need.

    Note: May or may not show the motherboard manufacturing.

    Overview: https://www.piriform.com/speccy

    Free version: https://www.piriform.com/speccy/download

    Test of Stress of FurMark GPU (graphics card):

    http://www.oZone3D.NET/benchmarks/fur/

    Pass marks burn in test: http://www.passmark.com/

    Burnin test, and their test bench at the same time give a good workout from all the major parts of Windows.

    HD Tune:

    Provides information of the car and has an option (tab scan error) to test your drive.

    http://www.hdtune.com/

    CrystalDiskInfo:

    http://CrystalMark.info/software/index-e.html

    User Manual: http://crystalmark.info/software/CrystalDiskInfo/manual-en/

    Monitors the State of health and the temperature. Solid State Drives brackets (value of the software).

    SpeedFan:

    Monitors internal temperatures and has a function of analysis health online (SMART tab) for hard disks drive.

    It displays your drives model number and compares your drive with other discs of the same brand and model.

    Note: Unfortunately now includes a lot of bloatware, be very careful when installing remove bloatware.

    http://www.almico.com/SpeedFan.php

    GPU - Z:

    A utility light, designed for you give information about your video card and GPU.

    http://www.techpowerup.com/GPUZ/

    PC WIZARD:

    A powerful utility designed especially for detection of hardware, also analyses more.

    He is able to identify a large scale of system components and supports the latest technologies

    and standards.

    http://www.CPUID.com/pcwizard.php

    J W Stuart: http://www.pagestart.com

  • simple question re RD230 module for remote management

    Hello

    Just bought and installed Rd230. Installed win2008 R2 SP1 (manually... not with easystartup).

    I read the for the management module user guide remote. Is superb! One thing... How to set up the MMR? (Address IP... etc). It is not in the BIOS... I don't see any prompt at startup to access a utility of config for IT... any help?

    Thank you

    M

    You will find information conrfiguration and answers to the other questions linked MMR in

    ThinkServer RD230 and RD240 Remote Management User Guide TeleManagement ThinkServer RD230 and RD240 user's guide:

    Download.Lenovo.com/ibmdl/pub/PC/pccbbs/ThinkServers/00697mst.pdf

  • Time for a while loop to run once

    Hello guys,.

    I want to measure the time for a while loop to run once. There is a piece of code raised. So I just created a simple VI to try, please let me know which is the right way to do it?

    And I wondered, when I run the VI without highlighting the execution, he wouldn't give me a number, maybe it's because the code is simple and really fast? I have to highlight all the time?

    Thank you

    Not quite right.  Both get primitive value time will run at the same time.  use an image sequence to force the order of execution, as shown.  I also brought in the relitve of accuracy seconds vi of VI. LIB\utilities because it depends on the clock of the system rather than the mSec timer accuracy.

  • While why broken arrow will not appear for a timed loop

    Hi all

    I need a little clarification relative to normal while loop and timed looping in labview.

    In labview, if I keep a while loop on a block diagram, broken arrow will appear in the upper left corner of the window indicating the error. It displays error because I have not wired conditional terminal of the while loop.

    But same is not the case for a timed loop. Can someone tell me what is the reason behind this...

    If I release the conditional terminal of the timed while loop, it runs in infinfite time like a normal while loop. Then y labview behaves differently for these two types of loops in the scenario above.

    FYI... I'm using labview 2009.

    Waiting for response.

    Thank you

    Herald

    Ruben,

    the reason is quite simple: call loops are mostly real-time and FPGA targets. Since most of the applications on these targets work continuously (at least this is more often the task), it is possible to create a loop that does not end. So the timed loop by default assumes that there is no need of a stop button.

    The 'normal' while loop needs code for termination (conditional terminal) because normal applications on Windows/Linux/Mac are used to be fair...

    hope this helps,

    Norbert

  • loop for and while loop with empty table entry

    Hello

    I have a question with loop and loop.

    When a constant empty array (zero element) is connected to the loop For with "allowing the index", there are no interactions performed in loop For. But, if the loop is replaced by any loop, no problem.

    LabVIEW 2010

    Hello

    It is ok. I have no problem at all.

    For the 'loop' For when you connect the table thanks to indexing, the number of iterations is set to the size of the array. The iteration number assigned to N (in your case 10) is ignored.

    For the 'While' loop the number of iteration is defined by the Boolean Condition and the size of the array is ignored.

    Paul

  • do I need to use the product for the management of the recovery key to refresh the window 8.1?

    do I need to use the product for the management of the recovery key to refresh the window 8.1?

    No, the product key will be automatically read from the BIOS.

  • [Q] how to build and install an SSL certificate signed for the management of a Cisco 5508 WLC?

    Our security policy requires that all web pages admin must be signed by our CA business. I have successfully implemented a SSL certificate 3rd party Auth Web our WLAN of comments, but I need to install a self-signed certificate for the management of the WLC himself. I followed the instructions here:

    http://www.Cisco.com/en/us/Tech/tk722/tk809/technologies_configuration_example09186a00806e367a.shtml

    but it was more useful for Web auth. I can't find a specific document explaining how it should be done for the management interface.

    Any help much appreciated.

    (1) Please use a password. Empty passwords regularly give problems.

    (2) you don't recombine the key with the certificate before you download to the WLC:

    Combine the CA.pem certificate with the private key, and then convert the file to a .pem file.

    Type this command in the OpenSSL application:

    openssl>pkcs12 -export -in CA.pem -inkey mykey.pem -out CA.p12 -clcerts
    -passin pass:check123 -passout pass:check123


    !--- This command should be on one line.

    openssl>pkcs12 -in CA.p12 -out final.pem -passin pass:check123 -passout pass:check123

    Note: In this command, you must enter a password for the parameters -passin' and -passout . The password is set to the setting -passout must match the setting SubscriptionId is configured on the WLC. In this example, the password is configured at the time the -passin' and settings -passout is check123. Step 4 of the procedure in the section download the WLC third certificate of this document deals with the configuration of the SubscriptionId parameter.

    The final.pem is the file that is transferred via TFTP to the Cisco WLC.

    Now that you have the certificate of the third-party CA, you must download the certificate to the WLC.

  • Foglight for storage management

    Foglight for Storage Management supports management switches HP9500 and storage Compellent and it is just a rebranding or does it have capacity/news?

    It doesn't support HP fiber switches, but it supports without Compellent.  The latest version adds support for physical systems related to the storage, General corrections and some new elements of the user interface.

  • I want to know what is the best possible settings for energy management software.

    Hey

    I just buy lenovo b 570 e dual core laptop.
    I want to know what is the best possible settings for energy management software.
    Secondly, I want to know b 570 e score if one is to use it.
    Thank you
    concerning
    Nadine
     
    Original title: lenovo B 570 e dual-core

    Hi Nadia,

    I suggest you to use your favorite search engine to find the best possible settings for energy management software.

    If you are referring to the Windows experience index, I suggest you follow the links below and the update of the status of the issue.

    What is the Windows experience index? :

    http://Windows.Microsoft.com/en-in/Windows7/what-is-the-Windows-experience-index

    Windows experience index:

    http://Windows.Microsoft.com/en-in/Windows7/products/features/Windows-experience-index

    I hope that the information above helps you.

  • Help for Stock management.

    Dear all,

    We develop a custom software for the management of stocks. Please advice, how can we manage the Stock? The customer may have several Branches / stores.

    Thanks in advance,

    Vishnu.

    Dear Vishnu.,.

    You can manage the stock in different ways,

    1. As HamidHelal said, create a table in which there will be minimum 3 fields, branch, section and stock code code. In this method, although each transaction is entered, changed, or deleted, you must change the stock field.
    2. Create a table that stores the primary key of the transaction date of the transaction, branch code, code section and stock. In this method, there will be a separate folder for every transcation (item wise). for the stock, you must take the amount.
    3. Third method is to create a view, which gives you the stock items. In this regard, all the tables of the transaction will be UNION ALL and then take the AMOUNT for the stock. Hereby you need to change / manage manually by each transaction.
    4. In this method, create a view which is a UNION ALL view that contains the details of wise transaction (in option 2). Take the SUM to get the final stock.

    You can choose one of these methods based on requirements.

    Manu.

  • I bought Lightroom 6 and when I open the application for Adobe Manager it does give me an option to download. Are they not turns on the map?

    I bought Lightroom 6 and when I open the application for Adobe Manager it does give me an option to download. Are they not turns on the map?

    Download & install instructions https://forums.adobe.com/thread/2003339 can help

    -includes a link to access a page to download the Adobe programs if you do not have a disk or drive

    Also go to https://forums.adobe.com/community/creative_cloud/creative_cloud_faq

  • As part of the SAR cert is to have a NW separated between ESXi host required for VMotion or is it OK to use IP for VMotion management, in the execution of Certification tests.

    As part of the SAR cert is "have a NW/dedicated separate between hosts ESXi (on which we GOS) mandatory for VMotion or is - OK to use IP for VMotion management in the execution of Certification tests.»

    Note that the verification passed Test when you use management IP for Vmotion and without a dedicated connection to NW between ESXi hosts.

    Separate dedicated network interface cards preferred. No problem with the test after this change case.

Maybe you are looking for

  • Question on how to choose the tensions to describe VEE 6 pulses of 0-10-10-15 0 0 1 s 0

    Hi all, I want to use AWR to simulate some CSOS COLPITTS BJT, hspice codes and I want to put the circuit on AWR and run it and see what happens?  Everything goes well, but one I'm confused, it's VEE 6-10-15 0 0 1 0 s 0-10 PULSES.  Can someone tell me

  • DV7-6c23cl: password on the DV7-6c23cl market

    Hello. I need assistance with a bios password. The code after three attempts at password is 59252476 Thank you.

  • Synaptics PS/2 Port Touchpad

    Good evening I have a laptop Compaq Presario CQ62 under Windows 7 Home Premium. I have problems with Touchpad Synaptics PS/2. Sometimes it works, and most of the time, it freezes and won't do anything. I checked the HP Web site for an update of the d

  • You can change the height of a digital indicator in LabVIEW 2010?

    It seems that you could have is LV 7.1 such that referenced by this article: http://digital.NI.com/public.nsf/allkb/AFCA584E0A70774586256E970052AFC3 However, I also found that in 8.5 you apparently cannot resize the height of the indicator/control...

  • Update of uncertainty

    I have a HP Pavilion Notebook 15-n243cl running on Windows 8.1. Check the drivers and the software, I see there's an HP Notebook System BIOS (AMD processors) update to F.15 I'm not sure. My current BIOS is Insyde F.15 and I have an AMD processor. I f